/**
 * Фронтенд стили калькулятора отделки (vce-peregorodki.ru)
 * UI v2: табы категорий, этапы-аккордеоны, липкий итог на мобилке.
 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&display=swap');

.ocalc-wrapper {
    font-family: 'Inter', -apple-system, 'Segoe UI', Arial, sans-serif;
    color: #2b2b2b;
    background: var(--ocalc-bg, #F5F5F0);
    padding: 24px;
    border: 1px solid #e0e0e0;
    border-radius: 2px;
    max-width: 1000px;
    margin: 0 auto;
    box-sizing: border-box;
}
.ocalc-wrapper * { box-sizing: border-box; }

/* ---------- Табы категорий ---------- */
.ocalc-tabs { display: flex; gap: 6px; margin: 0 0 14px; }
.ocalc-tab {
    flex: 1 1 0; min-width: 0;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 10px 6px;
    background: #fff;
    border: 2px solid var(--ocalc-accent, #2B2B2B);
    border-radius: 2px;
    font: inherit; color: var(--ocalc-accent, #2B2B2B);
    text-align: center; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.ocalc-tab-name { font-weight: 800; font-size: 15px; line-height: 1.15; }
.ocalc-tab-meta { font-size: 11px; font-weight: 600; color: #7A7A72; white-space: nowrap; line-height: 1.2; }
.ocalc-tab.is-active { background: var(--ocalc-accent, #2B2B2B); color: #fff; }
.ocalc-tab.is-active .ocalc-tab-meta { color: #E2DACB; }
.ocalc-tab.has-items .ocalc-tab-meta { color: #C5A059; font-weight: 700; }
.ocalc-tab.is-active.has-items .ocalc-tab-meta { color: #E8C989; }

/* ---------- Панель категории ---------- */
.ocalc-panel { display: block; }
.ocalc-panel[hidden] { display: none !important; }

.ocalc-label {
    display: block; font-size: 11px; font-weight: 700; margin: 0 0 6px;
    text-transform: uppercase; letter-spacing: 0.5px; color: #7A7A72;
}

/* ---------- Одно поле площади на категорию ---------- */
.ocalc-area {
    background: #fff;
    border: 1px solid #D8D8D0;
    padding: 12px 14px;
    margin: 0 0 12px;
}
.ocalc-area-row { display: flex; align-items: center; gap: 10px; }
.ocalc-area-unit { font-weight: 800; font-size: 16px; flex: 0 0 auto; }
.ocalc-area-hint { margin: 7px 0 0; font-size: 11px; line-height: 1.3; color: #7A7A72; }

/* ---------- Этапы-аккордеоны ---------- */
.ocalc-stage { background: #fff; border: 1px solid #D8D8D0; margin: 0 0 8px; }
.ocalc-stage-head {
    width: 100%;
    display: flex; align-items: center; gap: 10px;
    padding: 14px 14px;
    background: transparent; border: 0;
    font: inherit; color: inherit; text-align: left; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.ocalc-stage-name {
    flex: 1 1 auto; min-width: 0;
    font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.3px;
}
.ocalc-stage-meta { flex: 0 0 auto; font-size: 12px; font-weight: 600; color: #7A7A72; white-space: nowrap; }
.ocalc-stage.has-items .ocalc-stage-meta { color: #9A7B3A; font-weight: 800; }
.ocalc-stage-chev {
    flex: 0 0 auto; width: 8px; height: 8px; margin-right: 2px;
    border-right: 2px solid #2B2B2B; border-bottom: 2px solid #2B2B2B;
    transform: rotate(45deg); transition: transform .18s ease;
}
.ocalc-stage.is-open .ocalc-stage-chev { transform: rotate(-135deg); }
.ocalc-stage-body { display: none; border-top: 1px solid #EFEFE8; }
.ocalc-stage.is-open .ocalc-stage-body { display: block; }

/* ---------- Один этап: плоский список (без аккордеона) ---------- */
.ocalc-stage-flat { background: #fff; border: 1px solid #D8D8D0; margin: 0 0 8px; }
.ocalc-flat-head {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 14px 14px; border-bottom: 1px solid #EFEFE8;
}
.ocalc-flat-name {
    flex: 1 1 auto; min-width: 0;
    font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.3px;
}
.ocalc-flat-meta { flex: 0 0 auto; font-size: 12px; font-weight: 600; color: #7A7A72; white-space: nowrap; }
.ocalc-stage-flat.has-items .ocalc-flat-meta { color: #9A7B3A; font-weight: 800; }
.ocalc-flat-body .ocalc-custom-option:first-child { border-top: 0; }

/* ---------- Строка позиции ---------- */
.ocalc-custom-option { border-bottom: 1px solid #F2F2EC; }
.ocalc-custom-option:last-child { border-bottom: 0; }
.ocalc-option-row {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.ocalc-custom-option input[type="checkbox"] {
    position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none;
}
.ocalc-checkbox-ui {
    position: relative; flex: 0 0 22px; width: 22px; height: 22px;
    border: 2px solid var(--ocalc-accent, #2B2B2B); border-radius: 2px; background: #fff;
}
.ocalc-custom-option.is-checked .ocalc-checkbox-ui { background: var(--ocalc-accent, #2B2B2B); }
.ocalc-custom-option.is-checked .ocalc-checkbox-ui::after {
    content: ""; position: absolute; left: 6px; top: 2px; width: 6px; height: 11px;
    border-right: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(45deg);
}
.ocalc-option-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ocalc-option-text { font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
.ocalc-option-price { font-size: 12px; font-weight: 700; color: #7A7A72; }

/* Длина / кол-во — только у отмеченной позиции */
.ocalc-item-extra { display: none; padding: 0 14px 12px 46px; }
.ocalc-custom-option.is-checked .ocalc-item-extra { display: flex; align-items: center; gap: 10px; }
.ocalc-item-extra-label {
    flex: 0 0 auto; font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.4px; color: #7A7A72;
}

.ocalc-empty { font-size: 14px; color: #777; margin: 0; }

/* ---------- Итог ---------- */
.ocalc-total-panel {
    margin: 14px 0 0;
    background: #fff;
    border: 2px solid var(--ocalc-accent, #2B2B2B);
    padding: 14px 16px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.ocalc-total-text { display: flex; flex-direction: column; min-width: 0; }
.ocalc-total-label {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.5px; color: #7A7A72;
}
.ocalc-total-value { font-size: 26px; font-weight: 800; line-height: 1.15; white-space: nowrap; }
#ocalc-total-price { font-weight: 800; color: var(--ocalc-accent, #2B2B2B); }
.ocalc-btn-primary {
    flex: 0 0 auto;
    background: var(--ocalc-accent, #2B2B2B); color: #fff;
    border: 0; padding: 14px 22px;
    font: inherit; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px;
    cursor: pointer; white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}
.ocalc-btn-primary:hover { background: #C5A059; }

/* ---------- Модальное окно ---------- */
.ocalc-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(43, 43, 43, 0.85); z-index: 99999;
    display: flex; align-items: center; justify-content: center;
}
.ocalc-modal-content {
    background: var(--ocalc-bg, #F5F5F0); width: 100%; max-width: 500px;
    padding: 40px; position: relative; border: 1px solid #ccc;
}
.ocalc-modal-close { position: absolute; top: 15px; right: 20px; font-size: 28px; cursor: pointer; }
.ocalc-cf7-container input[type="text"],
.ocalc-cf7-container input[type="email"],
.ocalc-cf7-container input[type="tel"] { width: 100%; padding: 12px 15px; margin-bottom: 15px; border: 1px solid #ccc; }
.ocalc-cf7-container input[type="submit"] {
    width: 100%; background: var(--ocalc-accent, #2B2B2B); color: #fff; border: none;
    padding: 15px; font-weight: 700; text-transform: uppercase; cursor: pointer;
}

/* ---------- Жёсткий сброс стилей темы для инпутов калькулятора ---------- */
.ocalc-wrapper input[type="number"],
.ocalc-wrapper input[type="text"],
.ocalc-wrapper select {
    background-color: #fff !important;
    color: #2B2B2B !important;
    border: 2px solid #2B2B2B !important;
    border-radius: 2px !important;
    padding: 10px 12px !important;
    font-family: inherit !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    height: auto !important;
    outline: none !important;
}
.ocalc-wrapper input[type="number"]:focus,
.ocalc-wrapper input[type="text"]:focus,
.ocalc-wrapper select:focus {
    border-color: #C5A059 !important;
    box-shadow: 0 0 0 1px #C5A059 !important;
}
/* площадь: инпут тянется, единица измерения рядом */
.ocalc-wrapper .ocalc-area-row input[type="number"] { flex: 1 1 auto; width: auto !important; }
/* длина / кол-во в строке позиции: компактные, одинарная рамка */
.ocalc-wrapper .ocalc-custom-option .ocalc-item-extra input[type="number"] {
    width: 96px !important; flex: 0 0 96px;
    padding: 8px 10px !important;
    font-size: 16px !important;
    border-width: 1px !important;
    text-align: center;
}

/* ---------- Мобилка ---------- */
@media (max-width: 768px) {
    .ocalc-wrapper {
        padding: 12px;
        border: 0;
        border-radius: 0;
        max-width: 100%;
    }
    /* без overflow (он ломает position:sticky у полосы итога) */
    #ocalc-app { width: 100% !important; max-width: 100vw !important; }
    .ocalc-tabs { gap: 4px; margin-bottom: 10px; }
    .ocalc-tab { padding: 9px 4px; }
    .ocalc-tab-name { font-size: 14px; }
    .ocalc-tab-meta { font-size: 10px; }
    .ocalc-area { padding: 10px 12px; }
    .ocalc-area-hint { display: none; }
    .ocalc-stage-head { padding: 13px 12px; min-height: 48px; }
    .ocalc-stage-name { font-size: 13px; }
    .ocalc-stage-meta { font-size: 11px; }
    .ocalc-flat-head { padding: 13px 12px; min-height: 48px; }
    .ocalc-flat-name { font-size: 13px; }
    .ocalc-flat-meta { font-size: 11px; }
    .ocalc-option-row { padding: 11px 12px; min-height: 48px; }
    .ocalc-option-text { font-size: 13.5px; }
    .ocalc-item-extra { padding: 0 12px 11px 44px; }

    /* Липкий итог: всегда внизу экрана */
    .ocalc-total-panel {
        position: sticky;
        bottom: 0;
        z-index: 60;
        margin: 12px -12px -12px;
        padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
        border-width: 2px 0 0 0;
        box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.14);
        background: #fff;
    }
    .ocalc-total-value { font-size: 21px; }
    .ocalc-btn-primary { padding: 13px 16px; font-size: 13px; }
}

/* Десктоп: обычный блок, без липкости */
@media (min-width: 769px) {
    .ocalc-total-panel { position: static; }
}

/* iOS: события нажатий */
#ocalc-modal,
.ocalc-modal-close,
#ocalc-btn-lead,
.ocalc-tab,
.ocalc-stage-head {
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent;
}
