/* Base styles - 2026 Welcome to the Jungle Theme */
* {
    box-sizing: border-box;  /* Ensure all elements include padding/border in width */
}

:root {
    --primary-color: #2D5016;     /* Deep jungle green (monstera leaves) */
    --secondary-color: #8BC34A;   /* Light jungle green */
    --dark-green: #1B4D0E;        /* Darker jungle green for depth */
    --accent-color: #FDB71A;      /* Bright carnival yellow (from official artwork) */
    --text-color: #2D5016;        /* Jungle green text */
    --border-color: #AED581;      /* Light green border */
    --background-color: #FFFAED;  /* Light yellow creme (from carnival yellow) */
    --header-height: 130px;       /* Reduced header height */
    --parrot-blue: #4FC3F7;       /* Tropical parrot blue accent */
    --parrot-orange: #FF9800;     /* Tropical parrot orange accent */

    /* Dark mode colors - "Night Jungle" theme */
    --dm-background: #1A1A1A;     /* Deep charcoal night sky */
    --dm-surface: #2A2A2A;        /* Elevated surfaces (cards) */
    --dm-primary: #4CAF50;        /* Brighter jungle green */
    --dm-accent: #FFC107;         /* Warm yellow (better contrast) */
    --dm-text-primary: #E8F5E9;   /* Very light green tint */
    --dm-text-secondary: #A5D6A7; /* Muted light green */
    --dm-border: #3E3E3E;         /* Subtle borders */
    --dm-category-header: #1B5E20; /* Dark forest green */
}

html {
    overflow-x: hidden;  /* Prevent horizontal scrolling at root level */
    max-width: 100%;     /* Constrain to viewport width */
}

body {
    font-family: 'Overpass', -apple-system, BlinkMacSystemFont, sans-serif;
    margin: 0;
    padding: 0;
    color: var(--text-color);
    line-height: 1.6;
    background-color: var(--background-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;  /* Prevent horizontal scrolling */
    max-width: 100%;     /* Constrain to viewport width */
}

/* Layout structure */
.page-container {
    margin-top: var(--header-height);
    flex: 1;
    padding: 10px;
    width: 100%;       /* Explicit width for mobile browsers */
    max-width: 900px;  /* Constrain width on desktop */
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;  /* Include padding in width calculation */
}

/* Header styles */
.total-display {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    min-height: var(--header-height);
    background: linear-gradient(135deg, #FFFDF7 0%, #FFF9E6 100%);  /* Warm creme gradient */
    padding: 10px 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 100;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
    font-family: 'Merriweather', serif;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.total-display div {
    font-size: 1em;
    margin: 3px 0;
}

.info {
    font-family: 'Overpass', sans-serif;
    font-size: 0.9em !important;
    color: #558B2F;
    line-height: 1.4;
}

.info a {
    color: #1B4D0E;  /* Dark jungle green for links */
    text-decoration: none;
    font-weight: 500;
}

.info a:visited {
    color: #1B4D0E;  /* Keep same green even after visited */
}

.info a:hover {
    text-decoration: underline;
}

/* Category styles */
.category {
    margin: 10px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    background: white;
}

.category-header {
    background: var(--primary-color);
    color: white;
    padding: 15px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: 'Merriweather', serif;
    font-weight: 700;
    font-size: 0.9em;
    position: relative;
}

.category-header .left {
    display: flex;
    align-items: center;
    flex: 1;
}

.category-header .icon {
    margin-right: 12px;
    font-size: 1.3em;
    transition: transform 0.3s ease;
}

.category-header .total {
    background: var(--accent-color);
    color: var(--dark-green);
    padding: 4px 12px;
    border-radius: 20px;
    font-family: 'Overpass', sans-serif;
    font-size: 0.9em;
    font-weight: 600;
    margin-right: 35px;
    min-width: 60px;
    text-align: center;
}

/* Collapse indicator */
.category-header::after {
    content: '▼';
    position: absolute;
    right: 20px;
    font-size: 0.8em;
    transition: transform 0.3s ease;
}

.category-header.collapsed::after {
    transform: rotate(-180deg);
}

.category-header.collapsed .icon {
    transform: scale(0.9);
}

.category-header.collapsed .total {
    background: var(--secondary-color);
}

/* Item styles */
.item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: white;
    border-bottom: 1px solid var(--border-color);
}

.item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.item-name {
    font-family: 'Merriweather', serif;
    font-weight: 400;
    font-size: 1.1em;
    margin-bottom: 4px;
}

.scrip-amount {
    color: var(--primary-color);
    font-size: 0.9em;
    font-weight: 500;
}

/* Quantity control styles */
.quantity-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.quantity-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: var(--secondary-color);
    color: white;
    border-radius: 50%;
    font-size: 1.8em;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    font-family: 'Overpass', sans-serif;
    font-weight: 600;
}

.quantity-btn:active {
    background: var(--secondary-color);
    transform: scale(0.95);
}

.quantity-input {
    width: 50px;
    height: 44px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-align: center;
    font-size: 1.2em;
    font-family: 'Overpass', sans-serif;
    font-weight: 500;
    -moz-appearance: textfield;
    appearance: textfield;
}

.quantity-input::-webkit-outer-spin-button,
.quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Desktop styles - wider screens need taller header due to increased line spacing */
@media (min-width: 601px) {
    :root {
        --header-height: 180px;  /* Taller header for desktop */
    }
}

/* Mobile styles */
@media (max-width: 600px) {
    :root {
        --header-height: 130px;  /* Compact header height for mobile */
    }

    .total-display {
        padding: 8px 12px;
    }

    .total-display div {
        font-size: 1em;
        margin: 2px 0;
    }

    .info-about {
        margin-bottom: 10px !important;  /* Extra spacing before timestamp on mobile */
    }

    .category {
        margin: 8px;
    }

    .item-row {
        padding: 12px;
    }

    .quantity-btn {
        width: 48px;
        height: 48px;
    }

    .quantity-input {
        width: 45px;
        height: 48px;
    }
}

/* Utility classes */
.text-right {
    text-align: right;
}

/* Items container */
.items {
    transition: all 0.1s ease-out;
    max-height: 2000px;
    opacity: 1;
}

.items.hidden {
    max-height: 0;
    opacity: 0;
    display: block !important; /* Override general hidden class */
}

/* Order Summary styles */
.order-summary {
    margin: 8px 10px;  /* Adjusted margin */
    border-radius: 12px;
    overflow: visible;  /* Changed from hidden to prevent clipping */
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    background: white;
}

.summary-header {
    background: var(--dark-green);
    color: white;
    padding: 12px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: 'Merriweather', serif;
    font-weight: 700;
    border-radius: 12px 12px 0 0;  /* Rounded top corners */
    min-width: 0;  /* Allow flex children to shrink below content size */
}

.summary-title {
    font-size: 1.1em;
    min-width: 0;  /* Allow text to shrink */
    overflow: hidden;
    text-overflow: ellipsis;
}

.copy-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.7);
    color: white;
    border-radius: 16px;
    padding: 4px 10px;
    font-size: 1em;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: 10px;
    line-height: 1;
}

.copy-btn:active {
    transform: scale(0.97);
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.summary-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;  /* Prevent compression */
    margin-left: auto;  /* Push to right */
}

.clear-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.7);
    color: white;
    border-radius: 16px;
    padding: 4px 12px;
    font-size: 0.85em;
    font-family: 'Overpass', sans-serif;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;  /* Prevent text wrapping */
    flex-shrink: 0;  /* Prevent button compression */
}

.clear-btn:active {
    transform: scale(0.97);
}

.toggle-icon {
    transition: transform 0.3s ease;
}

.toggle-icon.collapsed {
    transform: rotate(-180deg);
}

.summary-content {
    padding: 15px;
    transition: max-height 0.3s ease-out;
    max-height: 500px;
    overflow: hidden;
    border-radius: 0 0 12px 12px;  /* Rounded bottom corners */
}

.summary-content.hidden {
    display: none;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    font-family: 'Overpass', sans-serif;
}

.summary-item:last-child {
    border-bottom: none;
}

.summary-item-name {
    flex: 1;
}

.summary-item-quantity {
    font-weight: 500;
    margin-left: 15px;
}

.empty-message {
    color: #558B2F;
    text-align: center;
    font-style: italic;
    padding: 20px;
    font-family: 'Overpass', sans-serif;
}

.last-updated {
    position: absolute;
    bottom: 5px;
    left: 10px;
    font-size: 0.75em !important;
    color: #558B2F;
    font-family: 'Overpass', sans-serif;
    margin: 2px 0 !important;
    text-align: left;
}

/* Floating totals */
.floating-totals {
    display: none;
}

/* Adjust bottom margin to prevent overlap with floating totals */
#categories {
    margin-bottom: 80px;
}

/* Category description */
.category-description {
    padding: 12px 15px;
    font-size: 0.9em;
    color: #558B2F;
    background: #FFF8F0;
    border-bottom: 1px solid var(--border-color);
    font-family: 'Overpass', sans-serif;
    line-height: 1.4;
    display: none;
}

.category:has(.items:not(.hidden)) .category-description {
    display: block;
}

@media (max-width: 600px) {
    .category-description {
        padding: 10px 12px;
        font-size: 0.85em;
    }
}

.item-description {
    display: block;
    font-family: 'Overpass', sans-serif;
    font-size: 0.85em;
    color: #558B2F;
    font-weight: normal;
    margin-top: 4px;
    line-height: 1.4;
    font-style: italic;
}

/* ============================================
   DARK MODE STYLES
   ============================================ */

html[data-theme="dark"] {
    color-scheme: dark;
    --background-color: var(--dm-background);
    --text-color: var(--dm-text-primary);
    --primary-color: var(--dm-primary);
    --accent-color: var(--dm-accent);
    --border-color: var(--dm-border);
}

html[data-theme="dark"] .total-display {
    background: linear-gradient(135deg, #2A2A2A 0%, #1F1F1F 100%);
    border-bottom: 1px solid var(--dm-border);
}

html[data-theme="dark"] .category {
    background: var(--dm-surface);
}

html[data-theme="dark"] .category-header {
    background: var(--dm-category-header);
}

html[data-theme="dark"] .category-header .total {
    background: var(--dm-accent);
    color: #1A1A1A;
}

html[data-theme="dark"] .item-row {
    background: var(--dm-surface);
    border-bottom: 1px solid var(--dm-border);
}

html[data-theme="dark"] .order-summary {
    background: var(--dm-surface);
}

html[data-theme="dark"] .summary-header {
    background: var(--dm-category-header);
}

html[data-theme="dark"] .summary-item {
    border-bottom: 1px solid var(--dm-border);
}

html[data-theme="dark"] .info,
html[data-theme="dark"] .empty-message,
html[data-theme="dark"] .last-updated,
html[data-theme="dark"] .category-description,
html[data-theme="dark"] .item-description {
    color: var(--dm-text-secondary);
}

html[data-theme="dark"] .info a {
    color: var(--dm-primary);
}

html[data-theme="dark"] .info a:visited {
    color: var(--dm-primary);
}

html[data-theme="dark"] .scrip-amount {
    color: var(--dm-primary);
}

html[data-theme="dark"] .quantity-input {
    background: var(--dm-surface);
    color: var(--dm-text-primary);
    border: 1px solid var(--dm-border);
}

html[data-theme="dark"] .category-description {
    background: #252525;
    border-bottom: 1px solid var(--dm-border);
}

/* Theme toggle button */
.theme-toggle {
    position: absolute;
    top: 10px;
    right: 15px;
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    font-size: 1.5em;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 101;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.theme-toggle:hover {
    background: rgba(0, 0, 0, 0.1);
}

html[data-theme="dark"] .theme-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.theme-toggle:focus-visible {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
}

.theme-toggle:active {
    transform: scale(0.95);
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .theme-toggle,
    .category-header,
    .items,
    .toggle-icon {
        transition: none;
    }
}
