/*
 * =======================================
 * 1. MD3 COLOR SYSTEM (THEMING)
 * =======================================
 */

/* MD3 Light Theme (Default/Fallback) */
:root {
    --md-sys-color-primary: #6750A4;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #EADDFF;
    --md-sys-color-on-primary-container: #21005D;

    --md-sys-color-secondary: #625B71;
    --md-sys-color-on-secondary: #FFFFFF;
    --md-sys-color-on-surface-variant: #49454F; /* Added for subtle text */

    --md-sys-color-surface: #FFFBFE; /* Primary Background */
    --md-sys-color-on-surface: #1C1B1F; /* Primary Text Color */
    --md-sys-color-surface-container-low: #F7F2FA;
    --md-sys-color-surface-container: #F3EDF7; /* Navbar, Footer */
    --md-sys-color-surface-container-high: #EADDFF; /* Cards/Containers */
    --md-sys-color-outline: #79747E;
}

/* MD3 Dark Theme (Applied when system preference is dark) */
@media (prefers-color-scheme: dark) {
    :root {
        --md-sys-color-primary: #D0BCFF;
        --md-sys-color-on-primary: #381E72;
        --md-sys-color-primary-container: #4F378B;
        --md-sys-color-on-primary-container: #EADDFF;

        --md-sys-color-secondary: #CCC2DC;
        --md-sys-color-on-secondary: #332D41;
        --md-sys-color-on-surface-variant: #C9C5C9;

        --md-sys-color-surface: #1C1B1F;
        --md-sys-color-on-surface: #E6E1E5;
        --md-sys-color-surface-container-low: #28252C;
        --md-sys-color-surface-container: #211F26;
        --md-sys-color-surface-container-high: #3C3940;
        --md-sys-color-outline: #938F99;
    }
}

/*
 * =======================================
 * 2. BASE AND TYPOGRAPHY
 * =======================================
 */

body {
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    font-family: 'Roboto', Arial, sans-serif;
    line-height: 1.5;
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden; /* Fixes horizontal scrollbar issue */
}

h1, h2, h3, h4, h5, h6 {
    color: var(--md-sys-color-on-surface);
    font-weight: 500;
}

.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    font-size: 24px;
}

/*
 * =======================================
 * 3. TOP APP BAR & FOOTER
 * =======================================
 */

.top-app-bar {
    background-color: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface);
    height: 64px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.app-bar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-icon {
    font-size: 28px;
    color: var(--md-sys-color-primary);
}

.app-bar-title {
    font-size: 22px;
    margin: 0;
    white-space: nowrap;
}

.profile-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.profile-button:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-primary) 8%, transparent);
}

.profile-icon {
    font-size: 32px;
    color: var(--md-sys-color-secondary);
}

.footer {
    background-color: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface);
    text-align: center;
    padding: 16px;
    font-size: 14px;
    opacity: 0.7;
    flex-shrink: 0;
    margin-top: auto;
}

/*
 * =======================================
 * 4. LAYOUT CONTAINERS
 * =======================================
 */

.content-area {
    flex-grow: 1;
    padding: 24px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Card Component (MD3 Surface Container High) */
.card {
    background-color: var(--md-sys-color-surface-container-high);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Auth Centering Container */
.auth-container {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
}

.auth-card {
    background-color: var(--md-sys-color-surface-container-high);
    border-radius: 28px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 24px;
}
/*
 * =======================================
 * 5. COMPONENT STYLES (BUTTONS, INPUTS)
 * =======================================
 */

/* Elevated Button (Primary Action) */
.md3-button-elevated {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
    border-radius: 20px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: background-color 0.2s, box-shadow 0.2s;
}

.md3-button-elevated:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-primary) 80%, var(--md-sys-color-on-primary));
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

/* Text Button (Secondary Action/Links) */
.md3-button-text {
    background: none;
    border: none;
    color: var(--md-sys-color-primary);
    text-transform: uppercase;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 10px;
    margin-left: -10px;
    border-radius: 20px;
    transition: background-color 0.2s;
    text-decoration: none;
    display: inline-block;
}

.md3-button-text:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-primary) 8%, transparent);
}

.navigation-link {
    text-align: center;
    font-size: 14px;
    color: var(--md-sys-color-on-surface-variant);
}

/* Text Field (MD3 Filled Style) */
.text-field {
    position: relative;
    margin-bottom: 24px;
    background-color: var(--md-sys-color-surface-container-low);
    border-radius: 4px 4px 0 0;
    padding-top: 8px;
    border-bottom: 1px solid var(--md-sys-color-outline);
    transition: border-bottom-color 0.2s;
}

.text-field:focus-within {
    border-bottom: 2px solid var(--md-sys-color-primary);
    padding-bottom: -1px;
}

.text-field label {
    position: absolute;
    top: 16px;
    left: 12px;
    pointer-events: none;
    transition: 0.2s ease-out;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 16px;
}

.text-field input {
    width: calc(100% - 24px);
    padding: 16px 12px 8px 12px;
    background: transparent;
    border: none;
    outline: none;
    font-size: 16px;
    color: var(--md-sys-color-on-surface);
}

/* Floating Label Animation */
.text-field input:focus + label,
.text-field input:not(:placeholder-shown) + label {
    top: 6px;
    font-size: 12px;
    color: var(--md-sys-color-primary);
}


/*
 * =======================================
 * 6. LANDING PAGE SPECIFIC STYLES
 * =======================================
 * (Defined here as they affect top-level layout, but use them sparingly)
 */

.landing-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 40px 48px;
    gap: 40px;
    background-color: var(--md-sys-color-surface-container);
    border-radius: 28px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.section-title {
    font-size: 32px;
    font-weight: 500;
    margin-top: 0;
    color: var(--md-sys-color-on-surface);
    border-bottom: 2px solid var(--md-sys-color-outline);
    padding-bottom: 8px;
}

/*
 * =======================================
 * 7. MOBILE OPTIMIZATIONS (RESPONSIVENESS)
 * =======================================
 */

/* Tablet & Large Mobile (Max Width 900px) */
@media (max-width: 900px) {
    .content-area {
        padding: 16px;
        gap: 16px;
    }
    .card, .landing-hero {
        padding: 16px;
    }
    h1 {
        font-size: 28px;
    }

    /* Layout stacking */
    .settings-layout, .product-detail-layout, .cart-layout, .landing-hero {
        flex-direction: column;
        gap: 24px;
    }
    .landing-hero {
        text-align: center;
    }
    .product-image-area, .product-details {
        max-width: 100%;
        padding: 0;
    }
    .product-details h1 {
        font-size: 32px;
    }
    .cart-summary {
        width: 100%;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); /* Re-adding shadow, but subtle */
    }
    .settings-sidebar {
        width: 100%;
    }
}

/* Small Mobile (Max Width 600px) */
@media (max-width: 600px) {
    .top-app-bar {
        height: 56px;
        padding: 0 12px;
    }
    .app-bar-title {
        font-size: 20px;
    }
    .auth-card {
        padding: 24px;
        border-radius: 16px;
    }
    .auth-card h2 {
        font-size: 28px;
        margin-bottom: 8px;
    }

    /* Cart Item stacking */
    .cart-item {
        flex-wrap: wrap;
        padding: 12px;
    }
    .item-details {
        flex-basis: 100%;
        order: 1;
        margin-top: 8px;
    }
    .item-quantity, .item-price {
        margin: 0 8px;
        font-size: 14px;
    }
    .item-price {
        order: 2;
    }
    .item-quantity {
        order: 3;
    }
    .md3-button-text {
        order: 4;
        margin-left: auto;
    }
    .md3-button-elevated {
        padding: 10px 16px;
    }
}
