/* styles.css (v7.3 - Dark/Light Theme) */

/* Define color variables for Light Theme (default) */
:root {
    --bg-primary: #e9ebee; /* Main background */
    --bg-secondary: #f8f9fa; /* Header, lighter sections */
    --bg-card: #ffffff; /* Product cards, cart, section backgrounds */
    --bg-top-bar: #ffffff;
    --bg-footer: #212529; /* Dark footer for contrast in light mode */

    --text-primary: #212529; /* Darker main text for better readability */
    --text-secondary: #495057; /* Subdued text */
    --text-headings: #343a40; /* Section headings */
    --text-header-h1: #007bff; /* Main header H1 */
    --text-header-p: #6c757d;
    --text-footer: #f8f9fa; /* Light text on dark footer */
    --text-on-accent: #ffffff; /* Text on primary/secondary accent buttons */

    --accent-primary: #007bff; /* Primary buttons, links, highlights */
    --accent-primary-hover: #0056b3;
    --accent-secondary: #28a745; /* Success/checkout buttons */
    --accent-secondary-hover: #218838;
    --accent-danger: #dc3545; /* Remove buttons */
    --accent-danger-hover: #c82333;
    --accent-unavailable: #6c757d; /* Disabled/unavailable buttons */
    --accent-unavailable-hover: #5a6268;

    --border-primary: #dee2e6; /* Borders for cards, top bar */
    --border-secondary: #ced4da; /* Slightly darker for some elements */
    --border-cart-item: #e9ecef;

    --shadow-color-light: rgba(0, 0, 0, 0.075); /* Softer shadows */
    --shadow-card: 0 4px 8px var(--shadow-color-light);
    --shadow-card-hover: 0 6px 12px rgba(0, 0, 0, 0.1);
    --shadow-top-bar: 0 2px 4px rgba(0, 0, 0, 0.1);

    /* Theme Toggle Button Specific */
    --theme-toggle-bg: #f8f9fa;
    --theme-toggle-icon: #007bff; /* Moon color in light mode */
    --theme-toggle-bg-hover: #e2e6ea;
    --theme-toggle-border: #ced4da;
}

/* Define color variables for Dark Theme */
body.dark-theme {
    --bg-primary: #212529; /* Very dark main background */
    --bg-secondary: #2c3034; /* Slightly lighter for header */
    --bg-card: #343a40; /* Darker cards, cart, sections */
    --bg-top-bar: #1a1d20; 
    --bg-footer: #16191c; 

    --text-primary: #f8f9fa; /* Light gray/off-white text */
    --text-secondary: #adb5bd; /* Lighter subdued text */
    --text-headings: #ffffff; /* White section headings */
    --text-header-h1: #5dade2; /* Lighter blue for main header H1 */
    --text-header-p: #95a5a6;
    --text-footer: #adb5bd;
    --text-on-accent: #ffffff;

    --accent-primary: #5dade2; 
    --accent-primary-hover: #3498db;
    --accent-secondary: #2ecc71; 
    --accent-secondary-hover: #27ae60;
    --accent-danger: #e74c3c; 
    --accent-danger-hover: #c0392b;
    --accent-unavailable: #7f8c8d; 
    --accent-unavailable-hover: #95a5a6;

    --border-primary: #495057; /* Darker borders */
    --border-secondary: #525960;
    --border-cart-item: #495057;

    --shadow-color-light: rgba(0, 0, 0, 0.3); /* Shadows might be less visible or different */
    --shadow-card: 0 4px 8px rgba(0,0,0,0.25);
    --shadow-card-hover: 0 6px 12px rgba(0,0,0,0.3);
    --shadow-top-bar: 0 2px 4px rgba(0,0,0,0.4);
    
    --theme-toggle-bg: #343a40;
    --theme-toggle-icon: #f1c40f; /* Sun icon color in dark mode */
    --theme-toggle-bg-hover: #495057;
    --theme-toggle-border: #525960;
}

/* Apply variables */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-primary);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.top-bar {
    background-color: var(--bg-top-bar);
    padding: 10px 25px;
    display: flex;
    align-items: center;
    justify-content: space-between; /* For logo and toggle button */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: var(--shadow-top-bar);
    border-bottom: 1px solid var(--border-primary);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.top-bar .logo-link img {
    height: 45px;
    cursor: pointer;
    vertical-align: middle;
}

#theme-toggle-btn {
    background-color: var(--theme-toggle-bg);
    color: var(--theme-toggle-icon);
    border: 1px solid var(--theme-toggle-border);
    padding: 8px 12px;
    border-radius: 50%; 
    cursor: pointer;
    font-size: 1.2em; 
    transition: background-color 0.3s ease, color 0.3s ease, transform 0.2s ease, border-color 0.3s ease;
    line-height: 1;
    width: 40px; /* Explicit size */
    height: 40px; /* Explicit size */
    display: flex;
    align-items: center;
    justify-content: center;
}

#theme-toggle-btn:hover {
    background-color: var(--theme-toggle-bg-hover);
    transform: scale(1.1);
}


body > *:not(.top-bar) {
    margin-top: 75px; 
}

header {
    text-align: center;
    padding: 20px 20px 10px 20px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-secondary);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

header h1 {
    margin: 10px 0;
    font-size: 2.2em;
    color: var(--text-header-h1);
    font-weight: 600;
    transition: color 0.3s ease;
}
header p {
    font-size: 1.1em;
    color: var(--text-header-p);
    margin-bottom: 10px;
    transition: color 0.3s ease;
}

main {
    flex: 1;
    padding: 20px;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    box-sizing: border-box;
}

section {
    text-align: center;
    margin-bottom: 35px;
    background-color: var(--bg-card); 
    padding: 25px;
    border-radius: 12px;
    box-shadow: var(--shadow-card);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

section h2 {
    margin-top: 0;
    margin-bottom: 25px;
    color: var(--text-headings);
    font-size: 1.8em;
    font-weight: 600;
    transition: color 0.3s ease;
}

.machine-list,
.product-list {
    display: flex;
    justify-content: center; 
    flex-wrap: wrap;
    gap: 25px;
}

.machine,
.product {
    background-color: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: 10px;
    padding: 20px;
    width: 280px; 
    text-align: center;
    box-shadow: var(--shadow-card);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
}

.machine:hover,
.product:hover:not(.unavailable) {
    transform: translateY(-8px) scale(1.02); 
    box-shadow: var(--shadow-card-hover);
}

.machine img,
.product img {
    max-width: 100%;
    height: 160px; 
    object-fit: contain;
    border-radius: 8px;
    display: block;
    margin: 0 auto 15px auto;
    border: 1px solid var(--border-secondary); 
    transition: border-color 0.3s ease;
}

.machine h3,
.product h2 { 
    font-size: 1.3em; 
    font-weight: 600;
    margin: 0 0 10px 0;
    color: var(--text-primary); 
    min-height: 2.8em; 
    transition: color 0.3s ease;
}

.product p { 
    font-size: 0.90em; 
    color: var(--text-secondary);
    margin: 5px 0 10px 0; 
    flex-grow: 1;
    line-height: 1.5;
    transition: color 0.3s ease;
}
.product p.price { 
    font-weight: bold;
    color: var(--accent-secondary); 
    font-size: 1.2em;
    margin-bottom: 15px;
    flex-grow: 0;
    transition: color 0.3s ease;
}

.machine a,
.product button.add-to-cart-btn { 
    display: inline-block;
    background-color: var(--accent-primary);
    color: var(--text-on-accent); 
    padding: 12px 20px;
    border-radius: 6px; 
    text-decoration: none;
    margin-top: 15px;
    border: none; 
    cursor: pointer; 
    font-size: 1em;
    font-weight: 500;
    transition: background-color 0.2s ease, transform 0.1s ease, color 0.3s ease;
    width: 100%;
    box-sizing: border-box;
}

.machine a:active,
.product button.add-to-cart-btn:active {
    transform: scale(0.98); 
}

.machine a:hover:not(.offline), 
.product button.add-to-cart-btn:hover:not([disabled]) { 
    background-color: var(--accent-primary-hover);
}

.machine a.offline,
.product.unavailable button.add-to-cart-btn {
    background-color: var(--accent-unavailable) !important;
    cursor: not-allowed !important;
}
.machine a.offline:hover,
.product.unavailable button.add-to-cart-btn:hover {
    background-color: var(--accent-unavailable-hover) !important;
}

.product.unavailable {
    opacity: 0.6;
    background-color: var(--bg-secondary); 
    box-shadow: none; 
    transform: none !important; 
}
.product.unavailable img {
    filter: grayscale(100%);
}
.product.unavailable .quantity-control button,
.product.unavailable button.add-to-cart-btn {
    background-color: var(--accent-unavailable); 
    cursor: not-allowed;
    pointer-events: all !important; 
}

.quantity-control {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 15px 0;
}
.quantity-control button {
    background-color: var(--accent-primary);
    color: var(--text-on-accent); 
    border: none;
    padding: 8px 12px;
    border-radius: 50%; 
    width: 36px; 
    height: 36px; 
    font-size: 1.2em;
    cursor: pointer;
    line-height: 1;
    transition: background-color 0.2s ease, color 0.3s ease;
}

.product.unavailable .quantity-control button {
    background-color: var(--accent-unavailable);
}

.quantity-control button:hover:not([disabled]) {
    background-color: var(--accent-primary-hover);
}
.quantity-control span {
    display: inline-block;
    width: 45px; 
    text-align: center;
    font-size: 1.2em; 
    margin: 0 8px; 
    font-weight: 600;
    color: var(--text-primary); 
    transition: color 0.3s ease;
}

.cart, 
#checkout-summary {
    background-color: var(--bg-card); 
    padding: 25px;
    border-radius: 12px; 
    margin-top: 30px;
    border: 1px solid var(--border-secondary); 
    box-shadow: var(--shadow-card); 
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.cart h2,
#checkout-summary h2 {
    margin-top: 0;
    color: var(--accent-primary); 
    border-bottom: 2px solid var(--accent-primary);
    padding-bottom: 12px;
    margin-bottom: 20px;
    font-size: 1.6em; 
    transition: color 0.3s ease, border-color 0.3s ease;
}

#cart-items {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

#cart-items li {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border-cart-item); 
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1em; 
    color: var(--text-primary); 
    transition: color 0.3s ease, border-color 0.3s ease;
}
#cart-items li:last-child {
    border-bottom: none;
}
#cart-items li .item-details { 
    flex-grow: 1;
}
#cart-items li .item-price { 
    min-width: 80px; 
    text-align: right;
    font-weight: 500;
    color: var(--text-secondary); 
    transition: color 0.3s ease;
}

#cart-items li button.remove-item {
    background-color: var(--accent-danger);
    color: white; 
    border: none;
    padding: 6px 12px; 
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    margin-left: 15px; 
    transition: background-color 0.2s ease;
}
#cart-items li button.remove-item:hover {
    background-color: var(--accent-danger-hover);
}

#total-price {
    font-weight: bold;
    font-size: 1.4em; 
    text-align: right;
    margin-top: 20px;
    color: var(--accent-primary); 
    padding-top: 15px;
    border-top: 2px solid var(--accent-primary);
    transition: color 0.3s ease, border-color 0.3s ease;
}

.cart button[onclick="checkout()"], 
#submitPayment {
    background-color: var(--accent-secondary); 
    color: var(--text-on-accent);
    padding: 14px 30px; 
    border: none;
    border-radius: 6px;
    font-size: 1.15em;
    font-weight: 500;
    cursor: pointer;
    margin-top: 25px;
    width: auto;
    display: inline-block;
    transition: background-color 0.2s ease, transform 0.1s ease, color 0.3s ease;
}
.cart button[onclick="checkout()"]:active,
#submitPayment:active {
    transform: scale(0.98);
}

.cart button[onclick="checkout()"]:hover,
#submitPayment:hover:not([disabled]) {
    background-color: var(--accent-secondary-hover);
}

#submitPayment:disabled {
    background-color: var(--accent-unavailable); 
    cursor: not-allowed;
    opacity: 0.7;
}

#statusMessage { /* Base class for status messages */
    margin-top: 20px;
    font-weight: 500;
    font-size: 1em;
    padding: 12px 15px;
    border-radius: 6px;
    text-align: center;
    border: 1px solid transparent; 
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}
#statusMessage.success {
    color: #155724; background-color: #d4edda; border-color: #c3e6cb;
}
body.dark-theme #statusMessage.success {
    color: #d4edda; background-color: #1d4a27; border-color: #2b6432; /* Adjusted dark theme success */
}
#statusMessage.error {
    color: #721c24; background-color: #f8d7da; border-color: #f5c6cb;
}
body.dark-theme #statusMessage.error {
    color: #f8d7da; background-color: #721c24; border-color: #8b2c36;
}
#statusMessage.info {
    color: #004085; background-color: #cce5ff; border-color: #b8daff;
}
body.dark-theme #statusMessage.info {
    color: #cce5ff; background-color: #002752; border-color: #005cbf; /* Adjusted dark theme info */
}

footer {
    background-color: var(--bg-footer);
    padding: 25px 20px;
    width: 100%;
    text-align: center;
    margin-top: auto;
    color: var(--text-footer);
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease;
}
.contact-info {
    font-size: 0.9em;
    margin: 0 auto;
    max-width: 800px;
    padding: 0;
}
.contact-info p {
    margin: 8px 0; 
}

.offline-message-section { 
    padding: 30px;
    background-color: var(--bg-card); 
}
.offline-message-section p {
    font-size: 1.2em;
    margin-bottom: 20px;
    color: var(--text-primary);
}
.offline-message-section a {
    background-color: var(--accent-primary);
    color: white; 
    padding: 10px 20px;
    text-decoration: none;
    border-radius: 5px;
    transition: background-color 0.2s ease;
}
.offline-message-section a:hover {
    background-color: var(--accent-primary-hover);
}
/* Add these new styles to your existing styles.css */

/* ... (all your existing styles.css content) ... */

/* Styles for the total and payment instruction section in checkout */
.total-section {
    text-align: right; /* Aligns both total and instruction to the right */
    margin-top: 20px;
    padding-top: 15px;
    border-top: 2px solid var(--accent-primary); /* Use existing variable */
}

#total-price {
    font-weight: bold;
    font-size: 1.4em; 
    color: var(--accent-primary); 
    margin-bottom: 5px; /* Add some space below the total */
    /* Removed margin-top and border-top as they are on .total-section now */
}

.payment-instruction-text {
    font-size: 0.9em;
    font-style: italic;
    color: var(--text-secondary); /* Use existing variable */
    margin-top: 0; /* Remove default p margin if needed */
}

/* Ensure status message styling is applied */
#statusMessage.status-message { /* Ensure base class is targeted if you added it */
    margin-top: 20px;
    font-weight: 500;
    font-size: 1em;
    padding: 12px 15px;
    border-radius: 6px;
    text-align: center;
    border: 1px solid transparent; 
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}
/* You should already have the .success, .error, .info styles for statusMessage */


