/* =========================================
   КАЛЬКУЛЯТОТОР v2.0 — Единый стиль с сайтом
   ========================================= */

.calculator-v2 {
    background: #0a0a0a;
    min-height: 100vh;
    padding: 32px 0 64px;
    position: relative;
}

/* Сетка на фоне — начинается после хедера (~80px отступ сверху) */
.calculator-v2::before {
    content: "";
    position: fixed;
    top: 80px; /* Отступ под хедер */
    left: 0;
    width: 100%;
    height: calc(100% - 80px); /* Высота минус хедер */
    background-size: 40px 40px;
    background-image:
        linear-gradient(to right, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    mask-image: linear-gradient(to bottom, black 40%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 40%, transparent 100%);
    pointer-events: none;
    z-index: 0;
}

.calc-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    position: relative;
    z-index: 1;
}

/* === ШАПКА === */
.calc-header {
    text-align: left;
    margin-bottom: 32px;
    padding: 24px 0;
    border-bottom: 1px solid #1f2937;
}

.calc-header h1 {
    color: #fff;
    font-size: 1.75rem;
    font-weight: 600;
    margin: 0 0 8px;
    letter-spacing: -0.02em;
}

.calc-header p {
    color: #9ca3af;
    font-size: 0.95rem;
    margin: 0;
}

/* === ЛЕЙАУТ === */
.calculator-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 24px;
    align-items: start;
}

/* === ЛЕВАЯ КОЛОНКА === */
.services-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Категории */
.service-category {
    background: rgba(17, 24, 39, 0.6);
    border: 1px solid #1f2937;
    border-radius: 1rem;
    padding: 20px;
}

.service-category:hover {
    border-color: rgba(59, 130, 246, 0.3);
}

.category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #1f2937;
}

.category-title {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

.category-count {
    color: #6b7280;
    font-size: 0.8rem;
    background: rgba(17, 24, 39, 0.8);
    padding: 4px 10px;
    border-radius: 0.5rem;
    white-space: nowrap;
}

/* Сетка услуг */
.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

/* Карточка услуги */
.service-card-calc {
    position: relative;
    background: rgba(17, 24, 39, 0.5);
    border: 1px solid #1f2937;
    border-radius: 1rem;
    padding: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.service-card-calc:hover {
    border-color: rgba(59, 130, 246, 0.5);
    background: rgba(17, 24, 39, 0.7);
    transform: translateY(-2px);
}

.service-card-calc.selected {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.2);
}

.service-card-calc input {
    position: absolute;
    opacity: 0;
}

/* Верхняя часть карточки */
.service-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.service-card-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.service-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.service-name {
    color: #e5e7eb;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.4;
    word-wrap: break-word;
}

.service-badge {
    font-size: 0.65rem;
    padding: 3px 8px;
    border-radius: 9999px;
    font-weight: 600;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.service-badge.popular {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.service-price-block {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.service-price {
    color: #60a5fa;
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
}

.service-price.price-on-request {
    color: #6b7280;
    font-size: 0.9rem;
}

.price-period {
    color: #6b7280;
    font-size: 0.8rem;
}

/* Чекбокс */
.service-check {
    width: 20px;
    height: 20px;
    border: 1px solid #374151;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
    margin-top: 2px;
}

.service-check svg {
    width: 12px;
    height: 12px;
    color: #fff;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.service-card-calc.selected .service-check {
    background: #3b82f6;
    border-color: #3b82f6;
}

.service-card-calc.selected .service-check svg {
    opacity: 1;
}

/* === ПРАВАЯ КОЛОНКА (ИТОГИ) === */
.summary-column {
    position: relative;
}

.summary-card {
    position: sticky;
    top: 24px;
    background: rgba(17, 24, 39, 0.6);
    border: 1px solid #1f2937;
    border-radius: 1rem;
    padding: 20px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #1f2937;
}

.summary-header h3 {
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

/* Список выбранных */
.selected-list {
    max-height: 280px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.selected-list::-webkit-scrollbar {
    width: 4px;
}

.selected-list::-webkit-scrollbar-track {
    background: rgba(17, 24, 39, 0.5);
    border-radius: 2px;
}

.selected-list::-webkit-scrollbar-thumb {
    background: #374151;
    border-radius: 2px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    color: #6b7280;
    text-align: center;
}

.empty-state p {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.5;
}

.selected-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.selected-item:last-child {
    border-bottom: none;
}

.selected-info {
    flex: 1;
    min-width: 0;
}

.selected-name {
    color: #d1d5db;
    font-size: 0.85rem;
    font-weight: 500;
    display: block;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.selected-category {
    color: #6b7280;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.selected-price-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.selected-price {
    color: #60a5fa;
    font-weight: 500;
    font-size: 0.85rem;
    white-space: nowrap;
}

.remove-btn {
    width: 22px;
    height: 22px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #9ca3af;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.remove-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

/* Итог */
.total-block {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 0.75rem;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.total-label {
    color: #9ca3af;
    font-size: 0.85rem;
}

.total-price {
    color: #fff;
    font-size: 1.5rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.total-hint {
    color: #6b7280;
    font-size: 0.75rem;
    margin: 0;
    text-align: center;
    transition: color 0.2s ease;
}

/* Кнопки */
.summary-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.btn-primary-calc {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 20px;
    background: linear-gradient(90deg, #2563eb, #3b82f6);
    color: #fff;
    border: none;
    border-radius: 9999px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.3);
}

.btn-primary-calc:hover:not(:disabled) {
    box-shadow: 0 0 30px rgba(37, 99, 235, 0.5);
    transform: translateY(-2px);
}

.btn-primary-calc:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #374151;
    color: #6b7280;
    box-shadow: none;
}

.btn-primary-calc.btn-auth {
    background: linear-gradient(90deg, #7c3aed, #8b5cf6);
}

.btn-primary-calc.btn-auth:hover {
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.5);
}

.btn-secondary-calc {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background: transparent;
    color: #9ca3af;
    border: 1px solid #374151;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
}

.btn-secondary-calc:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #d1d5db;
    border-color: #6b7280;
}

/* Гарантии */
.guarantees {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.guarantee-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #6b7280;
    font-size: 0.75rem;
}

.guarantee-item svg {
    color: #3b82f6;
    flex-shrink: 0;
}

/* === МОБИЛЬНАЯ ПЛАШКА === */
.mobile-summary {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(17, 24, 39, 0.95);
    border-top: 1px solid #1f2937;
    padding: 12px 16px;
    z-index: 100;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.mobile-summary-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    max-width: 600px;
    margin: 0 auto;
}

.mobile-summary-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mobile-count {
    color: #9ca3af;
    font-size: 0.8rem;
}

.mobile-price {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
}

.mobile-summary-btn {
    padding: 10px 20px;
    background: linear-gradient(90deg, #2563eb, #3b82f6);
    color: #fff;
    border: none;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    box-shadow: 0 0 15px rgba(37, 99, 235, 0.3);
}

.mobile-summary-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #374151;
    color: #6b7280;
    box-shadow: none;
}

.mobile-summary-btn:not(:disabled):hover {
    box-shadow: 0 0 25px rgba(37, 99, 235, 0.5);
    transform: translateY(-2px);
}

/* === АДАПТИВНОСТЬ === */
@media (max-width: 1024px) {
    .calculator-layout {
        grid-template-columns: 1fr;
    }

    .summary-card {
        position: fixed;
        bottom: 64px;
        left: 16px;
        right: 16px;
        top: auto;
        max-height: 60vh;
        overflow-y: auto;
        border-radius: 1rem 1rem 0 0;
        display: none;
    }

    .mobile-summary {
        display: block;
    }

    .calculator-v2 {
        padding-bottom: 120px;
    }

    .services-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .calc-header {
        padding: 16px 0;
        margin-bottom: 20px;
    }

    .calc-header h1 {
        font-size: 1.4rem;
    }

    .calc-header p {
        font-size: 0.9rem;
    }

    .service-category {
        padding: 14px;
        border-radius: 0.75rem;
    }

    .category-title {
        font-size: 1rem;
    }

    .service-card-calc {
        padding: 14px;
        border-radius: 0.75rem;
    }

    .service-name {
        font-size: 0.9rem;
    }

    .service-price {
        font-size: 1rem;
    }
    
    /* На мобильных сетка начинается ниже */
    .calculator-v2::before {
        top: 70px;
        height: calc(100% - 70px);
    }
}

/* Светлая тема: калькулятор */
html[data-theme="light"] .calculator-v2 {
    background: #f6f8fc;
}

html[data-theme="light"] .calculator-v2::before {
    background-image:
        linear-gradient(to right, rgba(15, 23, 42, 0.06) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(15, 23, 42, 0.06) 1px, transparent 1px);
}

html[data-theme="light"] .calc-header {
    border-bottom-color: rgba(15, 23, 42, 0.16);
}

html[data-theme="light"] .calc-header h1,
html[data-theme="light"] .category-title,
html[data-theme="light"] .summary-header h3,
html[data-theme="light"] .total-price,
html[data-theme="light"] .mobile-price {
    color: #111827;
}

html[data-theme="light"] .calc-header p,
html[data-theme="light"] .category-count,
html[data-theme="light"] .selected-name,
html[data-theme="light"] .selected-category,
html[data-theme="light"] .total-label,
html[data-theme="light"] .total-hint,
html[data-theme="light"] .mobile-count,
html[data-theme="light"] .guarantee-item {
    color: #4b5563;
}

html[data-theme="light"] .service-category,
html[data-theme="light"] .service-card-calc,
html[data-theme="light"] .summary-card,
html[data-theme="light"] .total-block,
html[data-theme="light"] .mobile-summary {
    background: #ffffff;
    border-color: rgba(15, 23, 42, 0.15);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .category-header,
html[data-theme="light"] .summary-header {
    border-bottom-color: rgba(15, 23, 42, 0.12);
}

html[data-theme="light"] .service-name {
    color: #111827;
}

html[data-theme="light"] .service-price {
    color: #1d4ed8;
}

html[data-theme="light"] .service-price.price-on-request,
html[data-theme="light"] .price-period {
    color: #6b7280;
}

html[data-theme="light"] .service-check {
    border-color: #9ca3af;
}

html[data-theme="light"] .selected-item {
    border-bottom-color: rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .btn-secondary-calc {
    color: #374151;
    border-color: rgba(15, 23, 42, 0.2);
}

html[data-theme="light"] .btn-secondary-calc:hover {
    background: rgba(37, 99, 235, 0.08);
    color: #1f2937;
}