/* ============================================================
   1. MASTER THEME SYSTEM
   ============================================================ */
:root, [data-theme="light-classic"] {
    --bg-body: #ffffff;
    --bg-header: rgba(255, 255, 255, 0.9);
    --bg-card: #f8fafc;
    --text-main: #1a1a1a;
    --text-muted: #64748b;
    --accent: #e67e22;
    --accent-soft: rgba(230, 126, 34, 0.1);
    --accent-glow: rgba(230, 126, 34, 0.2);
    --border-subtle: rgba(0,0,0,0.1);
}

[data-theme="light-ocean"] { --bg-body: #f0f9ff; --bg-header: rgba(240, 249, 255, 0.9); --bg-card: #ffffff; --text-main: #0c4a6e; --text-muted: #334155; --accent: #0ea5e9; --accent-soft: rgba(14, 165, 233, 0.1); --border-subtle: rgba(14, 165, 233, 0.2); }
[data-theme="dark-midnight"] { --bg-body: #0f172a; --bg-header: rgba(15, 23, 42, 0.9); --bg-card: #1e293b; --text-main: #f8fafc; --text-muted: #94a3b8; --accent: #38bdf8; --accent-soft: rgba(56, 189, 248, 0.1); --border-subtle: rgba(255,255,255,0.1); }
[data-theme="dark-forest"] { --bg-body: #064e3b; --bg-header: rgba(6, 78, 59, 0.9); --bg-card: #065f46; --text-main: #ecfdf5; --text-muted: #a7f3d0; --accent: #10b981; --accent-soft: rgba(16, 185, 129, 0.1); --border-subtle: rgba(16, 185, 129, 0.2); }
[data-theme="liquid-glass"] { --bg-body: radial-gradient(circle at top left, #1a2a3a, #070b10); --bg-header: rgba(255, 255, 255, 0.05); --bg-card: rgba(255, 255, 255, 0.05); --text-main: #ffffff; --text-muted: #d1d5db; --accent: #38BDF8; --accent-soft: rgba(56, 189, 248, 0.2); --border-subtle: rgba(255, 255, 255, 0.2); }

:root {
    --radius-lg: 24px;
    --container-width: 1100px;
    --transition: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ============================================================
   2. RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--bg-body);
    background-attachment: fixed;
    color: var(--text-main);
    margin: 0; padding: 0;
    transition: background 0.3s ease, color 0.3s ease;
}
.container { max-width: var(--container-width); margin: 0 auto; padding: 0 1.25rem; }
.site-main { padding-top: 100px; padding-bottom: 60px; }
h1, h2, h3, h4 { color: var(--text-main); margin: 0 0 1rem 0; }
p { line-height: 1.6; color: var(--text-main); }

/* ============================================================
   3. HEADER / TOP BAR (ENHANCED INTERACTION)
============================================================ */
.site-header {
    position: fixed; inset-inline: 0; top: 0; z-index: 1000;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-subtle);
    backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
}
.header-inner { display: flex; justify-content: space-between; align-items: center; padding: 0.8rem 0; }

/* Right Side Button Group */
.header-right { display: flex; align-items: center; gap: 12px; }

/* --- ICON BUTTON EFFECTS (Cart, Theme, Profile) --- */
.header-cart-btn, .theme-btn, .profile-btn {
    position: relative;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%; /* Perfect circles */
    background: rgba(255, 255, 255, 0.05); /* Glassy base */
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* Bouncy transition */
    cursor: pointer;
}

/* Hover State: The "Pop" and "Glow" */
.header-cart-btn:hover, .theme-btn:hover, .profile-btn:hover {
    transform: scale(1.15) translateY(-2px);
    background: var(--accent-soft);
    border-color: var(--accent);
    box-shadow: 0 8px 20px var(--accent-glow);
    color: var(--accent);
}

/* Active State: Click feedback */
.header-cart-btn:active, .theme-btn:active, .profile-btn:active {
    transform: scale(0.95);
}

/* Avatar/Initials inside Profile Button */
.avatar, .initials {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.3s;
}
.initials { background: var(--accent); color: white; font-weight: bold; font-size: 0.9rem; }
.profile-btn:hover .initials { background: var(--accent); }

/* Cart Badge Positioning */
.cart-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ff4444; /* Bright red for visibility */
    color: white;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 20px;
    border: 2px solid var(--bg-header);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

/* --- HAMBURGER MENU (FIXED ANIMATION) --- */
.hamburger { 
    width: 45px; height: 45px; 
    display: flex; flex-direction: column; justify-content: center; align-items: center; 
    gap: 5px; cursor: pointer; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border-subtle); border-radius: 50%;
    transition: all 0.3s;
}
.hamburger:hover { background: var(--accent-soft); border-color: var(--accent); }

.hamburger span { 
    display: block; width: 20px; height: 2px; 
    background: var(--text-main); border-radius: 2px; 
    transition: all 0.4s cubic-bezier(0.68, -0.6, 0.32, 1.6); 
}

/* The 'X' Transformation */
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); width: 22px; }
.hamburger.open span:nth-child(2) { opacity: 0; transform: translateX(-20px); }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); width: 22px; }
/* ============================================================
   4. PRODUCT DISPLAY
   ============================================================ */
.cards-grid { display: grid; gap: 2rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.product-card { 
    background: var(--bg-card); border-radius: var(--radius-lg); 
    padding: 1.5rem; border: 1px solid var(--border-subtle); 
    display: flex; flex-direction: column; transition: 0.3s;
}

.product-image-wrapper {
    width: 100%;
    height: 350px; 
    border-radius: 18px;
    overflow: hidden;
    margin-bottom: 1.5rem;
    background: rgba(0,0,0,0.05);
    border: 1px solid var(--border-subtle);
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover !important; 
    display: block;
    transition: transform 0.6s var(--transition);
}

.product-card:hover { transform: translateY(-5px); border-color: var(--accent); box-shadow: var(--shadow-strong); }
.product-card:hover .product-image { transform: scale(1.1); }

/* ============================================================
   5. BUTTONS, FORMS & TABLES (HOVERS RESTORED)
   ============================================================ */
.btn { 
    border-radius: 50px; padding: 0.8rem 2rem; font-weight: 700; 
    cursor: pointer; border: none; text-decoration: none; display: inline-flex; 
    align-items: center; justify-content: center; transition: all 0.3s ease;
}
.btn:active { transform: translateY(0); box-shadow: none; }

.btn-primary { background: var(--accent); color: #fff !important; box-shadow: 0 8px 20px var(--accent-glow); }
.btn-primary:hover { transform: translateY(-3px); filter: brightness(1.1); box-shadow: 0 12px 25px var(--accent-glow); }

.btn-outline { background: transparent; color: var(--text-main); border: 2px solid var(--border-subtle); }
.btn-outline:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); transform: translateY(-3px); }

/* Table styling */
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--bg-card); border-radius: 16px; border: 1px solid var(--border-subtle); overflow: hidden; }
th { background: var(--accent-soft); padding: 1.2rem; text-align: left; }
td { padding: 1.2rem; border-bottom: 1px solid var(--border-subtle); color: var(--text-main); }
/* ============================================================
   EMERGENCY PATCH: FORMS, INPUTS & Z-INDEX
============================================================ */

/* 1. Fix the Z-Index Hierarchy (Makes Hamburger Clickable) */
.site-header { 
    z-index: 9999 !important; /* Keeps header strictly on top */
}
.mobile-menu { 
    z-index: 9998 !important; 
    padding-top: 100px !important; 
}
.mobile-menu-overlay { 
    z-index: 9997 !important; 
}

/* 2. Restore Form Layout & Spacing */
form {
    margin-bottom: 1rem;
}

label { 
    display: block !important; 
    font-weight: 600; 
    margin-top: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--text-main); 
    font-size: 0.95rem;
}

/* Prevent cart quantity inputs from expanding to 100% */
td input[type="number"] {
    width: 80px !important;
    display: inline-block !important;
}

/* 3. Fix Input Backgrounds (The white box bug) */
input[type="text"], 
input[type="email"], 
input[type="password"], 
input[type="number"], 
textarea, 
select { 
    width: 100%;
    display: block;
    border-radius: 12px; 
    border: 1px solid var(--border-subtle); 
    background: rgba(128, 128, 128, 0.1) !important; /* Safe transparency for all themes */
    color: var(--text-main) !important; 
    padding: 0.9rem 1rem; 
    outline: none; 
    font-family: inherit;
    transition: all 0.3s ease;
}

input:focus, textarea:focus, select:focus { 
    border-color: var(--accent) !important; 
    box-shadow: 0 0 0 3px var(--accent-glow) !important; 
    background: rgba(128, 128, 128, 0.15) !important;
}
/* ============================================================
   RESTORED FOOTER & SOCIAL MEDIA BUTTONS
============================================================ */
.site-footer { 
    border-top: 1px solid var(--border-subtle); 
    background: linear-gradient(180deg, transparent, rgba(0,0,0,0.02)); 
    padding-top: 3rem; 
    margin-top: 4rem; 
}

.footer-inner { 
    display: grid; 
    gap: 2rem; 
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 
    padding-bottom: 2rem; 
}

.footer-bottom { 
    text-align: center; 
    font-size: 0.85rem; 
    padding: 1.5rem 0; 
    opacity: 0.7; 
    border-top: 1px solid var(--border-subtle);
}

/* --- The Social Buttons --- */
.social-links { 
    display: flex; 
    gap: 0.8rem; 
    margin-top: 0.8rem; 
    flex-wrap: wrap;
}

.social-btn { 
    padding: 0.5rem 1.2rem; 
    border-radius: 12px; 
    text-decoration: none !important; 
    font-size: 0.9rem; 
    font-weight: 600; 
    transition: transform 0.3s ease, box-shadow 0.3s ease, filter 0.3s ease; 
    display: inline-flex; 
    align-items: center;
    justify-content: center;
    color: #ffffff !important; /* Forces the text to stay white */
    border: none;
}

/* Brand Colors */
.social-btn.instagram { background: linear-gradient(45deg, #fd1d1d, #e1306c, #c13584); }
.social-btn.facebook { background: #1877f2; }
.social-btn.tiktok { background: #111111; }

/* The Hover "Pop" Effect */
.social-btn:hover { 
    transform: translateY(-4px); 
    box-shadow: 0 6px 15px rgba(0,0,0,0.2); 
    filter: brightness(1.1);
}
/* =========================================================
   6. ULTIMATE DROPDOWN VISIBILITY FIX
   ========================================================= */

/* Tell the browser engine to use Dark Mode for native UI (scrollbars, dropdowns) */
[data-theme*="dark"], [data-theme="liquid-glass"] {
    color-scheme: dark;
}
[data-theme*="light"] {
    color-scheme: light;
}

/* Force Native <option> menus (like Order Status & Categories) to have a solid background */
select option {
    background-color: #1e293b !important; /* Deep dark blue/grey */
    color: #ffffff !important;            /* Pure white text */
    font-weight: 600;
}

/* Keep them light when a Light Theme is active */
[data-theme*="light"] select option {
    background-color: #ffffff !important;
    color: #1a1a1a !important;
}

/* Force your Custom Theme Picker to stay dark and solid */
.theme-dropdown {
    background-color: #0f172a !important; /* Solid dark base */
    border: 1px solid rgba(255,255,255,0.1) !important;
}

/* Keep Theme Picker light in Light Themes */
[data-theme*="light"] .theme-dropdown {
    background-color: #ffffff !important;
    border: 1px solid rgba(0,0,0,0.1) !important;
}

/* Ensure theme options text is visible */
.theme-option { color: #ffffff !important; }
[data-theme*="light"] .theme-option { color: #1a1a1a !important; }
/* =========================================================
   MOBILE RESPONSIVENESS SAFETY NET
   (Guarantees layout integrity on small screens)
   ========================================================= */

@media (max-width: 768px) {
    /* 1. Prevent the "Horizontal Scroll of Death" */
    body, html {
        overflow-x: hidden;
        width: 100%;
    }

    /* 2. Scale down massive desktop fonts */
    h1 { font-size: 2.2rem !important; line-height: 1.2; }
    h2 { font-size: 1.8rem !important; }
    
    /* 3. Give text breathing room on small screens */
    .container {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }

    /* 4. Touch-Friendly Buttons (Apple UI Standard) */
    .btn {
        min-height: 48px; /* Minimum size for thumbs */
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
    }

    /* 5. Force side-by-side elements to stack neatly */
    .flex-mobile-stack {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 15px;
    }

    /* 6. Form Inputs & Selects - Prevent iOS zoom bug */
    input, textarea, select {
        font-size: 16px !important; /* iOS zooms in if text is smaller than 16px */
        width: 100%;
    }
}

/* 7. Responsive Tables (Crucial for your Cart & Admin pages) */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Smooth swiping on iPhones */
    border-radius: 12px;
}
/* ==========================================================================
   RECEIPT PAGE LAYOUT (DESKTOP)
   ========================================================================== */
.receipt-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 2rem;
    margin-bottom: 2rem;
}

.receipt-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.receipt-status {
    text-align: right;
}

.receipt-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 3rem;
}

.receipt-actions {
    margin-top: 3rem;
    text-align: center;
    display: flex;
    gap: 15px;
    justify-content: center;
}

.receipt-actions .btn, 
.receipt-actions button {
    min-width: 150px;
}

/* ==========================================================================
   RECEIPT PAGE RESPONSIVENESS (MOBILE)
   ========================================================================== */
@media (max-width: 768px) {
    /* Stack the top logo and order number */
    .receipt-header-flex {
        flex-direction: column;
        text-align: center;
        gap: 1.5rem;
    }

    /* Re-center the logo box */
    .receipt-brand {
        flex-direction: column;
        justify-content: center;
        text-align: center;
    }

    .receipt-brand > div {
        text-align: center !important;
    }

    /* Re-center the order status */
    .receipt-status {
        text-align: center;
    }

    /* Stack the details columns so the address isn't squished */
    .receipt-details-grid {
        grid-template-columns: 1fr; /* Turns the 2 columns into 1 */
        gap: 1.5rem;
    }

    /* Ensure long address text wraps safely */
    .receipt-details-grid p {
        word-break: break-word;
    }

    /* Stack buttons for easier tapping and put 'Home' on top */
    .receipt-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .receipt-actions .btn, 
    .receipt-actions button {
        width: 100%;
        margin: 0;
    }
}
/* ---------------------------------------------------
   MOBILE TABLE TO CARD CONVERSION 
--------------------------------------------------- */
@media (max-width: 768px) {
    /* 1. Remove the forced table structure */
    .admin-table, 
    .admin-table tbody, 
    .admin-table tr, 
    .admin-table td {
        display: block;
        width: 100%;
    }

    /* 2. Hide the top header row completely */
    .admin-table thead {
        display: none; 
    }

    /* 3. Turn each row into a distinct "Card" */
    .admin-table tr {
        background-color: rgba(255, 255, 255, 0.05); /* Slight highlight for dark mode */
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 12px;
        margin-bottom: 1.5rem;
        padding: 1rem;
    }

    /* 4. Align the data inside the card */
    .admin-table td {
        display: flex;
        justify-content: space-between; /* Pushes label left, data right */
        align-items: center;
        padding: 12px 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        text-align: right;
    }

    /* Remove border from the last item (buttons) */
    .admin-table td:last-child {
        border-bottom: none;
        flex-direction: column; /* Stack the buttons */
        gap: 10px;
        padding-top: 15px;
    }

    /* 5. Create the Left-Side Labels using the data-label attribute */
    .admin-table td::before {
        content: attr(data-label);
        font-weight: normal;
        color: #888; /* Gray color so the actual data stands out */
        text-align: left;
        margin-right: auto;
    }

    /* 6. Tweak the image so it doesn't blow up */
    .admin-table td img.product-thumb {
        max-width: 80px; /* Keeps the cake image thumbnail-sized */
        height: auto;
        border-radius: 8px;
    }

    /* 7. Make the action buttons easy to tap */
    .admin-table td.actions a.btn {
        width: 100%;
        text-align: center;
        box-sizing: border-box;
    }
}