/* =============================================
   vbClub Training — общие стили
   ============================================= */

/* CSS variables defined in theme.css (loaded before this file).
   See: assets/css/theme.css → canonical --t-* tokens + bridge to --primary, --bg, etc.
   Source of truth: config/theme.php */

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

html { font-size: 16px; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ============================================================
   Nav — ЗАЩИЩЁННЫЙ КОМПОНЕНТ
   Не менять без необходимости. Правила с !important — это
   защита от случайного переопределения модулями и страницами.
   ============================================================ */
.nav {
    background: var(--primary);
    padding: 0 16px;
    position: sticky !important;
    top: 0 !important;
    z-index: 1000 !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    isolation: isolate; /* собственный stacking context */
}
.nav__inner {
    max-width: 700px;
    margin: 0 auto;
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap !important; /* ЗАПРЕТ wrapping на десктопе */
    height: 56px;
}
.nav__logo {
    color: #fff;
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: -0.5px;
    text-decoration: none;
    white-space: nowrap;
    min-width: 0;
}
.nav__logo span { color: var(--accent); }

/* Desktop: links in a row */
.nav__links {
    display: flex;
    align-items: center;
    gap: 4px;
}
.nav__link {
    color: rgba(255,255,255,0.85);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.nav__link:hover { background: rgba(255,255,255,0.12); color: #fff; text-decoration: none; }
.nav__link--cta {
    background: var(--accent);
    color: var(--primary);
    font-weight: 700;
}
.nav__link--cta:hover { background: var(--accent-dark); color: var(--primary); }
.nav__link--admin { color: var(--accent); }
.nav__link--logout { color: rgba(255,255,255,0.6); }

/* Hamburger button — СКРЫТ на десктопе (!important = защита) */
.nav__burger {
    display: none !important;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}
.nav__burger span {
    display: block;
    width: 22px;
    height: 2px;
    background: rgba(255,255,255,0.9);
    border-radius: 2px;
    transition: transform 0.22s, opacity 0.22s;
    transform-origin: center;
}
/* Animate to X when open */
.nav__burger--open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav__burger--open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav__burger--open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---- Main container ---- */
.main { flex: 1; padding: 24px 16px 48px; }
.container {
    max-width: 520px;
    margin: 0 auto;
}
.container--wide { max-width: 700px; }

/* ---- Card ---- */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px 24px;
    border: 1px solid var(--border);
}

/* ---- Page title ---- */
.page-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 6px;
}
.page-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

/* ---- Forms ---- */
.form { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field--row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
}
.label--muted { font-weight: 400; color: var(--text-muted); }

.input,
.select,
.textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    font-family: var(--font);
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: none;
}
.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(91,63,168,0.15);
}
.input::placeholder { color: var(--text-muted); opacity: 0.7; }
.input--error { border-color: var(--danger); }

.select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235B3FA8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; cursor: pointer; }

.hint { font-size: 0.78rem; color: var(--text-muted); }
.error-msg { font-size: 0.82rem; color: var(--danger); }

/* ---- Section divider in forms ---- */
.form-section {
    border-top: 1.5px solid var(--border);
    padding-top: 16px;
    margin-top: 4px;
}
.form-section__title {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 14px;
}

/* ---- Checkbox ---- */
.checkbox-wrap {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
}
.checkbox-wrap input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 2px;
    accent-color: var(--primary);
    cursor: pointer;
}
.checkbox-wrap span {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.5;
}
.checkbox-wrap a { color: var(--primary); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 700;
    font-family: var(--font);
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.15s, background 0.15s;
    border: none;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.98); }

.btn--primary {
    background: var(--primary);
    color: #fff;
    width: 100%;
    box-shadow: 0 4px 14px rgba(91,63,168,0.3);
}
.btn--primary:hover { background: var(--primary-dark); }

.btn--accent {
    background: var(--accent);
    color: var(--primary);
    width: 100%;
    box-shadow: 0 4px 14px rgba(245,200,0,0.3);
}
.btn--accent:hover { background: var(--accent-dark); }

.btn--ghost {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--border);
}
.btn--ghost:hover { border-color: var(--primary); background: var(--bg); }

.btn--sm { padding: 8px 16px; font-size: 0.875rem; }
.btn--danger { background: var(--danger); color: #fff; }

/* ---- Alert ---- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    line-height: 1.5;
}
.alert--error   { background: #fff0f0; color: var(--danger);  border: 1px solid #fca5a5; }
.alert--success { background: #f0fff4; color: var(--success); border: 1px solid #86efac; }
.alert--info    { background: #f0f4ff; color: var(--primary); border: 1px solid #c7d2fe; }

/* ---- Tip / Memo (жёлтая плашка-подсказка) ---- */
.tip {
    background: #FFFBEA;
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    font-size: 0.85rem;
    line-height: 1.6;
    color: #4a3600;
}

/* ---- Auth pages ---- */
.auth-page { display: flex; align-items: flex-start; justify-content: center; padding: 32px 16px 48px; }
.auth-page .card { width: 100%; max-width: 440px; }

.auth-page .page-title { font-size: 1.4rem; }

.auth-divider {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: 8px 0;
}
.auth-divider a { font-weight: 600; }

/* ---- Dashboard ---- */
.programs-grid {
    display: grid;
    gap: 16px;
    margin-top: 16px;
}

.program-card {
    background: var(--card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    transition: border-color 0.15s, box-shadow 0.15s;
    text-decoration: none;
    color: var(--text);
}
.program-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
    text-decoration: none;
}
.program-card__name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
}
.program-card__desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}
.program-card__arrow { color: var(--primary); font-size: 1.25rem; flex-shrink: 0; }
.program-card--accent {
    border-color: var(--accent);
    background: #FFFBEA;
}
.program-card--accent:hover {
    border-color: var(--accent-dark);
    box-shadow: 0 2px 16px rgba(245,200,0,0.2);
}
.program-card--accent .program-card__name { color: #4a3600; }
.program-card--accent .program-card__desc { color: #7a5e00; }
.program-card--accent .program-card__arrow { color: #d4a900; }

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 32px 0;
    font-size: 0.95rem;
}
.empty-state__icon { font-size: 2.5rem; margin-bottom: 12px; }

/* ---- Profile ---- */
.profile-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}
.profile-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 800;
    flex-shrink: 0;
}
.profile-name { font-size: 1.1rem; font-weight: 700; }
.profile-email { font-size: 0.85rem; color: var(--text-muted); }

/* ---- КБЖУ summary in profile ---- */
.kbju-preview {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 8px;
}
.kbju-tile {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
    text-align: center;
}
.kbju-tile__val { font-size: 1.1rem; font-weight: 800; color: var(--primary); }
.kbju-tile__label { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

/* ---- Footer ---- */
.footer {
    background: var(--card);
    border-top: 1px solid var(--border);
    padding: 16px;
    margin-top: auto;
}
.footer__inner {
    max-width: 700px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.footer__links { display: flex; gap: 16px; }
.footer__links a { color: var(--text-muted); }
.footer__links a:hover { color: var(--primary); }

/* ---- Cookie banner ---- */
.cookie-banner {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--primary);
    color: #fff;
    padding: 14px 16px;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 0.875rem;
    z-index: 999;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.15);
}
.cookie-banner__text a { color: var(--accent); }
.cookie-banner__btn {
    background: var(--accent);
    color: var(--primary);
    border: none;
    padding: 7px 20px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    cursor: pointer;
    font-size: 0.875rem;
    white-space: nowrap;
}

/* ---- Legal pages ---- */
.legal-page .container { max-width: 680px; padding-top: 32px; }
.legal-page h1 { color: var(--primary); margin-bottom: 12px; }
.placeholder-notice {
    color: var(--text-muted);
    font-style: italic;
    padding: 24px 0;
}
.btn-back { color: var(--primary); font-weight: 600; display: inline-block; margin-top: 8px; }

/* ---- Verified badge ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 999px;
}
.badge--success { background: #dcfce7; color: var(--success); }
.badge--warn    { background: #fef9c3; color: #854d0e; }

/* ---- Responsive ---- */
@media (max-width: 480px) {
    .field--row { grid-template-columns: 1fr; }
    .card { padding: 20px 16px; }
    .kbju-preview { grid-template-columns: 1fr 1fr; }
}

/* ============================================================
   Mobile nav (hamburger) — ЗАЩИЩЁННЫЕ правила
   !important гарантирует, что модули не сломают бургер.
   ============================================================ */
@media (max-width: 720px) {
    .nav__inner {
        flex-wrap: wrap !important; /* разрешить wrap ТОЛЬКО на мобильном */
        height: auto !important;
        padding: 8px 0;
        align-items: center;
    }
    .nav__logo {
        font-size: 1.1rem;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .nav__burger {
        display: flex !important; /* ПОКАЗАТЬ бургер на мобильном */
    }
    /* Скрыть ссылки по умолчанию на мобильном */
    .nav__links {
        display: none !important;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        width: 100%;
        padding: 8px 0 12px;
        order: 3;
    }
    /* Показать при клике на бургер */
    .nav__links--open {
        display: flex !important;
    }
    .nav__link {
        font-size: 0.95rem;
        padding: 10px 12px;
        border-radius: var(--radius-sm);
        text-align: left;
    }
    .nav__link--logout {
        margin-top: 4px;
        border-top: 1px solid rgba(255,255,255,0.1);
        padding-top: 12px;
    }
    /* No-JS fallback: если JS не работает, ссылки видны */
    .nav__links:target {
        display: flex !important;
    }
}
