/* =====================================================
   Food Finder — Production CSS
   =====================================================
   Structure:
   1. Font Face
   2. CSS Variables (Dark/Light Theme)
   3. Reset & Base
   4. Layout
   5. Header & Navigation
   6. Form & Inputs
   7. Filter Section
   8. Food Cards & Results
   9. Skeleton Loading
   10. Compare Bar
   11. Compare Modal
   12. Meal Planner
   13. Utility & Animations
   14. Responsive
   ===================================================== */

/* ===== 1. FONT FACE ===== */
@font-face {
    font-family: 'Vazirmatn';
    src: url('fonts/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('fonts/Vazirmatn-Medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('fonts/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* ===== 2. CSS VARIABLES ===== */
:root {
    --bg-gradient: linear-gradient(160deg, #0d1117 0%, #0f1724 55%, #111827 100%);
    --surface: rgba(255, 255, 255, 0.04);
    --surface-hover: rgba(255, 255, 255, 0.07);
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: #6366f1;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: rgba(255, 255, 255, 0.3);

    --input-bg: rgba(255, 255, 255, 0.06);
    --input-bg-focus: rgba(255, 255, 255, 0.09);

    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-violet: #a78bfa;

    --card-shadow: 0 8px 32px rgba(99, 102, 241, 0.18);
    --modal-bg: #0f172a;

    --table-text: #f1f5f9;
    --table-muted: #64748b;

    --compare-bar-bg: rgba(15, 23, 42, 0.97);
    --chart-bg: rgba(255, 255, 255, 0.03);

    --badge-bg: rgba(99, 102, 241, 0.15);
    --badge-text: #818cf8;
    --toggle-bg: rgba(255, 255, 255, 0.06);

    --bar-protein: #10b981;
    --bar-carbs: #3b82f6;
    --bar-calories: #8b5cf6;

    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
}

[data-theme="light"] {
    --bg-gradient: linear-gradient(160deg, #f8fafc 0%, #f1f5f9 55%, #e2e8f0 100%);
    --surface: rgba(255, 255, 255, 0.85);
    --surface-hover: #ffffff;
    --border: rgba(15, 23, 42, 0.08);
    --border-hover: #6366f1;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: rgba(0, 0, 0, 0.3);

    --input-bg: rgba(255, 255, 255, 0.9);
    --input-bg-focus: #ffffff;

    --accent: #6366f1;
    --accent-light: #6366f1;
    --accent-violet: #7c3aed;

    --card-shadow: 0 8px 32px rgba(99, 102, 241, 0.12);
    --modal-bg: #ffffff;

    --table-text: #0f172a;
    --table-muted: #64748b;

    --compare-bar-bg: rgba(255, 255, 255, 0.97);
    --chart-bg: rgba(248, 250, 252, 0.9);

    --badge-bg: rgba(99, 102, 241, 0.1);
    --badge-text: #6366f1;
    --toggle-bg: rgba(0, 0, 0, 0.05);
}

/* ===== 3. RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    /* جلوگیری از horizontal scroll کل صفحه */
    overflow-x: hidden;
}

body {
    font-family: 'Vazirmatn', sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 32px 20px 20px;
    color: var(--text-primary);
    transition: background 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    /* جلوگیری از overflow افقی */
    overflow-x: hidden;
    /* حداقل عرض — زیر این سایت collapse نشه */
    min-width: 320px;
}

/* ===== 4. LAYOUT ===== */
.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Tab transition — opacity + translate به جای display:none */
.tab-content {
    animation: tabEnter 0.22s ease both;
}

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

/* وقتی تب داره ظاهر میشه */
@keyframes tabEnter {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== 5. HEADER & NAVIGATION ===== */
.header-row {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-bottom: 10px;
    padding: 0 120px;
}

h1 {
    text-align: center;
    font-size: 2.4rem;
    font-weight: 700;
    background: linear-gradient(135deg, #818cf8 0%, #a78bfa 50%, #c084fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

/* Theme Toggle */
.theme-toggle {
    position: absolute;
    left: 0;
    flex-shrink: 0;
    background: var(--toggle-bg);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    backdrop-filter: blur(10px);
}

.theme-toggle:hover {
    border-color: var(--accent);
    background: var(--surface-hover);
}

.theme-toggle .toggle-label {
    font-size: 0.8rem;
    font-weight: 500;
}

/* Tab Bar */
.tab-bar {
    display: flex;
    gap: 6px;
    background: var(--surface);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 6px;
    margin-bottom: 24px;
    width: 100%;
    max-width: 600px;
    margin-inline: auto;
    box-sizing: border-box;
}

.tab-btn {
    flex: 1;
    padding: 10px 8px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: 'Vazirmatn', sans-serif;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: 11px;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--surface-hover);
}

.tab-btn.active {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.35);
}

/* ===== 6. FORM & INPUTS ===== */
.subtitle {
    text-align: center;
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 30px;
    font-weight: 400;
}

.form-box {
    background: var(--surface);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 25px;
    border: 1px solid var(--border);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.input-row {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
}

.input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* Use number input for better semantics + mobile keyboard */
input[type="number"] {
    width: 100%;
    padding: 14px 18px;
    font-size: 1rem;
    font-family: 'Vazirmatn', sans-serif;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--input-bg);
    color: var(--text-primary);
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--input-bg-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

input[type="number"]::placeholder {
    color: var(--text-muted);
}

/* Inline validation message — replaces alert() */
.validation-msg {
    font-size: 0.85rem;
    color: var(--danger);
    min-height: 20px;
    margin-bottom: 12px;
    transition: opacity 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.validation-msg:empty {
    display: none;
}

.search-btn {
    width: 100%;
    padding: 15px;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Vazirmatn', sans-serif;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: opacity 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.search-btn:hover {
    opacity: 0.9;
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}

.search-btn:active {
    opacity: 1;
    box-shadow: none;
    transform: scale(0.99);
}

/* Live dot indicator */
.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.7);
    display: inline-block;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* ===== 7. FILTER SECTION ===== */
.filter-section {
    background: var(--surface);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 30px;
    border: 1px solid var(--border);
    transition: background 0.3s ease;
}

.filter-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-btn {
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: 'Vazirmatn', sans-serif;
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 25px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    white-space: nowrap;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    touch-action: manipulation;
}

.filter-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    border-color: rgba(99, 102, 241, 0.3);
}

.filter-btn.active {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #ffffff;
    border-color: transparent;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

@media (max-width: 768px) {
    .filter-section { padding: 16px; }
    .filter-btn { padding: 7px 13px; font-size: 0.8rem; }
}

@media (max-width: 420px) {
    .filter-section { padding: 14px 12px; }
    .filter-btn { padding: 6px 11px; font-size: 0.76rem; }
}

/* ===== 8. FOOD CARDS & RESULTS ===== */
#results {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
    margin-top: 30px;
    margin-bottom: 100px;
}

.food-card {
    background: var(--surface);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    cursor: pointer;
    opacity: 0;
    transform: translateY(12px);
    animation: cardEnter 0.3s ease both;
    animation-delay: calc(var(--card-index, 0) * 0.04s);
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

@keyframes cardEnter {
    to { opacity: 1; transform: translateY(0); }
}

.food-card:hover {
    background: var(--surface-hover);
    border-color: rgba(99, 102, 241, 0.35);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.1);
}

.food-card.selected {
    border: 2px solid var(--accent);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

/* Card Top Row: badge + fitness label */
.card-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 0;
    flex-wrap: wrap;
}

.match-badge {
    display: inline-block;
    background: var(--badge-bg);
    color: var(--badge-text);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    margin-bottom: 10px;
    border: 1px solid rgba(99, 102, 241, 0.25);
    letter-spacing: 0.03em;
}

.card-top-row .fitness-label {
    margin: 0 0 10px 0;
    font-size: 0.72rem;
    padding: 3px 9px;
}

.food-card h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.food-card .macro {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.food-card .macro span:first-child { color: var(--text-secondary); }
.food-card .macro span:last-child { color: var(--text-primary); font-weight: 500; }

.food-card .category {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
}

/* Card Actions */
.card-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 14px;
}

/* Fitness Labels */
.fitness-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
    width: fit-content;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.fit-muscle  { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); }
.fit-cut     { background: rgba(239, 68, 68, 0.12);  color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.28); }
.fit-bulk    { background: rgba(245, 158, 11, 0.12); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.28); }
.fit-balance { background: rgba(59, 130, 246, 0.12); color: #3b82f6; border: 1px solid rgba(59, 130, 246, 0.28); }

[data-theme="light"] .fit-muscle  { background: rgba(16, 185, 129, 0.12); color: #059669; }
[data-theme="light"] .fit-cut     { background: rgba(239, 68, 68, 0.1);   color: #dc2626; }
[data-theme="light"] .fit-bulk    { background: rgba(245, 158, 11, 0.1);  color: #d97706; }
[data-theme="light"] .fit-balance { background: rgba(59, 130, 246, 0.1);  color: #2563eb; }

/* ── Favorite Button ── */
.fav-btn {
    position: absolute;
    top: 12px;
    left: 12px;           /* سمت چپ کارت — در RTL = گوشه بیرونی */
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background 0.2s ease;
    touch-action: manipulation;
    line-height: 1;
    padding: 0;
    z-index: 1;
}

.fav-btn:hover { transform: scale(1.15); }

.fav-btn.fav-active {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.3);
}

/* کارت favorite — border رنگی */
.food-card.fav-card {
    border-color: rgba(239, 68, 68, 0.35);
}

.food-card.fav-card:hover {
    border-color: rgba(239, 68, 68, 0.6);
}

/* badge pinned */
.fav-pinned-badge {
    background: rgba(239, 68, 68, 0.12) !important;
    color: #f87171 !important;
    border-color: rgba(239, 68, 68, 0.25) !important;
}

/* کارت position relative برای absolute fav-btn */
.food-card { position: relative; }
.add-compare-btn {
    display: block;
    padding: 9px 22px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-light);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Vazirmatn', sans-serif;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.add-compare-btn:hover {
    background: rgba(99, 102, 241, 0.18);
    border-color: rgba(99, 102, 241, 0.4);
}

.add-compare-btn.added {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.25);
}

.add-meal-btn {
    padding: 7px 15px;
    background: transparent;
    color: var(--accent-light);
    border: 1.5px solid rgba(129, 140, 248, 0.5);
    border-radius: 25px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    font-family: 'Vazirmatn', sans-serif;
    transition: all 0.2s ease;
}

.add-meal-btn:hover {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #ffffff;
    border-color: transparent;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.add-meal-btn:active {
    transform: scale(0.96);
    box-shadow: none;
}

/* ===== 9. SKELETON LOADING ===== */
@keyframes shimmer {
    0%   { background-position: -600px 0; }
    100% { background-position:  600px 0; }
}

.skeleton-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.sk {
    border-radius: 8px;
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 0px, rgba(255,255,255,0.10) 100px, rgba(255,255,255,0.04) 200px);
    background-size: 600px 100%;
    animation: shimmer 1.8s ease-in-out infinite;
}

[data-theme="light"] .sk {
    background: linear-gradient(90deg, rgba(0,0,0,0.04) 0px, rgba(0,0,0,0.09) 100px, rgba(0,0,0,0.04) 200px);
    background-size: 600px 100%;
}

.sk-badge    { height: 22px; width: 65%; margin-bottom: 12px; border-radius: 20px; }
.sk-title    { height: 18px; width: 55%; margin-bottom: 16px; }

.sk-circle {
    width: 80px; height: 80px;
    border-radius: 50%;
    margin: 0 auto 14px;
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 0px, rgba(255,255,255,0.10) 100px, rgba(255,255,255,0.04) 200px);
    background-size: 600px 100%;
    animation: shimmer 1.8s ease-in-out infinite;
}

[data-theme="light"] .sk-circle {
    background: linear-gradient(90deg, rgba(0,0,0,0.04) 0px, rgba(0,0,0,0.09) 100px, rgba(0,0,0,0.04) 200px);
    background-size: 600px 100%;
}

.sk-macro-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.sk-label     { height: 13px; width: 40%; }
.sk-value     { height: 13px; width: 30%; }

.sk-category {
    height: 14px; width: 50%;
    margin: 14px auto 14px;
    border-radius: 8px;
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 0px, rgba(255,255,255,0.10) 100px, rgba(255,255,255,0.04) 200px);
    background-size: 600px 100%;
    animation: shimmer 1.8s ease-in-out infinite;
}

[data-theme="light"] .sk-category {
    background: linear-gradient(90deg, rgba(0,0,0,0.04) 0px, rgba(0,0,0,0.09) 100px, rgba(0,0,0,0.04) 200px);
    background-size: 600px 100%;
}

.sk-button {
    height: 38px; width: 60%;
    border-radius: 25px;
    margin: 4px auto 0;
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 0px, rgba(255,255,255,0.10) 100px, rgba(255,255,255,0.04) 200px);
    background-size: 600px 100%;
    animation: shimmer 1.8s ease-in-out infinite;
}

[data-theme="light"] .sk-button {
    background: linear-gradient(90deg, rgba(0,0,0,0.04) 0px, rgba(0,0,0,0.09) 100px, rgba(0,0,0,0.04) 200px);
    background-size: 600px 100%;
}

/* ===== 10. COMPARE BAR ===== */
.compare-bar {
    position: fixed;
    bottom: -80px;
    left: 0;
    right: 0;
    background: var(--compare-bar-bg);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding: 16px 40px;
    transition: bottom 0.25s ease, background 0.3s ease;
    z-index: 1000;
}

.compare-bar.show { bottom: 0; }

.compare-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.compare-content span {
    color: var(--text-secondary);
    font-size: 14px;
}

.compare-btn,
.clear-compare-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Vazirmatn', sans-serif;
    cursor: pointer;
    transition: opacity 0.2s ease, box-shadow 0.2s ease;
}

.compare-btn {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #ffffff;
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.35);
}

.compare-btn:hover:not(:disabled) {
    opacity: 0.88;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.45);
}

.compare-btn:disabled {
    background: rgba(99, 102, 241, 0.3);
    color: rgba(255, 255, 255, 0.4);
    opacity: 1;
    cursor: not-allowed;
    box-shadow: none;
}

.clear-compare-btn {
    background: rgba(220, 38, 38, 0.15);
    color: #f87171;
    border: 1px solid rgba(220, 38, 38, 0.3);
}

[data-theme="light"] .clear-compare-btn {
    background: rgba(220, 38, 38, 0.1);
    color: #b91c1c;
    border: 1px solid rgba(220, 38, 38, 0.4);
}

.clear-compare-btn:hover {
    background: rgba(220, 38, 38, 0.2);
    border-color: rgba(220, 38, 38, 0.4);
}

/* ===== 11. COMPARE MODAL ===== */
.compare-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.88);
    backdrop-filter: blur(20px);
    z-index: 2000;
    padding: 20px;
    overflow-y: auto;
    align-items: center;
    justify-content: center;
}

.compare-modal.show { display: flex; }

.compare-modal-content {
    background: var(--modal-bg);
    border-radius: 24px;
    width: 95%;
    max-width: 880px;
    margin: auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.08), 0 24px 60px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.compare-modal-content.modal-entered { opacity: 1; transform: translateY(0); }
.compare-modal-content.modal-leaving { opacity: 0; transform: translateY(10px); transition: opacity 0.18s ease, transform 0.18s ease; }

.compare-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.compare-modal-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin: 0;
}

.close-modal {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
}

.close-modal:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.25);
    color: #f87171;
}

#compareChart {
    overflow-y: auto;
    padding: 24px;
    flex: 1;
}

.modal-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.modal-food-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    opacity: 0;
    animation: cardEnter 0.25s ease forwards;
    transition: border-color 0.2s ease;
}

.modal-food-card:hover { border-color: rgba(99, 102, 241, 0.3); }

.modal-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.modal-card-emoji { font-size: 1.6rem; line-height: 1; flex-shrink: 0; }
.modal-card-name  { font-size: 0.9rem; font-weight: 700; color: var(--text-primary); margin-bottom: 2px; }
.modal-card-cat   { font-size: 0.72rem; color: var(--text-secondary); }

.modal-stats { display: flex; flex-direction: column; gap: 13px; }

.modal-stat-row { display: flex; flex-direction: column; gap: 6px; }

.modal-stat-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-stat-left {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.modal-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.dot-protein  { background: #10b981; }
.dot-carbs    { background: #3b82f6; }
.dot-calories { background: #8b5cf6; }

.modal-stat-val { font-size: 0.8rem; font-weight: 700; color: var(--text-primary); white-space: nowrap; }
.stat-best { color: #10b981; }
.stat-best::after { content: ' ↑'; font-size: 0.65rem; }

.modal-bar-track {
    width: 100%;
    height: 5px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
}

.modal-bar {
    height: 100%;
    border-radius: 99px;
    transition: width 0.45s ease;
}

.bar-protein  { background: #10b981; }
.bar-carbs    { background: #3b82f6; }
.bar-calories { background: #8b5cf6; }

.modal-legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    padding: 12px 16px;
    background: var(--surface);
    border-radius: 10px;
    border: 1px solid var(--border);
    font-size: 0.77rem;
    color: var(--text-secondary);
}

.modal-legend span { display: flex; align-items: center; gap: 6px; }
.legend-note { margin-right: auto; color: var(--text-muted); font-size: 0.72rem; }

/* ===== 12. MEAL PLANNER ===== */
.planner-header { text-align: center; margin-bottom: 30px; }

.planner-title {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-violet), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
}

.planner-subtitle { color: var(--text-secondary); font-size: 0.95rem; }

.planner-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-bottom: 100px;
}

.planner-col {
    background: var(--surface);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    transition: border-color 0.3s ease;
    min-height: 420px;
    display: flex;
    flex-direction: column;
}

.planner-col:hover { border-color: var(--border-hover); }

.planner-col-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 18px;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    background: var(--surface-hover);
    border-bottom: 1px solid var(--border);
}

.meal-icon { font-size: 1.3rem; }

.planner-items {
    flex: 1;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.planner-placeholder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--border);
    border-radius: 12px;
    min-height: 100px;
    color: var(--text-muted);
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.planner-placeholder:hover {
    border-color: var(--accent);
    color: var(--accent-light);
    background: rgba(99, 102, 241, 0.05);
}

/* Meal items in planner */
.meal-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    transition: all 0.2s ease;
    animation: cardEnter 0.3s ease both;
    /* role="listitem" باید در HTML باشه نه CSS — حذف شد */
}

.meal-item:hover { border-color: var(--border-hover); }

.meal-item-info { flex: 1; min-width: 0; }

.meal-item-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 6px;
}

.meal-item-grams {
    font-size: 0.7rem;
    font-weight: 600;
    color: #6366f1;
    background: rgba(99,102,241,0.12);
    border-radius: 5px;
    padding: 1px 5px;
    flex-shrink: 0;
    white-space: nowrap;
}

.meal-item-macros { font-size: 0.72rem; color: var(--text-secondary); }

.meal-item-remove {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid rgba(220, 38, 38, 0.3);
    background: rgba(220, 38, 38, 0.08);
    color: #ef4444;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
    line-height: 1;
    font-family: 'Vazirmatn', sans-serif;
}

.meal-item-remove:hover {
    background: rgba(220, 38, 38, 0.2);
    transform: scale(1.1);
}

/* Meal column totals */
.meal-col-totals {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.meal-col-totals span { font-weight: 500; }

/* Day Totals Bar */
#day-totals { margin-bottom: 20px; }

.day-total-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    padding: 16px 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    font-size: 0.9rem;
    color: var(--text-primary);
    animation: cardEnter 0.3s ease forwards;
}

.day-total-label {
    font-weight: 700;
    color: var(--accent-light);
    margin-left: auto;
}

/* Meal Picker Popup */
.meal-picker-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.18s ease;
}

.meal-picker-popup {
    position: relative;
    background: var(--modal-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    z-index: 1101;
    width: 290px;
    max-width: calc(100vw - 32px);
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.meal-picker-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 2px 6px 6px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2px;
}

.meal-picker-title--small {
    margin-top: 4px;
    font-size: 0.74rem;
    border-bottom: none;
    padding-bottom: 2px;
}

.meal-picker-foodname {
    color: var(--text-primary);
    font-weight: 700;
}

/* ── Gram input row ── */
.meal-picker-gram-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 6px;
    background: var(--surface);
    border-radius: 10px;
    border: 1px solid var(--border);
}

.meal-picker-gram-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.meal-picker-gram-ctrl {
    display: flex;
    align-items: center;
    gap: 6px;
}

.gram-step-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-hover);
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}

.gram-step-btn:hover {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border-color: transparent;
}

.meal-picker-gram-input {
    flex: 1;
    min-width: 0;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid var(--border-hover);
    background: var(--surface);
    color: var(--text-primary);
    font-family: 'Vazirmatn', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    outline: none;
    -moz-appearance: textfield;
}

.meal-picker-gram-input::-webkit-outer-spin-button,
.meal-picker-gram-input::-webkit-inner-spin-button { -webkit-appearance: none; }

.meal-picker-gram-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.meal-picker-preview {
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.5;
}

.meal-picker-gram-warn {
    font-size: 0.72rem;
    color: #ef4444;
    text-align: center;
    min-height: 1em;
}

.meal-picker-opt {
    padding: 9px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text-primary);
    font-family: 'Vazirmatn', sans-serif;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    text-align: right;
    transition: all 0.2s ease;
}

.meal-picker-opt:hover {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #ffffff;
    border-color: transparent;
}

.meal-picker-close {
    padding: 7px 14px;
    background: transparent;
    border: 1px solid rgba(220, 38, 38, 0.3);
    border-radius: 9px;
    color: #ef4444;
    font-family: 'Vazirmatn', sans-serif;
    font-size: 0.82rem;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    margin-top: 2px;
}

.meal-picker-close:hover { background: rgba(220, 38, 38, 0.1); }

/* ===== PIE CHART ===== */
.pie-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 10px 0 14px;
    gap: 8px;
}

.pie-svg {
    width: 80px;
    height: 80px;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.18));
}

.pie-center-text {
    font-size: 7px;
    font-weight: 700;
    fill: var(--text-primary);
    font-family: 'Vazirmatn', sans-serif;
}

.pie-legend {
    display: flex;
    gap: 10px;
    font-size: 0.72rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
    justify-content: center;
}

.pie-legend span { display: flex; align-items: center; gap: 4px; }
.pie-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-protein { background: #10b981; }
.dot-carbs   { background: #3b82f6; }

/* ===== 13. UTILITY & ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    font-size: 1rem;
}

.empty-state .empty-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 12px;
}

/* Focus-visible outline for keyboard users */
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ===== 14. RESPONSIVE ===== */
@media (max-width: 1200px) {
    #results { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
    #results { grid-template-columns: repeat(2, 1fr); }
    h1 { font-size: 2rem; }
    .theme-toggle .toggle-label { display: none; }
    .header-row { padding: 0 60px; }
    .filter-btn { padding: 8px 16px; font-size: 0.85rem; }
    .planner-grid { grid-template-columns: repeat(2, 1fr); }
    .tab-btn { padding: 9px 18px; font-size: 0.88rem; }
}

@media (max-width: 600px) {
    body { padding: 20px 12px 12px; }
    .header-row {
        flex-direction: column;
        padding: 0;
        gap: 10px;
        align-items: center;
    }
    .theme-toggle {
        position: static;
        align-self: flex-end;
    }
    .input-row { flex-direction: column; }
    #results { grid-template-columns: 1fr; }
    h1 { font-size: 1.8rem; }
    .form-box { padding: 20px; }
    .filter-section { padding: 20px; }
    .filter-btn { padding: 7px 14px; font-size: 0.8rem; }
    .compare-modal { align-items: flex-end; padding: 0; }
    .compare-modal-content { width: 100%; border-radius: 20px 20px 0 0; max-height: 92vh; }
    .modal-cards-grid { grid-template-columns: 1fr; }
    .legend-note { display: none; }
}

@media (max-width: 500px) {
    .planner-grid { grid-template-columns: 1fr; }
    .tab-bar { width: 100%; max-width: 100%; }
    .tab-btn { padding: 9px 4px; font-size: 0.78rem; }
}

@media (max-width: 360px) {
    .tab-btn { font-size: 0.72rem; }
}

/* =====================================================
   BMR CALCULATOR + GOAL TRACKER
   ===================================================== */

/* ── Open Button ── */
.bmr-open-btn {
    margin-top: 14px;
    padding: 10px 22px;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: 'Vazirmatn', sans-serif;
    background: var(--surface);
    color: var(--accent-light);
    border: 1.5px solid rgba(99, 102, 241, 0.3);
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.bmr-open-btn:hover {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

/* ── Goal Tracker ── */
.goal-tracker {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 22px 26px;
    margin-bottom: 24px;
    transition: background 0.3s ease;
}

.goal-tracker-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 18px;
}

.goal-bars {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.goal-bar-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.goal-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
}

.goal-bar-label {
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.goal-bar-numbers {
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.goal-bar-numbers strong {
    color: var(--text-primary);
    font-weight: 700;
}

.goal-bar-numbers .goal-pct {
    font-size: 0.72rem;
    opacity: 0.7;
    margin-right: 4px;
}

.goal-track {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
}

.goal-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

/* Color states */
.goal-fill.calories  { background: linear-gradient(90deg, #8b5cf6, #a78bfa); }
.goal-fill.protein   { background: linear-gradient(90deg, #10b981, #34d399); }
.goal-fill.carbs     { background: linear-gradient(90deg, #3b82f6, #60a5fa); }

.goal-fill.over {
    background: linear-gradient(90deg, #ef4444, #f87171) !important;
}

.goal-fill.done {
    background: linear-gradient(90deg, #10b981, #059669) !important;
}

/* Completion badge */
.goal-done-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 20px;
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
    animation: popIn 0.3s ease;
}

@keyframes popIn {
    0%   { transform: scale(0.8); opacity: 0; }
    60%  { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

.goal-over-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 20px;
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.goal-tracker-empty {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 0.88rem;
}

/* ── BMR Modal ── */
.bmr-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.88);
    backdrop-filter: blur(20px);
    z-index: 2000;
    padding: 20px;
    overflow-y: auto;
    align-items: center;
    justify-content: center;
}

.bmr-modal.show { display: flex; }

.bmr-modal-content {
    background: var(--modal-bg);
    border-radius: 24px;
    width: 95%;
    max-width: 520px;
    margin: auto;
    border: 1px solid var(--border);
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.08), 0 24px 60px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.22s ease, transform 0.22s ease;
    overflow: hidden;
}

.bmr-modal-content.modal-entered { opacity: 1; transform: translateY(0); }
.bmr-modal-content.modal-leaving { opacity: 0; transform: translateY(10px); transition: opacity 0.18s ease, transform 0.18s ease; }

.bmr-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.bmr-modal-header h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.bmr-close-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-family: 'Vazirmatn', sans-serif;
}

.bmr-close-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.25);
    color: #f87171;
}

.bmr-modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.bmr-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin: 0;
}

/* BMR Input Grid */
.bmr-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.bmr-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.bmr-field--full {
    grid-column: 1 / -1;
}

.bmr-field label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.bmr-field input,
.bmr-field select {
    width: 100%;
    padding: 11px 14px;
    font-size: 0.95rem;
    font-family: 'Vazirmatn', sans-serif;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: var(--input-bg);
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    -moz-appearance: textfield;
}

.bmr-field input::-webkit-outer-spin-button,
.bmr-field input::-webkit-inner-spin-button { -webkit-appearance: none; }

.bmr-field input:focus,
.bmr-field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.bmr-field select option {
    background: var(--modal-bg);
    color: var(--text-primary);
}

/* Goal Buttons */
.bmr-goal-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.bmr-goal-btn {
    flex: 1;
    padding: 10px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: 'Vazirmatn', sans-serif;
    background: var(--surface);
    color: var(--text-secondary);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    min-width: 0;
}

.bmr-goal-btn:hover {
    color: var(--text-primary);
    border-color: rgba(99, 102, 241, 0.3);
    background: var(--surface-hover);
}

.bmr-goal-btn.active {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 3px 12px rgba(99, 102, 241, 0.35);
}

/* BMR Result */
.bmr-result {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px 20px;
    display: none;
    flex-direction: column;
    gap: 12px;
    animation: cardEnter 0.3s ease both;
}

.bmr-result.visible { display: flex; }

.bmr-result-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.bmr-result-nums {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.bmr-result-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.bmr-result-item .val {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.bmr-result-item .lbl {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.bmr-result-item .val.accent { color: var(--accent-light); }

.bmr-result-note {
    font-size: 0.78rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    padding-top: 10px;
    line-height: 1.6;
}

/* BMR Actions */
.bmr-actions {
    display: flex;
    gap: 10px;
}

.bmr-calc-btn {
    flex: 1;
    padding: 13px;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: 'Vazirmatn', sans-serif;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: opacity 0.2s ease, box-shadow 0.2s ease;
}

.bmr-calc-btn:hover {
    opacity: 0.9;
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.bmr-reset-btn {
    padding: 13px 18px;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: 'Vazirmatn', sans-serif;
    background: transparent;
    color: var(--text-secondary);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.bmr-reset-btn:hover {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.05);
}

/* ── Responsive ── */
@media (max-width: 600px) {
    .bmr-grid { grid-template-columns: 1fr; }
    .bmr-modal { align-items: flex-end; padding: 0; }
    .bmr-modal-content { width: 100%; border-radius: 20px 20px 0 0; max-height: 92vh; overflow-y: auto; }
    .bmr-goal-btns { flex-direction: column; }
    .bmr-goal-btn { flex: unset; }
}

/* ===== 15. PERSIAN NAME SEARCH ===== */
.name-search-box {
    margin: 0 0 1.25rem;
}

.name-search-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 14px;
    padding: 0 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.name-search-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
    background: var(--surface-hover);
}

.name-search-icon {
    font-size: 1.05rem;
    opacity: 0.5;
    flex-shrink: 0;
}

.name-search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    padding: 0.8rem 0.3rem;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-primary);
    direction: rtl;
    text-align: right;
}

.name-search-input::placeholder {
    color: var(--text-secondary);
    font-size: 0.88rem;
    opacity: 0.7;
}

.name-search-clear {
    background: var(--surface-hover);
    border: 1px solid var(--border);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.75rem;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.name-search-clear:hover {
    background: rgba(239,68,68,0.15);
    border-color: rgba(239,68,68,0.4);
    color: #ef4444;
}

/* ── Dropdown — body-level, fixed position ── */
.name-search-dropdown {
    background: var(--modal-bg, #1a1f2e);
    border: 1.5px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.2);
    z-index: 99999;
    max-height: 300px;
    overflow-y: auto;
    padding: 6px;
}

.name-search-dropdown::-webkit-scrollbar { width: 4px; }
.name-search-dropdown::-webkit-scrollbar-track { background: transparent; }
.name-search-dropdown::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.ns-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.8rem;
    cursor: pointer;
    transition: background 0.12s;
    direction: rtl;
    border-radius: 9px;
}

.ns-item:hover,
.ns-item.focused {
    background: rgba(99,102,241,0.12);
}

.ns-name {
    flex: 1;
    font-size: 0.92rem;
    color: var(--text-primary);
    text-align: right;
}

.ns-name mark {
    background: rgba(99,102,241,0.25);
    color: #818cf8;
    border-radius: 3px;
    padding: 0 2px;
    font-weight: 700;
    font-style: normal;
}

.ns-cat {
    font-size: 0.72rem;
    color: var(--text-secondary);
    flex-shrink: 0;
    white-space: nowrap;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px 6px;
}

.ns-empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.88rem;
    direction: rtl;
}


/* ── Favorites header layout fix ── */
.fav-tab-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.fav-tab-sub-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* theme toggle alt — در همه تب‌ها */
.theme-toggle-alt {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 7px 14px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text-primary);
    font-family: 'Vazirmatn', sans-serif;
    white-space: nowrap;
    flex-shrink: 0;
    touch-action: manipulation;
}

.theme-toggle-alt:hover {
    border-color: var(--accent);
    background: var(--surface-hover);
}

.theme-toggle-alt .toggle-label {
    font-size: 0.8rem;
    font-weight: 500;
}

@media (max-width: 480px) {
    .theme-toggle-alt .toggle-label { display: none; }
}

/* =====================================================
   FAVORITES TAB + THEME TOGGLE ALT
   ===================================================== */

.planner-header-top {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-bottom: 6px;
}
.planner-header-top .theme-toggle-alt { position: absolute; left: 0; }

@media (max-width: 600px) {
    .planner-header-top {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }
    .planner-header-top .theme-toggle-alt {
        position: static;
        align-self: flex-end;
    }
}

.theme-toggle-alt {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 7px 14px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text-primary);
    font-family: 'Vazirmatn', sans-serif;
    white-space: nowrap;
    flex-shrink: 0;
    touch-action: manipulation;
}
.theme-toggle-alt:hover { border-color: var(--accent); background: var(--surface-hover); }
.theme-toggle-alt .toggle-label { font-size: 0.8rem; font-weight: 500; }

.tab-content { animation: tabEnter 0.22s ease both; }
@keyframes tabEnter {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fav-tab-header { margin-bottom: 20px; }
.fav-tab-top-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.fav-tab-title {
    font-size: clamp(1.3rem,4vw,1.8rem); font-weight: 700; margin: 0;
    background: linear-gradient(135deg,#f43f5e,#fb7185);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.fav-tab-sub-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fav-tab-subtitle { font-size: 0.9rem; color: var(--text-secondary); margin: 0; }

.fav-clear-all-btn {
    padding: 7px 16px; font-size: 0.8rem; font-weight: 600;
    font-family: 'Vazirmatn',sans-serif; background: transparent;
    color: var(--text-secondary); border: 1px solid var(--border);
    border-radius: 8px; cursor: pointer; transition: all 0.2s ease;
    white-space: nowrap; flex-shrink: 0; touch-action: manipulation;
}
.fav-clear-all-btn:hover { color: #ef4444; border-color: rgba(239,68,68,.35); background: rgba(239,68,68,.06); }

.fav-sort-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; flex-wrap: wrap; }
.fav-sort-label { font-size: 0.82rem; color: var(--text-secondary); font-weight: 500; flex-shrink: 0; }
.fav-sort-btns  { display: flex; gap: 6px; flex-wrap: wrap; }
.fav-sort-btn {
    padding: 6px 14px; font-size: 0.8rem; font-weight: 500;
    font-family: 'Vazirmatn',sans-serif; background: var(--surface);
    color: var(--text-secondary); border: 1px solid var(--border);
    border-radius: 20px; cursor: pointer; transition: all 0.2s ease; touch-action: manipulation;
}
.fav-sort-btn:hover { color: var(--text-primary); border-color: rgba(99,102,241,.3); background: var(--surface-hover); }
.fav-sort-btn.active { background: linear-gradient(135deg,#6366f1,#8b5cf6); color: #fff; border-color: transparent; box-shadow: 0 3px 10px rgba(99,102,241,.3); }

.fav-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 100px; }

.fav-empty { grid-column: 1/-1; text-align: center; padding: 80px 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.fav-empty-icon  { font-size: 3.5rem; opacity: .35; margin-bottom: 4px; }
.fav-empty-title { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); margin: 0; }
.fav-empty-desc  { font-size: 0.88rem; color: var(--text-secondary); margin: 0; max-width: 280px; line-height: 1.6; }

.fav-card-item {
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
    padding: 18px; display: flex; flex-direction: column; gap: 12px;
    opacity: 0; transform: translateY(10px);
    animation: cardEnter .28s ease both;
    animation-delay: calc(var(--card-index,0) * .04s);
    transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
.fav-card-item:hover { background: var(--surface-hover); border-color: rgba(244,63,94,.3); box-shadow: 0 4px 20px rgba(244,63,94,.08); }

.fav-card-top        { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.fav-card-name-row   { display: flex; align-items: center; gap: 7px; min-width: 0; flex: 1; }
.fav-card-emoji      { font-size: 1.2rem; flex-shrink: 0; line-height: 1; }
.fav-card-name       { font-size: .92rem; font-weight: 700; color: var(--text-primary); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.fav-remove-btn {
    width: 28px; height: 28px; border-radius: 50%;
    border: 1px solid rgba(244,63,94,.2); background: rgba(244,63,94,.08);
    font-size: .85rem; cursor: pointer; display: flex; align-items: center;
    justify-content: center; flex-shrink: 0; transition: transform .2s ease, background .2s ease;
    touch-action: manipulation; padding: 0; line-height: 1;
}
.fav-remove-btn:hover { transform: scale(1.15); background: rgba(244,63,94,.2); }

.fav-fitness-badge { display: inline-flex; align-items: center; gap: 4px; font-size: .72rem; font-weight: 700; padding: 3px 10px; border-radius: 20px; width: fit-content; }

.fav-macros { display: flex; align-items: center; background: var(--surface-hover); border-radius: 10px; padding: 10px 12px; gap: 6px; }
.fav-macro-item    { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 1; }
.fav-macro-val     { font-size: .95rem; font-weight: 700; line-height: 1; }
.fav-macro-lbl     { font-size: .65rem; color: var(--text-secondary); font-weight: 500; }
.fav-macro-divider { width: 1px; height: 28px; background: var(--border); flex-shrink: 0; }

.protein-color { color: #10b981; }
.carbs-color   { color: #3b82f6; }
.cal-color     { color: #a78bfa; }

.fav-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fav-card-cat { font-size: .75rem; color: var(--text-secondary); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }

.fav-add-meal-btn {
    padding: 6px 14px; font-size: .78rem; font-weight: 600;
    font-family: 'Vazirmatn',sans-serif; background: transparent;
    color: var(--accent-light); border: 1.5px solid rgba(129,140,248,.4);
    border-radius: 20px; cursor: pointer; transition: all .2s ease;
    white-space: nowrap; flex-shrink: 0; touch-action: manipulation;
}
.fav-add-meal-btn:hover { background: linear-gradient(135deg,#6366f1,#8b5cf6); color: #fff; border-color: transparent; box-shadow: 0 3px 12px rgba(99,102,241,.35); }

@media (max-width: 1200px) { .fav-grid { grid-template-columns: repeat(3,1fr); } }
@media (max-width: 900px)  { .fav-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 600px)  { .fav-tab-top-row { flex-wrap: wrap; gap: 10px; } .theme-toggle-alt .toggle-label { display: none; } }
@media (max-width: 480px)  { .fav-grid { grid-template-columns: 1fr; } .fav-card-item { padding: 14px; } }
