/* ============================================
   AlexandraFitLab — Exact Figma Match
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Tenor+Sans&display=swap');

:root {
    --green: #9EC282;
    --green-hover: #90B574;
    --green-light: #EAF0E6;
    --green-bg: #F7F9F5;
    --green-text: #8CA578;
    --green-dark: #5C604B;
    --txt: #343432;
    --text-medium: #555555;
    --text-light: #999999;
    --white: #FFFFFF;
    --grey: #F0F0F0;
    --border: #E0E0E0;
    --radius: 10px;
    --radius-btn: 5px;
    --font: 'Tenor Sans', Helvetica, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    font-family: var(--font);
    font-weight: 400;
    color: var(--txt);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ============ Background ============ */
.app-bg {
    position: fixed;
    inset: 0;
    background: url('/static/images/bg.jpg') center/cover no-repeat;
    z-index: 0;
}
.app-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(248, 248, 245, 0.78);
}

/* ============ Main Container ============ */
.app-container {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 18px 16px 24px;
}

/* ============ Header / Logo ============ */
.app-header {
    text-align: center;
    margin-bottom: 12px;
}
.app-header .logo-text {
    font-family: var(--font);
    font-size: 18px;
    color: var(--green-text);
    font-weight: 400;
    letter-spacing: -1.26px;
    border-radius: 100px;
    padding: 9px 24px 4px;
    display: inline-block;
    background: var(--grey);
    box-shadow: 0px 4px 4px rgba(0,0,0,0.25);
}
.app-header .logo-sub {
    font-family: var(--font);
    font-size: 9px;
    color: var(--green-dark);
    letter-spacing: -0.63px;
    margin-top: 1px;
    display: block;
    text-align: center;
}
.app-header .logo-desc {
    font-size: 11px;
    color: var(--txt);
    max-width: 360px;
    margin: 8px auto 0;
    line-height: 13px;
    text-align: center;
}

/* ============ Popup System ============ */
.popup {
    display: none;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: 0px 4px 4px rgba(0,0,0,0.25);
    width: 100%;
    max-width: 520px;
    padding: 0;
    animation: popupIn 0.2s ease-out;
    overflow: visible;
}
.popup.active { display: block; }

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

/* Gray top section of welcome popup */
.popup-top {
    background: var(--grey);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 30px 23px 14px;
}

/* ============ WELCOME POPUP ============ */
.welcome-popup {
    position: relative;
    width: 520px;
    height: 624px;     /* +44 px на 4-ю кнопку «Индивидуальный разбор питания» */
    padding: 0;
    border-radius: 10px;
    box-shadow: 0px 4px 4px rgba(0,0,0,0.25);
    background: #ffffff;
    display: block;
    margin: 0 auto;
    overflow: visible;
}
.welcome-popup.hidden { display: none; }
.welcome-gray-top {
    position: absolute;
    top: 0; left: 0;
    width: 520px;
    height: 184px;
    background: #f0f0f0;
    border-radius: 10px 10px 0 0;
}
.welcome-avatar {
    position: absolute;
    top: 24px;
    left: 30px;
    width: 75px;
    height: 75px;
    border-radius: 50%;
    object-fit: cover;
    object-position: 50% 35%;
}
.welcome-greeting {
    position: absolute;
    top: 36px;
    left: 125px;
    color: #5c604b;
    font-size: 22px;
    line-height: 22px;
    font-family: 'Tenor Sans', Helvetica;
    font-weight: 400;
    white-space: nowrap;
}
.welcome-desc {
    position: absolute;
    top: 64px;
    left: 125px;
    right: 30px;
    color: #343432;
    font-size: 12px;
    line-height: 14px;
    font-family: 'Tenor Sans', Helvetica;
    font-weight: 400;
    margin: 0;
}
.welcome-line {
    position: absolute;
    top: 115px;
    left: 30px;
    width: 460px;
    height: 1px;
    background: #c0c0c0;
}
.welcome-vk {
    position: absolute;
    top: 122px;
    left: 38px;
    width: 78px;
    height: 44px;
}
/* Общие стили social-блоков. Каждый блок позиционируется индивидуально
   через welcome-social-N (left/width — как в Figma).
   Ключевая правка: используем bottom вместо top — все три блока выравниваются
   по нижней границе строки, длинный текст растёт ВВЕРХ, а не вниз. */
.welcome-social {
    position: absolute;
    bottom: 432px;        /* popup-height 624 − bottom edge 192 = 432 */
    color: #343432;
    font-size: 14px;
    line-height: 16px;
    font-family: 'Tenor Sans', Helvetica;
    font-weight: 400;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.welcome-social-1 { left: 125px; width: 130px; }
.welcome-social-2 { left: 280px; width: 130px; }
.welcome-social-3 { left: 425px; width: 90px; }

.welcome-vk-link {
    /* Обёртка над SVG. position у самой иконки задан в .welcome-vk. */
    display: inline-block;
    line-height: 0;
    text-decoration: none;
}
.welcome-vk-link:hover .welcome-vk { opacity: 0.75; }
.welcome-heading {
    position: absolute;
    top: 204px;
    left: 30px;
    color: #343432;
    font-size: 22px;
    line-height: 26px;
    font-family: 'Tenor Sans', Helvetica;
    font-weight: 400;
    white-space: nowrap;
}
.welcome-menu {
    position: absolute;
    left: 30px;
    width: 460px;
    font-size: 14px;
    line-height: 16px;
    font-family: 'Tenor Sans', Helvetica;
    font-weight: 400;
    margin: 0;
}
.welcome-menu-1 { top: 240px; }
.welcome-menu-2 { top: 300px; }
.welcome-menu-3 { top: 360px; }
.welcome-menu .m-span {
    color: #333431;
    font-size: 14px;
    line-height: 16.8px;
}
.welcome-menu .m-title {
    color: #8ca578;
    font-size: 14px;
    line-height: 16.8px;
}
.welcome-btn {
    position: absolute;
    left: 30px;
    width: 460px;
    height: 36px;
    background: #9ec282;
    color: #343432;
    border: none;
    border-radius: 5px;
    font-family: 'Tenor Sans', Helvetica;
    font-weight: 400;
    font-size: 14px;
    cursor: pointer;
    text-align: center;
    padding: 0;
    transition: background 0.15s;
}
.welcome-btn:hover { background: #90b574; }
.welcome-btn-1 { top: 436px; }
.welcome-btn-2 { top: 478px; }
.welcome-btn-3 { top: 520px; }
.welcome-btn-4 { top: 562px; }

/* White bottom section */
.popup-body {
    padding: 16px 23px 20px;
}

/* Popups without top section */
.popup-simple {
    padding: 22px 23px;
    max-height: 450px;
    overflow-y: auto !important;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #5c604b transparent;
}

/* Адаптивная высота, без внутреннего скролла:
   страница скроллится вместе с попапом. */
#popup-dish-result,
#popup-result,
#popup-diet-start,
#popup-diet-result {
    max-height: none !important;
    overflow: visible !important;
}
#popup-dish-result::-webkit-scrollbar,
#popup-result::-webkit-scrollbar,
#popup-diet-start::-webkit-scrollbar,
#popup-diet-result::-webkit-scrollbar { display: none; }

/* Финальный экран рациона — больше воздуха между блоками,
   как в Figma (а не «скукоженный»). */
#popup-diet-result {
    padding: 26px 28px 24px !important;
}
#popup-diet-result h2 {
    font-size: 22px;
    margin: 0 0 14px;
}
#popup-diet-result h3 {
    font-size: 16px;
    margin: 18px 0 10px;
}
#popup-diet-result > p {
    margin: 0 0 12px;
    line-height: 1.5;
}
#popup-diet-result .pdf-card {
    margin-bottom: 14px;
    padding: 12px 14px;
}
#popup-diet-result .links-row {
    margin: 6px 0 12px;
}
#popup-diet-result .hint {
    margin: 4px 0 18px;
    line-height: 1.45;
}
#popup-diet-result > .btn {
    margin-bottom: 8px;
}

/* Custom scrollbar matching Figma */
.popup-simple::-webkit-scrollbar {
    width: 6px;
}
.popup-simple::-webkit-scrollbar-track {
    background: transparent;
    margin: 8px 0;
}
.popup-simple::-webkit-scrollbar-thumb {
    background: #5c604b;
    border-radius: 20px;
    min-height: 40px;
}
.popup-simple::-webkit-scrollbar-thumb:hover {
    background: #4a4e3c;
}

/* ============ Avatar Block (welcome) ============ */
.avatar-block {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
}
.avatar-img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.avatar-block .avatar-text {
    flex: 1;
    min-width: 0;
}
.avatar-greeting {
    font-size: 20px;
    font-weight: 400;
    color: var(--green-dark);
    line-height: 20px;
    margin-bottom: 6px;
}
.avatar-block .avatar-desc {
    font-size: 10px;
    color: var(--txt);
    line-height: 12px;
    margin: 0;
}

/* ============ Avatar Row (other popups) ============ */
.avatar-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

/* ============ Social Strip ============ */
.social-strip {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 10px;
    color: var(--txt);
    line-height: 11px;
}
.social-strip .social-vk {
    flex-shrink: 0;
    margin-top: 2px;
}
.social-strip span {
    white-space: nowrap;
}

/* ============ Divider ============ */
.divider { height: 1px; background: #ccc; margin: 12px 0; }
.divider.olive { background: var(--green-text); opacity: 0.5; }

/* ============ Typography ============ */
.popup h2 {
    font-size: 20px;
    font-weight: 400;
    color: var(--txt);
    margin-bottom: 10px;
    line-height: 24px;
}
.popup h3 {
    font-size: 16px;
    font-weight: 400;
    color: var(--txt);
    margin-bottom: 8px;
}
.popup p, .popup .desc {
    font-size: 14px;
    color: var(--txt);
    line-height: 16.8px;
    margin-bottom: 10px;
}
.popup .hint {
    font-size: 11px;
    color: var(--txt);
    font-style: italic;
    line-height: 13px;
    margin-bottom: 10px;
}

/* ============ Section Header ============ */
.section-header {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 10px;
}
.section-header .icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.section-header .text { font-size: 14px; color: var(--txt); line-height: 16px; }

/* ============ Menu Items ============ */
.menu-section { margin-bottom: 12px; }
.menu-item {
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
    line-height: 14px;
}
.menu-item:last-child { border-bottom: none; }
.menu-item .title {
    font-size: 14px;
    font-weight: 400;
    color: var(--green-text);
    margin-bottom: 2px;
    text-decoration: none;
}
.menu-item .desc-text {
    font-size: 14px;
    color: var(--txt);
    line-height: 14px;
}

/* ============ Buttons ============ */
.btn {
    display: block;
    width: 100%;
    padding: 10px 16px;
    height: 36px;
    border: none;
    border-radius: var(--radius-btn);
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
    font-family: var(--font);
    margin-bottom: 4px;
}
.btn:last-child { margin-bottom: 0; }

.btn-green {
    background: var(--green);
    color: var(--txt);
    border: none;
}
.btn-green:hover {
    background: var(--green-hover);
}

.btn-green-filled {
    background: var(--green);
    color: var(--txt);
    border: none;
}
.btn-green-filled:hover {
    background: var(--green-hover);
}

.btn-outline {
    background: var(--green);
    color: var(--txt);
    border: none;
}
.btn-outline:hover {
    background: var(--green-hover);
}

/* Welcome popup buttons — same green as all others */

/* ============ Input Fields ============ */
.input-group { margin-bottom: 12px; }
.input-group label {
    font-size: 10px;
    color: var(--text-light);
    display: block;
    margin-bottom: 4px;
}
.input-field {
    width: 100%;
    height: 36px;
    padding: 0 12px;
    border: 1px solid rgba(92, 96, 75, 0.5);
    border-radius: 5px;
    font-size: 14px;
    font-family: var(--font);
    font-weight: 400;
    color: var(--txt);
    transition: border-color 0.2s;
}
.input-field:focus {
    outline: none;
    border-color: var(--green);
}
.input-field::placeholder { color: var(--txt); font-size: 11px; line-height: 13px; }

/* ============ Option Cards ============ */
.option-card {
    background: var(--green);
    border-radius: 5px;
    padding: 16px 17px;
    margin-bottom: 2px;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
    min-height: 80px;
}
.option-card:hover { background: var(--green-hover); }
.option-card.selected {
    background: var(--green-hover);
    outline: 2px solid var(--green-dark);
}
.option-card .option-title {
    font-size: 14px;
    font-weight: 400;
    color: #333431;
    margin-bottom: 3px;
}
.option-card .option-desc {
    font-size: 11px;
    color: var(--txt);
    line-height: 13px;
}

/* ============ Data Summary ============ */
.data-summary {
    background: var(--green-bg);
    border-radius: var(--radius-btn);
    padding: 12px;
    margin-bottom: 12px;
}
.data-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 14px;
}
.data-row .label { color: var(--text-light); }
.data-row .value { font-weight: 400; }

/* ============ Result Block (single gray box) ============ */
.result-block {
    background: var(--grey);
    border-radius: 5px;
    box-shadow: 0px 4px 4px rgba(0,0,0,0.25);
    padding: 14px 16px;
    margin-bottom: 12px;
    font-size: 12px;
    line-height: 14px;
    color: var(--green-dark);
}

/* Legacy result-card (backward compat) */
.result-card {
    background: var(--grey);
    border-radius: 5px;
    box-shadow: 0px 4px 4px rgba(0,0,0,0.25);
    padding: 12px;
    margin-bottom: 12px;
    text-align: center;
}
.result-card .big-number {
    font-size: 24px;
    font-weight: 400;
    color: var(--green-dark);
}
.result-card .unit {
    font-size: 10px;
    color: var(--green-dark);
}

/* ============ Distribution Block (gray box with 2 columns) ============ */
.dist-block {
    background: var(--grey);
    border-radius: 5px;
    box-shadow: 0px 4px 4px rgba(0,0,0,0.25);
    padding: 14px 12px;
    margin-bottom: 12px;
    display: flex;
    gap: 0;
    font-size: 11px;
    line-height: 13px;
    color: var(--green-dark);
}
.dist-col {
    flex: 1;
    padding: 0 8px;
    white-space: nowrap;
}
.dist-col:first-child {
    border-right: 1px solid var(--green-dark);
    padding-left: 4px;
}
.dist-col:last-child {
    padding-right: 4px;
}

/* Legacy dist-table (backward compat) */
.dist-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12px;
    font-size: 9px;
    color: var(--green-dark);
}
.dist-table th {
    background: var(--green);
    color: var(--white);
    padding: 6px;
    text-align: left;
    font-weight: 400;
}
.dist-table td {
    padding: 5px 6px;
    border-bottom: 1px solid #eee;
}
.dist-table tr:nth-child(even) { background: var(--green-bg); }

/* ============ Dish Result Layout (Figma) ============ */
/* Описание + PDF-чип в одну строку (PDF справа, по высоте — как 2 строки описания) */
.dish-desc-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.dish-desc-row #dish-result-desc {
    flex: 1;
    margin: 0;
}
.dish-desc-row .pdf-card {
    flex: 0 0 auto;
    margin-bottom: 0;
    min-height: 44px;
    padding: 10px 12px;
    align-self: stretch;
}
.dish-ingredients-box {
    background: var(--grey);
    border-radius: 5px;
    padding: 8px 10px;
    font-size: 11px;
    line-height: 13px;
    color: var(--txt);
    margin-bottom: 8px;
}

/* ============ Ingredients ============ */
.ingredient-list { margin-bottom: 12px; }
.ingredient-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    border-bottom: 1px solid #e8e8e8;
    font-size: 11px;
    line-height: 13px;
}
.ingredient-row .name { flex: 1; }
.ingredient-row .amount { color: var(--txt); white-space: nowrap; }

/* ============ Disclaimer ============ */
.disclaimer-icon { color: #d9534f; margin-right: 4px; }
.disclaimer-text {
    font-size: 14px;
    color: var(--txt);
    line-height: 16.8px;
    margin-bottom: 12px;
}
.disclaimer-text a { color: var(--green-text); text-decoration: underline; }

/* ============ Price ============ */
.price-block { text-align: center; margin: 14px 0; }
.price-block .price { font-size: 22px; font-weight: 400; }
.price-block .currency { font-size: 16px; color: var(--text-light); }

/* ============ Ration List (branch 3) — вертикальный стек по Figma ============ */
.ration-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 6px 0 4px;
}
.ration-card {
    display: block;
    width: 100%;
    text-align: left;
    background: #9EC282;          /* насыщенный зелёный — как в Figma */
    border: none;
    border-radius: 10px;
    padding: 14px 16px;
    cursor: pointer;
    font: inherit;
    color: var(--txt);
    transition: background 0.15s, transform 0.05s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.ration-card:hover { background: #8fb574; }
.ration-card:active { transform: scale(0.995); }
.ration-card__title {
    font-size: 15px;
    font-weight: 500;
    color: var(--green-dark);
    line-height: 1.25;
    margin-bottom: 6px;
}
.ration-card__desc {
    font-size: 12px;
    line-height: 16px;
    color: var(--txt);
}

/* ============ Ration Detail composition ============ */
.composition-header {
    color: var(--green-dark);
    font-size: 14px;
    font-weight: 500;
    margin: 6px 0 10px;
}
.composition-section {
    margin: 0 0 12px;
}
.composition-section__title {
    color: var(--green-dark);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 3px;
}
.composition-section__body {
    font-size: 12px;
    line-height: 16px;
    color: var(--txt);
}

/* ============ PDF Card ============ */
.pdf-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--green-bg);
    border-radius: var(--radius-btn);
    padding: 8px 12px;
    margin-bottom: 8px;
}
.pdf-icon {
    background: #d9534f;
    color: white;
    font-weight: 400;
    font-size: 11px;
    padding: 4px 6px;
    border-radius: 3px;
}
.pdf-info .pdf-name { font-size: 13px; }
.pdf-info .pdf-size { font-size: 11px; color: var(--text-light); }

/* ============ Links Row ============ */
.links-row { display: flex; gap: 6px; margin-bottom: 8px; }
.link-btn {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-btn);
    text-align: center;
    font-size: 13px;
    color: var(--text-medium);
    text-decoration: none;
    transition: all 0.15s;
}
.link-btn:hover { border-color: var(--green); color: var(--green-text); }

/* Messenger buttons (VK/MAX/Telegram) */
.messenger-btn {
    border-color: var(--green);
    min-width: 110px;
    flex: 0 1 auto;
    font-size: 14px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
}

/* ============ Bottom Navigation ============ */
.bottom-nav {
    background: rgba(255,255,255,0.75);
    border-radius: var(--radius);
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 100%;
    max-width: 400px;
    margin: 8px auto 0;
}
.bottom-nav .btn {
    background: var(--white);
    color: var(--txt);
    border: 1px solid var(--green);
    font-size: 11px;
    padding: 8px 12px;
}
.bottom-nav .btn:hover {
    background: var(--green-bg);
    color: var(--green-text);
}

/* ============ Error ============ */
.error-msg {
    background: #fce4e4;
    color: #d9534f;
    padding: 6px 10px;
    border-radius: var(--radius-btn);
    font-size: 11px;
    margin-bottom: 8px;
    display: none;
}
.error-msg.show { display: block; }

/* ============ Video ============ */
.video-wrap {
    border-radius: var(--radius-btn);
    overflow: hidden;
    aspect-ratio: 16/9;
    background: #555;
    margin-bottom: 8px;
}
.video-wrap iframe { width: 100%; height: 100%; border: none; }

/* ============ Spinner ============ */
.spinner { display: none; text-align: center; padding: 14px; }
.spinner.show { display: block; }
.spinner::after {
    content: '';
    display: inline-block;
    width: 24px; height: 24px;
    border: 3px solid var(--green-light);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Responsive ============ */
@media (max-width: 480px) {
    .app-container { padding: 10px 10px 20px; }
    .popup { max-width: 100%; }
    .bottom-nav { max-width: 100%; }
    .app-header .logo-text { font-size: 16px; }
}

@media (min-width: 768px) {
    .app-container { padding-top: 30px; }
}

/* ============ Utility ============ */
.hidden { display: none !important; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-green { color: var(--green-text); }
.flex-row { display: flex; gap: 6px; }
.flex-row > * { flex: 1; }
