/* Страница рассрочки — сайдбар, хедер, футер как на Доставка/Контакты */
.installment-page {
    background-color: #f8f9fa;
}

.installment-main-content {
    padding: 30px 0 50px;
    margin-left: 0;
    transition: margin-left 0.3s ease;
}

.sidebar-open .installment-main-content {
    margin-left: 250px;
}

.installment-container {
    max-width: 640px;
    margin: 0 auto;
}

/* Заголовок страницы — как на Доставке: белый фон, оранжевая полоса сверху */
.installment-page .page-header.installment-page-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 32px 20px;
    background: #fff;
    border-radius: 12px;
    color: #333;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.06);
    position: relative;
    overflow: hidden;
}

.installment-page .page-header.installment-page-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: #F57C00;
}

.installment-page .page-header.installment-page-header h1 {
    font-size: 2rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.installment-page .page-header.installment-page-header h1 i {
    color: #FFC107;
}

.installment-page .page-header.installment-page-header .page-subtitle {
    font-size: 1.1rem;
    color: #333;
    opacity: 0.9;
    max-width: 700px;
    margin: 0 auto;
}

/* Блок калькулятора — карточка как delivery-card */
.installment-calculator {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border: 1px solid #e0e6ed;
    overflow: hidden;
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.installment-calculator:hover {
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    border-color: #FFC107;
}

/* Табы тарифов */
.calculator-tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 2px solid #e0e6ed;
    padding: 10px;
    gap: 8px;
}

.calculator-tab {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e0e6ed;
    border-radius: 8px;
    background: #fff;
    color: #555;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.calculator-tab:hover {
    background: #fff8e1;
    border-color: #FFC107;
    color: #2c3e50;
}

.calculator-tab.active {
    background: linear-gradient(135deg, #FFD700 0%, #FFC107 100%);
    border-color: #FFC107;
    color: #2c3e50;
}

.calculator-form {
    padding: 28px 24px;
}

.calculator-layout {
    display: block;
}

.calculator-left,
.calculator-right {
    min-width: 0;
}

.calculator-row {
    margin-bottom: 24px;
}

.calculator-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 10px;
}

.calculator-input-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.calculator-range {
    flex: 1 1 100%;
    min-width: 0;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: #e0e6ed;
    border-radius: 4px;
    outline: none;
}

.calculator-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #FFC107;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.4);
    transition: transform 0.15s;
}

.calculator-range::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    background: #F57C00;
}

.calculator-range::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #FFC107;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.4);
}

.calculator-range::-moz-range-thumb:hover {
    background: #F57C00;
}

.calculator-range-values {
    display: flex;
    justify-content: space-between;
    width: 100%;
    font-size: 13px;
    color: #666;
    margin-top: 4px;
}

.calculator-range-values span:nth-child(2) {
    font-weight: 700;
    color: #2c3e50;
}

.calculator-unit {
    font-size: 14px;
    color: #666;
    margin-left: 4px;
}

/* Ручной ввод значений */
.calculator-manual-input {
    width: 140px;
    max-width: 100%;
    padding: 10px 12px;
    border: 1px solid #e0e6ed;
    border-radius: 10px;
    background: #fff;
    color: #2c3e50;
    font-size: 14px;
    font-weight: 600;
    outline: none;
    text-align: right;
}

.calculator-manual-input:focus {
    border-color: #FFC107;
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.18);
}

.calculator-manual-input--term {
    width: 110px;
}

/* Блок результатов */
.calculator-results {
    background: linear-gradient(135deg, #fffde7 0%, #fff8e1 100%);
    border-radius: 12px;
    padding: 20px;
    margin: 28px 0 24px;
    border: 1px solid #FFE082;
}

.calculator-results .result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 15px;
}

.calculator-results .result-row + .result-row {
    border-top: 1px solid #FFE082;
}

.result-label {
    color: #555;
}

.result-value {
    font-weight: 700;
    color: #2c3e50;
}

.result-total .result-value {
    font-size: 20px;
    color: #F57C00;
}

/* Условия и документы */
.calculator-conditions {
    margin-bottom: 24px;
    font-size: 14px;
    color: #555;
}

.calculator-conditions .conditions-title,
.calculator-conditions .conditions-docs {
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 8px;
}

.calculator-conditions .conditions-docs {
    margin-top: 16px;
}

.conditions-list {
    margin: 0;
    padding-left: 20px;
    list-style: none;
}

.conditions-list li {
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.conditions-list li i {
    color: #FFC107;
    font-size: 14px;
}

.calculator-actions {
    text-align: center;
}

.calculator-right .calculator-results {
    margin-top: 0;
}

.calculator-right .calculator-conditions {
    margin-top: 18px;
}

.calculator-right .calculator-actions {
    margin-top: 20px;
}

.btn-installment-apply {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    background: linear-gradient(135deg, #FFD700 0%, #FFC107 100%);
    border: 1px solid #FFC107;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-installment-apply:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.35);
    border-color: #F57C00;
}

.btn-installment-apply:active {
    transform: translateY(0);
}

@media (min-width: 900px) {
    .installment-container {
        max-width: 980px;
    }

    .calculator-layout {
        display: grid;
        grid-template-columns: 1fr 360px;
        gap: 28px;
        align-items: start;
    }

    .calculator-left .calculator-row:last-child {
        margin-bottom: 0;
    }

    .calculator-right {
        position: sticky;
        top: 16px;
    }
}

/* Блок примеров по тарифам */
.installment-examples {
    margin-top: 40px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border: 1px solid #e0e6ed;
    overflow: hidden;
    padding: 28px 24px;
}

.examples-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 20px;
    text-align: center;
}

.examples-table-wrap {
    overflow-x: auto;
    margin-bottom: 24px;
}

.examples-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.examples-table th,
.examples-table td {
    padding: 12px 14px;
    text-align: center;
    border: 1px solid #e0e6ed;
}

.examples-table thead th {
    background: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
}

.examples-table thead th:first-child {
    background: transparent;
    border-left: none;
    border-top: none;
}

.examples-table .examples-label {
    text-align: left;
    font-weight: 500;
    color: #555;
    background: #fafafa;
}

.examples-table tbody tr:hover .examples-label {
    background: #fff8e1;
}

.examples-table .examples-total td {
    font-weight: 700;
    background: #fffde7;
}

.examples-table .examples-total .examples-label {
    background: #fff8e1;
}

.examples-table .examples-total td:not(.examples-label) {
    color: #F57C00;
}

.installment-conditions-block {
    font-size: 14px;
    color: #555;
    margin-bottom: 20px;
}

.installment-conditions-block .conditions-title,
.installment-conditions-block .conditions-docs {
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 8px;
}

.installment-conditions-block .conditions-docs {
    margin-top: 16px;
}

.installment-conditions-block .conditions-list {
    margin: 0;
    padding-left: 20px;
    list-style: none;
}

.installment-conditions-block .conditions-list li {
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.installment-conditions-block .conditions-list li i {
    color: #FFC107;
    font-size: 14px;
}

.examples-actions {
    margin-top: 8px;
}

@media (max-width: 600px) {
    html,
    .installment-page {
        overflow-x: hidden;
    }

    .installment-page .main-content-wrapper,
    .installment-page .header,
    .installment-page .footer {
        overflow-x: hidden;
    }

    .installment-page .container {
        max-width: 100%;
        box-sizing: border-box;
    }

    /* На мобилке сайдбар должен быть оверлеем — не сдвигаем контент (иначе появляется скролл вправо) */
    .sidebar-open .installment-main-content {
        margin-left: 0 !important;
    }

    .installment-page .header .container,
    .installment-page .footer .container {
        width: 100% !important;
        max-width: 100% !important;
        padding-right: calc(20px + env(safe-area-inset-right)) !important;
        padding-left: calc(15px + env(safe-area-inset-left)) !important;
        box-sizing: border-box;
    }

    /* Футер: на очень узких экранах minmax(250px, 1fr) может давать overflow */
    .installment-page .footer-content {
        grid-template-columns: 1fr !important;
        gap: 24px !important;
    }

    /* Длинные строки/ссылки в футере не должны расширять экран */
    .installment-page .footer-column ul li,
    .installment-page .footer-column ul li a {
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .installment-page .footer-column ul li {
        flex-wrap: wrap;
    }

    /* Хедер: разрешаем перенос, чтобы элементы не распирали ширину */
    .installment-page .header-content {
        flex-wrap: wrap;
    }

    .installment-main-content {
        padding-left: calc(15px + env(safe-area-inset-left));
        padding-right: calc(20px + env(safe-area-inset-right));
    }

    .installment-page .page-header.installment-page-header {
        padding: 24px 16px;
    }

    .installment-page .page-header.installment-page-header h1 {
        font-size: 1.5rem;
        flex-wrap: wrap;
    }

    .calculator-form {
        padding: 20px 16px;
    }

    .calculator-tab {
        font-size: 13px;
        padding: 10px 8px;
    }
}

/* Доп. фикс переполнения для "мобильных" до 768px (хедер/футер из sidebar.php) */
@media (max-width: 768px) {
    html,
    .installment-page {
        overflow-x: hidden;
    }

    .installment-page .main-content-wrapper,
    .installment-page .header,
    .installment-page .footer {
        overflow-x: hidden;
    }

    /* На мобилке сайдбар должен быть оверлеем — не сдвигаем контент */
    .sidebar-open .installment-main-content {
        margin-left: 0 !important;
    }

    /* Контейнеры хедера/футера: ширина 100%, padding входит в ширину */
    .installment-page .header .container,
    .installment-page .footer .container {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        padding-left: calc(12px + env(safe-area-inset-left)) !important;
        padding-right: calc(12px + env(safe-area-inset-right)) !important;
    }

    /* Футер в одну колонку — чтобы minmax(250px,1fr) не распирал экран */
    .installment-page .footer-content {
        grid-template-columns: 1fr !important;
        gap: 18px !important;
    }

    /* Делаем футер компактнее по высоте на мобилке */
    .installment-page .footer {
        padding: 28px 0 14px !important;
        margin-top: 35px !important;
    }
    .installment-page .footer-column h3 {
        font-size: 18px !important;
        margin-bottom: 16px !important;
    }
    .installment-page .footer-content {
        margin-bottom: 22px !important;
    }

    /* Хедер компактнее и без распирания по горизонтали */
    .installment-page .header {
        padding: 10px 0 !important;
    }
    .installment-page .header-content {
        gap: 8px !important;
        flex-wrap: wrap !important;
    }
    .installment-page .search-bar {
        flex: 1 1 100%;
        max-width: 100% !important;
    }
    .installment-page .search-bar form {
        width: 100%;
    }
    .installment-page .search-bar input {
        width: 100%;
    }

    /* Хедер: разрешаем перенос и не даём поиску/логотипу распирать ширину */
    .installment-page .header-content {
        flex-wrap: wrap !important;
    }
    .installment-page .search-bar {
        min-width: 0;
        max-width: 100%;
    }
    .installment-page .search-bar input {
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Сайдбар (из includes/sidebar.php): страхуем от выхода за viewport на installment.php */
    .installment-page .categories-sidebar,
    .installment-page .right-sidebar {
        max-width: 100vw !important;
        box-sizing: border-box !important;
    }
}
