/* ============================================
   Fitwea — Index Page Styles
   ============================================ */

* { margin: 0; padding: 0; box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
body { background-color: var(--bg-primary, #f9fafb); display: flex; justify-content: center; align-items: flex-start; min-height: 100vh; padding: 16px; }
.container { width: 100%; max-width: 800px; background: transparent; }
.top-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: space-between; margin-bottom: 8px; }
.top-bar-left { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.badge { font-size: 12px; font-weight: 500; padding: 4px 12px; border-radius: 40px; text-decoration: none; display: inline-block; }
.badge-email { background: var(--accent-light, #eef2ff); color: var(--text-primary, #1f2937); }
.badge-profile { background: var(--accent-light, #eef2ff); color: var(--accent, #2563eb); }
.badge-logout { background: var(--danger-light, #fef2f2); color: var(--danger, #ef4444); }
.badge-login { background: var(--accent-light, #eef2ff); color: var(--accent, #2563eb); }
.badge-register { background: var(--accent, #3b82f6); color: #fff; }
.date-picker-wrapper { background: var(--bg-secondary, white); border-radius: 40px; padding: 6px 14px; border: 1px solid var(--border-color, #e5e7eb); display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text-primary, #1f2937); position: relative; }
.date-picker-wrapper svg { width: 16px; height: 16px; stroke: #64748b; stroke-width: 1.8; fill: none; }
#hiddenDateInput { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.header { text-align: center; margin: 8px 0; }
.header h1 { font-size: 22px; font-weight: 700; color: var(--text-primary, #000); letter-spacing: -0.5px; }

/* ====== Main Tabs (Обзор | Дневник) ====== */
.main-tabs-fitwea { display: flex; gap: 6px; margin-bottom: 16px; justify-content: center; }
.main-tab { display: inline-flex; align-items: center; gap: 6px; padding: 10px 28px; border-radius: 40px; border: 1px solid var(--border-color, #e5e7eb); background: var(--bg-secondary, #fff); font-size: 15px; font-weight: 600; color: var(--text-secondary, #374151); cursor: pointer; transition: all 0.15s; }
.main-tab.active { background: var(--accent, #3b82f6); border-color: var(--accent, #3b82f6); color: #fff; box-shadow: 0 2px 8px rgba(59,130,246,0.25); }
.main-tab:hover { background: var(--bg-hover, #f1f5f9); }
.main-tab.active:hover { background: var(--accent-hover, #2563eb); }

.main-section { display: none; }
.main-section.active-main-section { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ====== Rings Carousel ====== */
.rings-carousel-wrapper { background: var(--bg-card, #fff); border-radius: 32px; padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,0.05)); overflow: hidden; }
.rings-carousel { display: flex; transition: transform 0.3s ease; }
.ring-slide { flex: 0 0 100%; display: flex; justify-content: center; }
.ring-cell { display: flex; flex-direction: column; align-items: center; }
.ring-cell canvas { width: 130px; height: 130px; }
.ring-cell-label { font-size: 14px; font-weight: 600; color: var(--text-primary, #1f2937); margin-top: 6px; }
.ring-cell-value { font-size: 13px; color: var(--text-secondary, #4b5563); font-weight: 500; background: var(--bg-hover, #f3f4f6); padding: 3px 12px; border-radius: 24px; margin-top: 4px; }
.ring-cell-sub { font-size: 11px; color: var(--text-muted, #6b7280); margin-top: 2px; }

.carousel-dots { display: none; justify-content: center; gap: 6px; margin-top: 12px; }
.carousel-dot { width: 8px; height: 8px; border-radius: 50%; background: #d1d5db; cursor: pointer; transition: all 0.2s; }
.carousel-dot.active { background: #3b82f6; width: 24px; border-radius: 4px; }

/* На десктопе — один ряд из 4 колец, без карусели */
@media (min-width: 620px) {
    .rings-carousel { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; transform: none !important; }
    .ring-slide { flex: 0 0 auto; }
    .carousel-dots { display: none !important; }
}
@media (max-width: 619px) {
    .carousel-dots { display: flex; }
}

/* ====== Overview Split (шаги + упражнения рядом) ====== */
.overview-split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
@media (max-width: 500px) { .overview-split { grid-template-columns: 1fr; } }

/* ====== Overview Cards ====== */
.overview-card { background: var(--bg-card, #fff); border-radius: 28px; padding: 18px; margin-bottom: 12px; box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,0.04)); }
.overview-card:last-child { margin-bottom: 0; }
.overview-card-header { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--text-primary, #1f2937); margin-bottom: 10px; }
.overview-card-value { font-size: 18px; font-weight: 700; color: var(--accent, #3b82f6); margin-left: auto; }
.overview-card-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 10px; }

/* Steps progress bar */
.steps-progress-bar { width: 100%; height: 8px; background: var(--bg-hover, #f1f5f9); border-radius: 4px; overflow: hidden; margin: 4px 0; }
.steps-progress-fill { height: 100%; background: linear-gradient(90deg, #3b82f6, #2563eb); border-radius: 4px; transition: width 0.3s ease; }
.steps-progress-label { font-size: 11px; color: var(--text-muted, #6b7280); margin-bottom: 6px; }

/* Steps chart */
.steps-chart-container { width: 100%; margin: 4px 0; }
.steps-chart-container canvas { width: 100%; height: 120px; }

/* Exercise stats */
.exercise-stats { display: flex; gap: 16px; justify-content: center; padding: 8px 0; }
.exercise-stat { text-align: center; }
.exercise-stat-value { display: block; font-size: 22px; font-weight: 700; color: var(--accent, #3b82f6); }
.exercise-stat-label { font-size: 11px; color: var(--text-muted, #6b7280); }

/* ====== Diary (Дневник) ====== */
.diary-meals { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.diary-meal-block { background: var(--bg-card, #fff); border-radius: 20px; padding: 14px 16px; box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,0.04)); }
.diary-meal-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.diary-meal-label { font-size: 14px; font-weight: 700; color: var(--text-primary, #1f2937); }
.diary-meal-kcal { font-size: 12px; font-weight: 600; color: var(--text-muted, #6b7280); background: var(--bg-hover, #f3f4f6); padding: 2px 10px; border-radius: 20px; }
.diary-add-food-btn { margin-left: auto; background: var(--accent-light, #eef2ff); border: none; border-radius: 20px; padding: 5px 14px; font-size: 12px; font-weight: 600; color: var(--accent, #2563eb); cursor: pointer; transition: background 0.15s; }
.diary-add-food-btn:hover { background: #dbeafe; }

.diary-meal-item { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--bg-hover, #f1f5f9); }
.diary-meal-item:last-child { border-bottom: none; }
.diary-meal-item-name { font-size: 13px; font-weight: 500; color: var(--text-primary, #0f172a); flex: 1; }
.diary-meal-item-kcal { font-size: 11px; font-weight: 600; color: var(--text-secondary, #4b5563); background: var(--bg-hover, #f3f4f6); padding: 2px 8px; border-radius: 12px; }

.diary-water-section, .diary-exercise-section { background: var(--bg-card, #fff); border-radius: 20px; padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,0.04)); }

/* ====== Food Search ====== */
.food-search-section { background: var(--bg-card, #fff); border-radius: 28px; padding: 18px; margin-bottom: 12px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); position: relative; z-index: 10; }
.food-search-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 15px; font-weight: 600; color: var(--text-primary, #1f2937); }
.food-search-close { background: none; border: none; color: #6b7280; cursor: pointer; padding: 4px; }
.food-search-close:hover { color: #ef4444; }
.food-search-input-wrap { margin-bottom: 12px; }
.food-search-input-wrap input { width: 100%; padding: 10px 14px; border: 1px solid var(--border-color, #e5e7eb); border-radius: 24px; font-size: 14px; outline: none; }
.food-search-input-wrap input:focus { border-color: var(--accent, #3b82f6); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
.food-search-results { max-height: 280px; overflow-y: auto; margin-bottom: 12px; }
.food-search-item { display: flex; align-items: center; gap: 8px; padding: 8px 4px; border-bottom: 1px solid var(--bg-hover, #f1f5f9); }
.food-search-item:last-child { border-bottom: none; }
.food-search-item-info { flex: 1; }
.food-search-item-name { font-size: 13px; font-weight: 600; color: var(--text-primary, #0f172a); display: block; }
.food-search-item-nutr { font-size: 11px; color: var(--text-muted, #6b7280); }
.food-search-item-add { background: var(--accent, #3b82f6); color: #fff; border: none; border-radius: 50%; width: 28px; height: 28px; font-size: 18px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; }
.food-search-item-add:hover { background: var(--accent-hover, #2563eb); }

.food-search-manual { border-top: 1px solid var(--bg-hover, #f1f5f9); padding-top: 12px; }
.food-search-manual-title { font-size: 12px; font-weight: 600; color: var(--text-muted, #6b7280); margin-bottom: 8px; }
/* Grams input */
.food-search-grams { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; padding: 8px 4px; }
.food-search-grams-label { font-size: 12px; font-weight: 500; color: var(--text-muted, #6b7280); white-space: nowrap; }
.food-search-grams .lifestyle-input { width: 80px; }
.food-search-add-btn { width: 100%; background: var(--accent, #3b82f6); color: #fff; border: none; border-radius: 14px; padding: 10px; font-size: 14px; font-weight: 600; cursor: pointer; margin-top: 8px; }
.food-search-add-btn:hover { background: var(--accent-hover, #2563eb); }
#foodGramsAddBtn { width: auto; margin-top: 0; padding: 6px 16px; border-radius: 12px; }

/* ====== Old nav tabs ====== */
.nav-tabs-fitwea { display: flex; gap: 6px; margin-bottom: 16px; justify-content: center; }
.nav-tabs-fitwea .nav-tab { display: inline-flex; align-items: center; gap: 6px; padding: 8px 20px; border-radius: 40px; border: 1px solid var(--border-color, #e5e7eb); background: var(--bg-secondary, #fff); font-size: 14px; font-weight: 600; color: var(--text-secondary, #374151); cursor: pointer; transition: all 0.15s; }
.nav-tabs-fitwea .nav-tab.active { background: var(--accent-light, #eef2ff); border-color: var(--accent, #3b82f6); color: var(--accent, #2563eb); }
.nav-tabs-fitwea .nav-tab:hover { background: var(--bg-hover, #f1f5f9); }
.nav-tabs-fitwea .nav-tab svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.8; fill: none; }

/* Sections */
.fitwea-section { display: none; }
.fitwea-section.active-section { display: block; }

/* Lifestyle grid */
.lifestyle-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.lifestyle-card { background: var(--bg-card, #fff); border-radius: 20px; padding: 14px 10px; text-align: center; box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,0.04)); }
.lifestyle-icon { display:flex; align-items:center; justify-content:center; width:28px; height:28px; margin:0 auto; }
.lifestyle-icon svg { width:22px; height:22px; stroke:var(--text-muted, #64748b); stroke-width:1.8; fill:none; }
.lifestyle-value { font-size: 18px; font-weight: 700; color: var(--text-primary, #0f172a); margin: 4px 0 2px; }
.lifestyle-label { font-size: 11px; color: var(--text-muted, #6b7280); margin-bottom: 6px; }
.lifestyle-actions { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
.lifestyle-btn { background: var(--bg-hover, #f1f5f9); border: none; border-radius: 12px; padding: 4px 10px; font-size: 12px; font-weight: 600; color: var(--text-secondary, #374151); cursor: pointer; transition: background 0.15s; }
.lifestyle-btn:hover { background: var(--border-color, #e2e8f0); }
.lifestyle-input { width: 60px; border: 1px solid var(--border-color, #e5e7eb); border-radius: 12px; padding: 4px 6px; font-size: 12px; text-align: center; outline: none; background: var(--bg-input, #fff); color: var(--text-primary, #1f2937); }

/* Mode tabs */
.mode-tabs { display: flex; justify-content: center; margin-bottom: 12px; }
.tab-container { display: flex; border: 1px solid var(--border-color, #e5e7eb); border-radius: 999px; padding: 3px; background: var(--bg-secondary, #fff); }
.tab-btn { display:inline-flex; align-items:center; gap:4px; padding: 6px 14px; border: none; background: transparent; border-radius: 999px; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--text-muted, #4b5563); transition: all 0.2s; }
.tab-btn.active { background-color: var(--accent-light, #eef2ff); color: var(--accent, #2563eb); }
.tab-btn svg { width:14px; height:14px; stroke:currentColor; stroke-width:1.8; fill:none; }
.tab-panel { display: none; animation: fadeIn 0.2s ease; }
.tab-panel.active-panel { display: block; }

/* Chat input */
.input-box { border: 1px solid var(--border-color, #e5e7eb); border-radius: 24px; padding: 14px; background: var(--bg-card, #fff); }
.input-box textarea { width: 100%; border: none; outline: none; resize: none; font-size: 15px; color: var(--text-primary, #1f2937); min-height: 48px; font-family: inherit; line-height: 1.4; background: transparent; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; flex-wrap: wrap; gap: 6px; }
.left-tools { display: flex; gap: 6px; }
.mini-btn { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border: 1px solid var(--border-color, #e5e7eb); border-radius: 999px; background: var(--bg-secondary, #fff); font-size: 12px; font-weight: 500; color: var(--text-secondary, #374151); cursor: pointer; }
.mini-btn svg { width:12px; height:12px; stroke:currentColor; stroke-width:1.8; fill:none; }
.send-btn { background-color: var(--accent, #3b82f6); border: none; border-radius: 50%; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.send-btn svg { width: 16px; height: 16px; fill: none; stroke: #fff; stroke-width: 2.5; }

/* Meal selector */
.meal-selector { display: flex; gap: 6px; margin: 8px 0; flex-wrap: wrap; }
.meal-btn { display:inline-flex; align-items:center; gap:4px; border: 1px solid var(--border-color, #e5e7eb); border-radius: 40px; padding: 5px 12px; font-size: 12px; font-weight: 500; background: var(--bg-secondary, #fff); color: var(--text-secondary, #475569); cursor: pointer; transition: all 0.15s; }
.meal-btn.active { background: var(--accent-light, #eef2ff); border-color: var(--accent, #3b82f6); color: var(--accent, #2563eb); }
.meal-btn:hover { background: var(--bg-hover, #f1f5f9); }
.meal-btn svg { width:14px; height:14px; stroke:currentColor; stroke-width:1.8; fill:none; }

/* KBJU result */
.kbju-result { display: none; background: var(--accent-light, #eef2ff); border-radius: 20px; padding: 12px 16px; margin-bottom: 12px; box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,0.04)); }
.kbju-result.visible { display: block; }
.kbju-title { font-size: 13px; font-weight: 600; color: var(--accent, #2563eb); margin-bottom: 6px; }
.kbju-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.kbju-item { background: var(--bg-secondary, #fff); border-radius: 12px; padding: 4px 10px; font-size: 12px; font-weight: 500; color: var(--text-primary, #1f2937); }
.kbju-confirm { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.kbju-confirm button { border: none; border-radius: 12px; padding: 5px 14px; font-size: 12px; font-weight: 600; cursor: pointer; }
.kbju-add { background: var(--accent, #3b82f6); color: #fff; }
.kbju-add:hover { background: var(--accent-hover, #2563eb); }
.kbju-cancel { background: var(--border-color, #e5e7eb); color: var(--text-secondary, #374151); }
.kbju-cancel:hover { background: var(--text-light, #d1d5db); }
.kbju-checkbox { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-secondary, #475569); cursor: pointer; }
.kbju-checkbox input { width: 14px; height: 14px; cursor: pointer; }

/* Micro table */
.micro-container { background: var(--bg-card, white); border-radius: 28px; padding: 12px 0; }
.micro-row { display: flex; align-items: center; padding: 8px 16px; border-bottom: 1px solid var(--border-light, #f0f2f5); gap: 8px; }
.micro-row:last-child { border-bottom: none; }
.micro-label { font-size: 13px; font-weight: 500; color: var(--text-secondary, #334155); min-width: 100px; }
.micro-total { font-weight: 600; color: var(--text-primary, #0f172a); font-size: 13px; min-width: 50px; text-align: right; }
.micro-goal { font-size: 12px; color: var(--text-muted, #6b7280); min-width: 40px; }
.micro-remain { font-size: 11px; color: var(--text-secondary, #475569); background: var(--bg-hover, #f1f5f9); padding: 2px 8px; border-radius: 40px; white-space: nowrap; }
.micro-bar-wrap { flex: 1; height: 8px; background: var(--bg-hover, #f1f5f9); border-radius: 4px; overflow: hidden; min-width: 60px; }
.micro-bar { height: 100%; border-radius: 4px; transition: width 0.3s ease; }
.micro-section-title { font-size: 14px; font-weight: 700; color: var(--text-primary, #0f172a); padding: 14px 16px 6px; }

/* History */
.history-list { background: var(--bg-card, white); border-radius: 28px; padding: 8px 0; max-height: 300px; overflow-y: auto; }
.history-item { padding: 10px 16px; border-bottom: 1px solid var(--bg-hover, #f1f5f9); display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.history-text { font-size: 13px; font-weight: 500; color: var(--text-primary, #0f172a); background: var(--bg-primary, #f8fafc); padding: 4px 10px; border-radius: 24px; }
.history-mealtype { font-size: 10px; color: var(--accent, #3b82f6); background: var(--accent-light, #eef2ff); padding: 2px 8px; border-radius: 20px; font-weight: 600; }
.history-nutrients { font-size: 11px; color: var(--text-secondary, #475569); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.history-nutrients span { background: var(--bg-hover, #f1f5f9); padding: 3px 7px; border-radius: 20px; }
.delete-btn { background: var(--danger-light, #fef2f2); color: var(--danger, #ef4444); border: none; border-radius: 50%; width: 24px; height: 24px; cursor: pointer; font-size: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background 0.15s; }
.delete-btn:hover { background: #fee2e2; }

/* ====== Nutrition Tab (Питание) ====== */
.nutrition-section-title { font-size: 15px; font-weight: 700; color: var(--text-primary, #1f2937); padding: 14px 0 8px; }
.nutrient-table { background: var(--bg-card, #fff); border-radius: 20px; padding: 4px 0; margin-bottom: 12px; box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,0.04)); }
.nutrient-row { display: flex; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--bg-hover, #f1f5f9); gap: 8px; }
.nutrient-row:last-child { border-bottom: none; }
.nutrient-label { font-size: 13px; font-weight: 500; color: var(--text-primary, #0f172a); min-width: 100px; }
.nutrient-value { font-size: 13px; font-weight: 600; color: var(--accent, #2563eb); min-width: 50px; text-align: right; }
.nutrient-goal { font-size: 11px; color: var(--text-muted, #6b7280); min-width: 40px; text-align: right; }
.nutrient-remain { font-size: 11px; font-weight: 500; color: var(--text-secondary, #475569); background: var(--bg-hover, #f1f5f9); padding: 2px 8px; border-radius: 12px; white-space: nowrap; }
.nutrient-bar-wrap { flex: 1; height: 6px; background: var(--bg-hover, #f1f5f9); border-radius: 3px; overflow: hidden; min-width: 40px; }
.nutrient-bar { height: 100%; border-radius: 3px; transition: width 0.3s ease; }

/* Attribution */
.attribution { text-align: center; font-size: 11px; color: var(--text-light, #9ca3af); margin-top: 12px; }

/* Responsive */
@media (max-width: 480px) { .ring-cell canvas { width: 110px; height: 110px; } }
@media (max-width: 500px) { .lifestyle-grid { grid-template-columns: repeat(2, 1fr); } }