/* ============================================================
   ОБЩИЕ СТИЛИ ДЛЯ ВСЕХ СТРАНИЦ САЙТА
   ============================================================ */

/* ---------- Reset и base ---------- */

* {
    box-sizing: border-box;
    font-family: system-ui, 'Segoe UI', Roboto, sans-serif;
}

body {
    background: #f4f7fc;
    margin: 20px;
    display: flex;
    justify-content: center;
}

/* ---------- Основной контейнер страницы ---------- */

.container {
    max-width: 1400px;
    width: 100%;
    background: white;
    padding: 24px 28px;
    border-radius: 28px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
}

/* ---------- Loading / Main containers ---------- */

#loadingContainer.hidden {
    display: none;
}

#mainContainer {
    display: none;
}

#mainContainer.visible {
    display: block;
}

/* ---------- Шапка страницы ---------- */

.subhead {
    color: #475569;
    margin-bottom: 24px;
    border-bottom: 1px solid #e9edf2;
    padding-bottom: 16px;
}

.subhead-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}

.subhead-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.subhead-langs {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}

.subhead-bottom {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

h1 {
    font-weight: 600;
    font-size: 1.8rem;
    color: #1e293b;
    margin: 0;
    letter-spacing: -0.02em;
}


/* ---------- Бейджи статусов ---------- */

.badge {
    display: inline-block;
    padding: 2px 14px;
    border-radius: 30px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
}

.badge-default {
    background: #f1f5f9;
    color: #475569;
}

.badge-completed {
    background: #fee2e2;
    color: #991b1b;
}

.badge-active {
    background: #dcfce7;
    color: #166534;
}

.badge-upcoming {
    background: #fef9c3;
    color: #854d0e;
}

.badge-accent {
    background: #0b3b5c;
    color: white;
    font-size: 0.7rem;
}

.badge-warning {
    background: #f59e0b;
    color: white;
    font-size: 0.7rem;
}

/* ---------- Языковой переключатель ---------- */

.lang-btn {
    background: transparent;
    border: 1px solid #ccd7e6;
    border-radius: 30px;
    padding: 4px 14px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: 0.15s;
    color: #475569;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.lang-btn:hover {
    background: #f1f5f9;
    border-color: #0b3b5c;
}

.lang-btn.active {
    background: #0b3b5c;
    border-color: #0b3b5c;
    color: white;
}

.lang-btn img {
    border-radius: 2px;
}

/* ---------- Кнопки ---------- */

.home-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: #475569;
    font-weight: 500;
    font-size: 0.85rem;
    padding: 6px 14px;
    border-radius: 30px;
    border: 1px solid #ccd7e6;
    background: transparent;
    transition: 0.15s;
    white-space: nowrap;
    cursor: pointer;
    font-family: inherit;
}

.home-btn:hover {
    background: #f1f5f9;
    border-color: #0b3b5c;
    color: #0b3b5c;
}

.home-btn:active {
    transform: scale(0.97);
}

.home-btn.saved {
    background: #dcfce7;
    border-color: #1e8b3c;
    color: #166534;
}

.calc-btn {
    background: #1e8b3c;
    color: white;
    border: none;
    padding: 10px 32px;
    border-radius: 40px;
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: 0.15s;
    box-shadow: 0 2px 6px rgba(30, 139, 60, 0.2);
}

.calc-btn:hover {
    background: #26a04a;
    transform: scale(1.01);
}

.recalc-btn {
    background: #0b3b5c;
    color: white;
    border: none;
    padding: 6px 20px;
    border-radius: 30px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: 0.15s;
    font-weight: 500;
}

.recalc-btn:hover {
    background: #1a4a6e;
    transform: scale(1.02);
}

/* ---------- Секции (общий каркас заголовка) ---------- */

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e9edf2;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.section-header .section-title {
    margin-bottom: 0;
}

.section-title .count {
    font-size: 0.75rem;
    font-weight: 400;
    color: #94a3b8;
    background: #f1f5f9;
    padding: 0 10px;
    border-radius: 30px;
}

/* ---------- Сообщения ---------- */

.loading-msg {
    text-align: center;
    padding: 40px;
    color: #94a3b8;
    font-size: 1.1rem;
}

.loading-error {
    text-align: center;
    padding: 40px;
    color: #b91c1c;
    font-size: 1.1rem;
    background: #fef2f2;
    border-radius: 12px;
    border: 1px solid #fecaca;
}

.error-msg {
    background: #fef2f2;
    color: #b91c1c;
    padding: 12px 18px;
    border-radius: 12px;
    border: 1px solid #fecaca;
    font-size: 0.9rem;
}

.empty-msg {
    color: #94a3b8;
    font-size: 0.9rem;
    text-align: center;
    padding: 20px 0;
}

/* ---------- Тултипы ---------- */

.tooltip {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #0f172a;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 400;
    text-align: left;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    line-height: 1.6;
    white-space: normal;
    pointer-events: none;
}

.tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: #0f172a;
}

.tooltip strong {
    color: #60a5fa;
}

/* Хост: кнопка-действие с тултипом */
.tooltip-btn {
    position: relative;
}

.tooltip-btn .tooltip {
    width: 360px;
}

.tooltip-btn:hover .tooltip {
    display: block;
}

/* Хост: иконка "?" с тултипом */
.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #e9edf2;
    color: #475569;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: help;
    transition: 0.15s;
    position: relative;
    margin-left: 4px;
    z-index: 100;
}

.help-icon:hover {
    background: #0b3b5c;
    color: white;
    transform: scale(1.1);
}

.help-icon .tooltip {
    width: 460px;
}

.help-icon:hover .tooltip {
    display: block;
}

.help-icon .tooltip .tooltip-handle {
    display: inline-block;
    font-size: 1.1rem;
    padding: 0 4px;
}

/* Модификатор: значок-предупреждение (красный) */
.help-icon.help-icon-warning {
    background: #fee2e2;
    color: #b91c1c;
}

.help-icon.help-icon-warning:hover {
    background: #b91c1c;
    color: white;
}

/* ---------- Стили внутри тултипов ---------- */

.tooltip-warning-title {
    color: #fca5a5;
}

.tooltip-divider {
    display: block;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    margin: 8px 0;
}

/* ---------- Адаптив ---------- */

@media (max-width: 700px) {
    .container {
        padding: 20px 16px 28px;
    }
    h1 {
        font-size: 1.4rem;
    }
    .tooltip-btn .tooltip,
    .help-icon .tooltip {
        width: 220px;
        left: auto;
        right: -20px;
        transform: none;
    }
    .tooltip-btn .tooltip::before,
    .help-icon .tooltip::before {
        left: auto;
        right: 30px;
        transform: none;
    }
}

@media (max-width: 600px) {
    .home-btn {
        font-size: 0.75rem;
        padding: 4px 10px;
    }
}

@media (max-width: 400px) {
    .lang-btn {
        font-size: 0.7rem;
        padding: 3px 10px;
    }

    .lang-btn img {
        width: 16px;
        height: 12px;
    }
}

/* ---------- Строки формы (лейбл + поле + единица) ---------- */

.form-rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-row {
    display: grid;
    grid-template-columns: 320px 120px 1fr;
    gap: 12px;
    align-items: center;
}

.form-row > label {
    font-size: 0.85rem;
    color: #475569;
}

.form-row > .unit {
    font-size: 0.85rem;
    color: #475569;
}

@media (max-width: 700px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}
