/* ==========================================================================
   DESKTOP STYLES (Screen > 768px)
   ========================================================================== */
:root {
    --primary-dark: #1e293b;
    --accent-green: #10b981;
    --bg-light: #f8fafc;
    --border-color: #e2e8f0;
}

body {
    background: var(--bg-light);
    font-family: 'Inter', sans-serif;
    overflow-x: hidden;
    margin: 0;
}

/* Sticky Header */
.sticky-summary {
    position: sticky;
    top: 0;
    z-index: 1050;
    background: var(--primary-dark);
    color: white;
    padding: 15px 0;
    border-bottom: 3px solid var(--accent-green);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stat-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--accent-green);
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #94a3b8;
}

/* Layout Wrapper */
.layout-wrapper {
    display: flex;
    width: 100%;
}

/* Sidebar History */
.sidebar {
    width: 320px;
    background: white;
    border-right: 1px solid var(--border-color);
    padding: 25px;
    height: calc(100vh - 85px);
    position: sticky;
    top: 85px;
    overflow-y: auto;
}

.sidebar-title {
    font-weight: 700;
    color: var(--primary-dark);
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.history-card {
    background: #f8fafc;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
    position: relative;
    cursor: pointer;
    transition: 0.2s;
}

.history-card:hover {
    border-color: var(--accent-green);
    background: #f0fdf4;
}

.del-meal {
    position: absolute;
    top: 8px;
    right: 12px;
    color: #ef4444;
    cursor: pointer;
    font-size: 18px;
    z-index: 10;
}

/* Main Content Builder */
.main-content {
    flex: 1;
    padding: 40px;
    max-width: 1200px;
}

.meal-card {
    background: white;
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 25px;
    border: 1px solid var(--border-color);
    position: relative;
}

.nutrition-row {
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    background: #f1f5f9;
    padding: 18px;
    border-radius: 15px;
}

.nutri-box {
    flex: 1;
    min-width: 90px;
    text-align: center;
}

.nutri-box small {
    color: #64748b;
    font-size: 0.75rem;
    display: block;
}

.row-total-display {
    font-size: 1.6rem;
    font-weight: 800;
    color: #3b82f6;
}

.remove-icon {
    position: absolute;
    right: -10px;
    top: -10px;
    background: #ef4444;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 3px solid var(--bg-light);
}

@media print { .no-print { display: none !important; } }

/* ==========================================================================
   ULTRA-MODERN MOBILE STYLES (Screen < 768px)
   ========================================================================== */
@media (max-width: 768px) {
    :root {
        --mobile-bg: #f8fafc;
        --card-radius: 20px;
        --accent-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
    }

    body {
        background-color: var(--mobile-bg);
        padding-bottom: 20px; /* Space for bottom scroll */
    }

    /* 1. Compact Sticky Header */
    .sticky-summary {
        padding: 12px 5px;
        border-radius: 0 0 20px 20px;
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    }

    .stat-value {
        font-size: 1.1rem;
        margin-bottom: 2px;
    }

    .stat-label {
        font-size: 0.55rem;
        font-weight: 700;
        letter-spacing: 0.5px;
    }

    /* 2. Layout Structure */
    .layout-wrapper {
        flex-direction: column; /* Stack order */
    }

    /* 3. History Section (Accordion Style) */
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        top: 0;
        padding: 15px;
        background: transparent;
        border: none;
    }

    .sidebar-title {
        font-size: 1rem;
        margin-bottom: 15px;
        text-align: center;
        color: var(--text-muted);
    }

    #history-list {
        display: flex;
        overflow-x: auto; /* Horizontal scrolling for history cards */
        gap: 12px;
        padding-bottom: 10px;
        scrollbar-width: none; /* Hide scrollbar */
    }

    #history-list::-webkit-scrollbar { display: none; }

    .history-card {
        min-width: 160px; /* Small square-ish cards */
        padding: 12px;
        border-radius: 16px;
        margin-bottom: 0;
        background: white;
        flex-shrink: 0;
    }

    /* 4. Main Content Area */
    .main-content {
        padding: 15px 12px;
    }

    /* 5. Modern Action Buttons */
    .btn-custom-mobile {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }

    .btn-modern {
        width: 100% !important;
        padding: 14px;
        font-size: 0.95rem;
        border-radius: 16px;
    }

    /* 6. Professional Meal Card */
    .meal-card {
        padding: 20px 15px;
        border-radius: var(--card-radius);
        margin-bottom: 20px;
        border: none;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    }

    .form-control-modern {
        font-size: 14px;
        padding: 12px;
    }

    /* 7. Bottom Nutrient Grid */
    .nutrition-row {
        display: grid;
        grid-template-columns: repeat(2, 1fr); /* 2 per row */
        gap: 8px;
        padding: 12px;
        margin-top: 15px;
        border-radius: 14px;
    }

    .nutri-box {
        background: white;
        padding: 8px;
        border-radius: 10px;
        border: 1px solid #f1f5f9;
    }

    .nutri-box small {
        font-size: 0.6rem;
    }

    .nutri-box span {
        font-size: 0.9rem;
    }

    /* 8. Subtotal Display */
    .row-total-display {
        font-size: 1.4rem;
        display: block;
        width: 100%;
        text-align: right;
        margin-top: 10px;
        color: #3b82f6;
    }

    /* Delete Icon on Mobile */
    .remove-icon {
        width: 28px;
        height: 28px;
        right: 10px;
        top: 10px;
        font-size: 12px;
    }
}