/* Цвета подгружаются из выбранной темы через JS: /static/themes/{green,blue,orange}.css */
:root {
    /* Fallback на случай, если тема не подгрузилась — нейтральная синяя */
    --bg: #ffffff;
    --bg-secondary: #f4f5f7;
    --text: #1a1a1a;
    --hint: #708499;
    --link: #2481cc;
    --accent: #2481cc;
    --accent-dark: #1f6cad;
    --accent-soft: #e1f0fb;
    --accent-text: #ffffff;
    --separator: rgba(0, 0, 0, 0.08);
    --danger: #d83a3a;
    --header-gradient: linear-gradient(135deg, #2481cc 0%, #4ea3e8 100%);
}

* { box-sizing: border-box; }

/* HTML-атрибут `hidden` всегда побеждает display: flex/inline у наших элементов */
[hidden] { display: none !important; }

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.45;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 560px;
    margin: 0 auto;
    padding: 0 16px 120px;
}

/* --- Шапка с градиентом темы --------------------------------------- */

.header {
    background: var(--header-gradient);
    color: #ffffff;
    padding: 24px 20px 28px;
    margin: 0 -16px 24px;
    border-radius: 0 0 24px 24px;
    text-align: center;
}
.brand {
    font-size: 13px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    opacity: 0.88;
    margin-bottom: 4px;
}
.header h1 {
    font-size: 24px;
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.2px;
}
.header .subtitle {
    margin: 6px 0 0;
    opacity: 0.92;
    font-size: 14px;
    font-weight: 400;
}

/* --- Секции (группы полей) ----------------------------------------- */

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

.section {
    border: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--accent-dark);
    padding: 0 0 6px 4px;
    margin: 0;
    letter-spacing: -0.1px;
    width: 100%;            /* legend в flex иначе занимает 0px */
}

/* --- Поле формы ---------------------------------------------------- */

.field {
    background: var(--bg-secondary);
    border-radius: 14px;
    padding: 14px 16px;
}
.field-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text);
}
.field-label.sub { margin-top: 10px; }
.field-label .hint {
    display: block;
    font-weight: 400;
    color: var(--hint);
    font-size: 12px;
    margin-top: 2px;
}

/* --- Radio --------------------------------------------------------- */

.radio-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.radio-group.vertical {
    flex-direction: column;
    gap: 6px;
}
/* Раздел «Комиссия»: 6 кнопок одинакового размера в 2 ряда (3×2) */
.radio-group.commission-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.radio-group.commission-grid .radio {
    flex: none;
    justify-content: center;
    text-align: center;
}
.radio {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: 10px;
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: border-color 0.15s, background 0.15s;
}
.radio:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.radio input { accent-color: var(--accent); flex-shrink: 0; }
.radio span { font-size: 14px; }

/* --- Chip-кнопки (часы, гости) ------------------------------------- */

.chip-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.chip {
    padding: 8px 14px;
    border-radius: 18px;
    border: 1.5px solid var(--separator);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.chip:hover { border-color: var(--accent); }
.chip.selected {
    background: var(--accent);
    color: var(--accent-text);
    border-color: var(--accent);
}

.custom-input {
    margin-top: 10px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--separator);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
}

/* --- Текстовые поля + дата + число --------------------------------- */

input[type="text"],
input[type="date"],
input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--separator);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    caret-color: var(--accent);  /* мигающий курсор цвета темы */
}
input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: var(--accent);
}

/* Убираем нативные стрелки у number-инпутов: на iOS они визуально
   маскируют курсор, плюс мы и так не используем step-увеличение */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Safari/iPad: input[type="date"] игнорирует наши размеры — приходится
   явно отключать нативный appearance и задавать стабильную высоту,
   иначе поле вылазит за пределы .field-карточки. */
input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
    min-height: 44px;            /* iOS touch-target */
    line-height: 1.2;
    text-align: left;
    -webkit-min-logical-width: calc(100% - 24px);  /* против схлопывания на iPad */
}
input[type="date"]::-webkit-date-and-time-value {
    text-align: left;
    min-height: 1.2em;
}
input[type="date"]::-webkit-calendar-picker-indicator {
    margin-left: auto;
    cursor: pointer;
}

/* --- Checkbox ------------------------------------------------------- */

.checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    cursor: pointer;
    font-size: 14px;
}
.checkbox input { accent-color: var(--accent); margin-top: 2px; flex-shrink: 0; }
.checkbox span { line-height: 1.4; }
.checkbox .info {
    font-style: normal;
    color: var(--hint);
    font-size: 12px;
    margin-left: 4px;
}
.checkbox .hint {
    display: block;
    color: var(--hint);
    font-size: 12px;
}

.loading-placeholder {
    color: var(--hint);
    font-size: 13px;
    padding: 8px 0;
}

/* --- Условные поля с лёгкой анимацией ------------------------------- */

#floor-wrapper, #opt-large-format, #opt-ai-styles {
    animation: fadeIn 0.25s ease-out;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Результат ------------------------------------------------------ */

.result {
    margin-top: 24px;
    padding: 22px 18px;
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 2px solid var(--accent-soft);
    animation: fadeIn 0.3s ease-out;
}
.result h2 {
    font-size: 18px;
    margin: 0 0 16px;
    color: var(--accent-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}
.result h2::before {
    content: "💰";
    font-size: 22px;
}
.result-items {
    list-style: none;
    margin: 0 0 14px;
    padding: 0;
}
.result-items li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--separator);
    font-size: 14px;
}
.result-items li:last-child { border-bottom: none; }
.result-items .label { color: var(--text); }
.result-items .amount {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    white-space: nowrap;
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-top: 12px;
    margin-top: 4px;
    border-top: 2px solid var(--accent);
    font-size: 16px;
    font-weight: 600;
}
.total-row strong {
    font-size: 26px;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
    letter-spacing: -0.5px;
}

/* «Итого с учётом %» — серее и чуть меньше основного итога */
.total-commission-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-top: 6px;
    font-size: 14px;
    color: var(--hint);
}
.total-commission-row strong {
    font-size: 20px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--hint);
}

.pending-note {
    margin-top: 14px;
    padding: 11px 13px;
    background: var(--accent-soft);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
}

.warnings, .notes {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.warnings .item {
    padding: 9px 11px;
    background: rgba(216, 58, 58, 0.08);
    border-left: 3px solid var(--danger);
    border-radius: 6px;
    font-size: 13px;
}
.notes .item {
    padding: 9px 11px;
    background: var(--bg);
    border-radius: 6px;
    font-size: 13px;
    color: var(--hint);
}

/* --- Кнопка «Скачать PDF» в блоке результата ------------------------ */

.pdf-button {
    display: block;
    width: 100%;
    margin-top: 16px;
    padding: 14px 18px;
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, transform 0.05s;
}
.pdf-button:hover { background: var(--accent-dark); }
.pdf-button:active { transform: scale(0.98); }
.pdf-button:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* --- Кнопка «Сбросить расчёт» — серый вариант под pdf-button ------- */
.reset-button {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 14px 18px;
    background: #9ca3af;
    color: #ffffff;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, transform 0.05s;
}
.reset-button:hover { background: #6b7280; }
.reset-button:active { transform: scale(0.98); }

/* --- Toast (всплывающее уведомление об успехе) --------------------- */

.toast {
    position: fixed;
    bottom: 16px;
    left: 16px;
    right: 16px;
    padding: 12px 16px;
    background: var(--accent);
    color: var(--accent-text);
    border-radius: 10px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    z-index: 100;
    animation: fadeIn 0.2s ease-out;
}

/* --- Баннер ошибок -------------------------------------------------- */

.error-banner {
    position: fixed;
    bottom: 16px;
    left: 16px;
    right: 16px;
    padding: 12px 16px;
    background: var(--danger);
    color: #fff;
    border-radius: 10px;
    text-align: center;
    font-size: 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    z-index: 100;
}
