/* static/style.css */
/* По умолчанию скрываем всё, чтобы при прямой ссылке был белый экран */
#main-content, #unregistered-view {
    display: none;
}

/* Специальный экран для тех, кто зашел через браузер */
#browser-denied {
    display: none; /* Тоже скрыт, включим его через JS */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    text-align: center;
    background: #ffffff;
    color: #000;
    font-family: sans-serif;
    padding: 20px;
}

:root {
    --tg-theme-bg-color: var(--tg-theme-bg-color, #ffffff);
    --tg-theme-text-color: var(--tg-theme-text-color, #000000);
    --tg-theme-button-color: var(--tg-theme-button-color, #3390ec);
    --tg-theme-button-text-color: var(--tg-theme-button-text-color, #ffffff);
    --tg-theme-hint-color: var(--tg-theme-hint-color, #999999);
    --tg-theme-section-bg-color: var(--tg-theme-section-bg-color, #f3f3f3);
    --protein-color: #007aff; --fat-color: #ff9500;
    --carbs-color: #ff3b30; --calorie-color: #34c759;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--tg-theme-bg-color); color: var(--tg-theme-text-color);
    margin: 0; padding: 15px 15px 85px 15px; -webkit-font-smoothing: antialiased;
}

/* ФИКС ДЛЯ СВАЙПОВ */
#today-view {
    touch-action: pan-y;
    min-height: 100vh;
}

.view { display: none; }
.view.active-view { display: block; }

.card {
    background-color: var(--tg-theme-section-bg-color); border-radius: 14px;
    padding: 12px; margin-bottom: 20px;
}
.card h2 { font-size: 17px; margin: 0 0 12px 0; font-weight: 600; }

/* СОВРЕМЕННЫЙ СЕЛЕКТОР ДАТЫ */
.date-selector { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
.date-selector h1 { margin: 0; font-size: 24px; font-weight: 700; }

.date-arrow {
    background-color: rgba(120, 120, 128, 0.1);
    border: none;
    color: var(--tg-theme-button-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.date-arrow:active { transform: scale(0.9); background-color: rgba(120, 120, 128, 0.2); }

.summary-grid {
    display: grid; grid-template-columns: 140px 1fr; gap: 15px;
    align-items: center; margin-bottom: 25px;
}

.calorie-circle-card { position: relative; width: 140px; height: 140px; display: flex; justify-content: center; align-items: center; }
.calorie-circle-svg { position: absolute; width: 100%; height: 100%; transform: rotate(-90deg); }
.calorie-circle-bg, .calorie-circle-progress { fill: none; stroke-width: 9; }
.calorie-circle-bg { stroke: rgba(120, 120, 128, 0.16); }
.calorie-circle-progress { stroke: var(--calorie-color); stroke-linecap: round; transition: stroke-dashoffset 0.5s ease-out; }
.calorie-circle-content { display: flex; flex-direction: column; align-items: center; text-align: center; }
.calorie-main-value { font-size: 30px; font-weight: 700; line-height: 1.1; }
.calorie-label { font-size: 13px; color: var(--tg-theme-hint-color); }
.calorie-sub-value { font-size: 12px; color: var(--tg-theme-hint-color); margin-top: 4px; }

.macros-card { display: flex; flex-direction: column; gap: 12px; }
.macro-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.macro-label span:first-child { font-weight: 500; } .macro-label span:last-child { color: var(--tg-theme-hint-color); }
.progress-bar { height: 6px; background-color: rgba(120, 120, 128, 0.16); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease-out; }
.progress-fill.protein { background-color: var(--protein-color); }
.progress-fill.fat { background-color: var(--fat-color); } .progress-fill.carbs { background-color: var(--carbs-color); }

#meal-log-card { padding: 12px; background-color: rgba(120, 120, 128, 0.08); }
#meal-groups-container { display: flex; flex-direction: column; gap: 12px; }

.meal-group-header {
    display: flex; align-items: center; gap: 6px;
    padding-bottom: 6px; border-bottom: 1px solid rgba(120, 120, 128, 0.1); margin-bottom: 8px;
}
.meal-group-emoji { font-size: 16px; margin-right: 2px; }
.meal-group-title { font-size: 15px; font-weight: 600; }
.meal-group-time { font-size: 12px; color: var(--tg-theme-hint-color); }
.meal-group-calories { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--tg-theme-hint-color); }

.meal-item {
    display: grid; grid-template-columns: 1fr auto; align-items: center;
    gap: 10px; padding: 3px 0;
}
.meal-details .product-name { font-size: 14px; font-weight: 400; line-height: 1.2; }
.meal-details .product-weight { font-size: 11px; color: var(--tg-theme-hint-color); margin-top: 1px; }
.meal-calories { font-size: 13px; font-weight: 400; justify-self: end; }
.meal-placeholder { text-align: center; padding: 20px; color: var(--tg-theme-hint-color); }

@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.meal-group { animation: fadeInUp 0.4s ease-out forwards; }

.card-header-with-filters, .card-header-with-summary {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px;
}
.card-header-with-filters h2, .card-header-with-summary h2 { margin: 0; }

.filter-buttons { display: flex; gap: 5px; }
.filter-button {
    background-color: rgba(120, 120, 128, 0.12); border: none; border-radius: 8px;
    padding: 5px 12px; font-size: 14px; font-weight: 500; color: var(--tg-theme-hint-color);
    cursor: pointer; transition: all 0.2s ease;
}
.filter-button.active { background-color: var(--tg-theme-button-color); color: var(--tg-theme-button-text-color); }

.weight-summary { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 5px; }
.weight-summary.positive-change { color: #ff453a; }
.weight-summary.negative-change { color: #34c759; }

.single-value-display { text-align: center; padding: 20px 0; }
.single-value-display .value { font-size: 32px; font-weight: 700; color: var(--tg-theme-text-color); }
.single-value-display .label { font-size: 14px; color: var(--tg-theme-hint-color); }

#recommendations-container p { margin: 0 0 15px 0; line-height: 1.5; font-size: 15px; }
#reco-details { display: flex; flex-direction: column; gap: 12px; }
.reco-item { display: flex; align-items: center; gap: 10px; }
.reco-item-icon { font-size: 18px; width: 25px; text-align: center; }
.reco-item-text .title { font-weight: 600; font-size: 15px; }
.reco-item-text .description { font-size: 13px; color: var(--tg-theme-hint-color); }

.nav-bar {
    position: fixed; bottom: 0; left: 0; right: 0; height: 70px;
    background-color: var(--tg-theme-section-bg-color); border-top: 1px solid rgba(120, 120, 128, 0.16);
    display: flex; justify-content: space-around; align-items: flex-start; padding-top: 10px;
    padding-bottom: env(safe-area-inset-bottom, 10px);
}
.nav-button { background: none; border: none; font-size: 16px; font-weight: 500; color: var(--tg-theme-hint-color); padding: 0 20px; cursor: pointer; transition: color 0.2s ease; }
.nav-button.active { color: var(--tg-theme-button-color); }

@media (max-width: 400px) {
    body { padding: 10px 10px 80px 10px; }
    .summary-grid { grid-template-columns: 120px 1fr; gap: 12px; }
    .calorie-circle-card { width: 120px; height: 120px; }
    .calorie-main-value { font-size: 26px; }
}

/* --- Исправление черного круга и настройка слоев --- */
.calorie-circle-bg,
.calorie-circle-progress,
.calorie-circle-overrun {
    fill: none !important; /* Убирает черный фон */
    stroke-width: 9;
}

/* Цвет основного прогресса (зеленый) */
.calorie-circle-progress {
    stroke: var(--calorie-color);
    stroke-linecap: round;
    transition: stroke-dashoffset 0.5s ease-out;
}

/* Цвет перебора (красный) */
.calorie-circle-overrun {
    stroke: #ff3b30;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.5s ease-out;
}

/* Уменьшение шрифта при переборе */
.calorie-main-value.overflow {
    font-size: 22px;
    color: #ff3b30;
}

/* --- Градиентные полоски БЖУ --- */
.progress-fill.protein { --base-color: #007aff; background-color: var(--base-color); }
.progress-fill.fat     { --base-color: #ff9500; background-color: var(--base-color); }
.progress-fill.carbs   { --base-color: #ff3b30; background-color: var(--base-color); }

.progress-fill.macro-overflow {
    background: linear-gradient(90deg,
        var(--base-color) 0%,
        var(--base-color) 80%,
        #ff3b30 95%,
        #8b0000 100%) !important;
}

.macro-status { font-size: 12px; margin-left: 4px; font-weight: bold; color: #ff3b30; }

/* Центрирование контента внутри круга */
.calorie-circle-content {
    z-index: 2;
    width: 90px;
    pointer-events: none;
}

.reco-item-text .description {
    font-size: 13px;
    color: var(--tg-theme-hint-color);
    line-height: 1.3;
    margin-top: 2px;
}

.reco-item-text .title {
    font-weight: 600;
    font-size: 15px;
}

#about-view .card h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--tg-theme-button-color);
}

.about-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 10px;
}

.step-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.step-num {
    background-color: var(--tg-theme-button-color);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 13px;
    font-weight: bold;
    flex-shrink: 0;
}

.about-text {
    line-height: 1.5;
    font-size: 14px;
    color: var(--tg-theme-text-color);
    opacity: 0.9;
}

.contact-card {
    text-align: center;
    padding: 20px;
}

.contact-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    background-color: var(--tg-theme-button-color);
    color: white !important;
    text-decoration: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 600;
    transition: transform 0.2s ease;
}

.contact-link:active {
    transform: scale(0.95);
}

.link-icon {
    font-size: 18px;
}

/* Экран блокировки */
.auth-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 80vh;
    text-align: center;
    padding: 20px;
}

.auth-icon {
    font-size: 80px;
    margin-bottom: 20px;
}

.auth-container h1 {
    font-size: 24px;
    margin-bottom: 10px;
    color: var(--tg-theme-text-color);
}

.auth-container p {
    font-size: 16px;
    color: var(--tg-theme-hint-color);
    margin-bottom: 30px;
    line-height: 1.4;
}

.auth-button {
    background-color: var(--tg-theme-button-color);
    color: white !important;
    text-decoration: none;
    padding: 15px 30px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 16px;
    box-shadow: 0 4px 15px rgba(51, 144, 236, 0.3);
}