/* Calculator Section - Enhanced Design */
.calculator-section-light {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    padding: 80px 0;
    position: relative;
    /* Allow dropdowns to overflow outside the section when needed */
    overflow: visible;
}

.calculator-section-light::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg width="60" height="60" viewBox="0 0 60 60" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><g fill="%23e2e8f0" fill-opacity="0.3"><circle cx="30" cy="30" r="1"/></g></svg>') repeat;
    opacity: 0.5;
}

.calculator-header {
    text-align: center;
    margin-bottom: 80px;
    position: relative;
    z-index: 2;
}

/* Removed specific h2 styles to allow section-title class to take effect */

.calculator-header p {
    font-size: 1.3rem;
    color: #64748b;
    max-width: 700px;
    margin: 0 auto;
    font-weight: 400;
    line-height: 1.7;
}

.calculator-card {
    background: 
        linear-gradient(90deg, #3b82f6, #8b5cf6, #06b6d4) 0 0 / 100% 4px no-repeat,
        #ffffff;
    border-radius: 32px;
    padding: 60px;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
    border: 1px solid rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    overflow: visible; /* Исправлено для dropdown */
}

.calculator-single-column {
    margin-bottom: 50px;
}

.calculator-single-column h3 {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 40px;
    padding-bottom: 16px;
    border-bottom: 3px solid #e2e8f0;
    position: relative;
}

.calculator-single-column h3::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 80px;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    border-radius: 2px;
}

.calculator-two-columns {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 48px;
    align-items: start;
    position: relative; /* provide stacking context for children */
    overflow: visible;
}

.config-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.config-group {
    background: rgba(255, 255, 255, 0.7);
    padding: 32px 32px 16px 32px;
    border-radius: 24px;
    border: 1px solid rgba(59, 130, 246, 0.1);
    backdrop-filter: blur(10px);
    overflow: visible;
    position: relative;
    z-index: 1;
}

/* Уменьшаем отступы config-group на мобильном */
@media (max-width: 768px) {
    .config-group {
        padding: 20px 16px; /* Уменьшено с 32px */
        border-radius: 16px; /* Уменьшено с 24px */
    }
}

.config-group h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 32px;
}

@media (max-width: 1024px) {
    .calculator-two-columns {
        grid-template-columns: 1fr;
        gap: 32px;
    }
    
    .config-column {
        gap: 24px;
    }
    
    .config-group {
        padding: 24px;
    }
}

.form-group-modern {
    margin-bottom: 20px;
    position: relative;
    z-index: auto;
}

/* Активная форм-группа с открытым dropdown */
.form-group-modern.dropdown-active {
    z-index: 1001;
    position: relative;
}

.form-group-modern label {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    margin-top: 12px;
    margin-bottom: 12px;
    letter-spacing: -0.01em;
}

.custom-select {
    position: relative;
    width: 100%;
}

/* Простая иерархия z-index без конфликтов */
.custom-select {
    z-index: auto;
}

.custom-select.active {
    position: relative;
    z-index: 1000; /* согласовано с dropdown-improved.css */
}

/* Open dropdown upwards when needed */
.custom-select.open-up .select-options {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 4px;
}

/* Remove padding hacks to avoid layout shift (jerk) */
/* No extra padding applied when active */

/* Убираем сложную портальную систему - используем простое позиционирование */

.select-trigger {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 16px 20px;
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 500;
    color: #1f2937;
    cursor: pointer;
    transition: border-color 0.2s ease;
    user-select: none;
}

.select-trigger:hover {
    border-color: #3b82f6;
}

.select-trigger.active {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.select-icon {
    font-size: 20px;
    color: #3b82f6;
}

.select-text {
    flex: 1;
    text-align: left;
}

.select-arrow {
    transition: transform 0.2s ease;
    color: #6b7280;
}

.select-trigger.active .select-arrow {
    transform: rotate(180deg);
}

.select-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    margin-top: 4px;
    padding: 4px;
    z-index: 1002; /* согласовано с dropdown-improved.css */
    display: none;
    visibility: hidden;
    opacity: 0;
    transform: translateY(-8px) scale(0.95);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 20px 25px -5px rgba(0, 0, 0, 0.1),
        0 10px 10px -5px rgba(0, 0, 0, 0.04),
        0 0 0 1px rgba(0, 0, 0, 0.05);
    max-height: min(50vh, 320px);
    overflow-y: auto;
    overflow-x: hidden;
    will-change: transform, opacity;
}

.custom-select.active .select-options {
    display: block;
    visibility: visible;
    opacity: 1;
    transform: translateY(0) scale(1);
}

.select-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #ffffff !important;
    color: #1e293b;
}

.select-option:hover {
    background: rgba(59, 130, 246, 0.1) !important;
    transform: translateX(4px);
}

.select-option.selected {
    background: rgba(59, 130, 246, 0.15) !important;
    color: #3b82f6;
}

.option-icon {
    font-size: 18px;
    flex-shrink: 0;
    color: #6b7280;
}

.option-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.option-title {
    font-weight: 600;
    color: #1f2937;
    font-size: 15px;
}

.option-subtitle {
    font-size: 13px;
    color: #6b7280;
    font-weight: 400;
}

.select-option.selected .option-title {
    color: #3b82f6;
}

.select-option.selected .option-subtitle {
    color: #3b82f6;
    opacity: 0.8;
}

.select-option.selected .option-icon {
    color: #3b82f6;
}

/* Slider Styles */
.slider-container {
    position: relative;
    padding: 0 0 20px 0;
}

.form-slider {
    width: 100%;
    height: 8px;
    border-radius: 8px;
    background: linear-gradient(to right, #3b82f6 0%, #3b82f6 12.5%, #e5e7eb 12.5%, #e5e7eb 100%);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.form-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid #3b82f6;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    transition: all 0.2s ease;
}

.form-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.form-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid #3b82f6;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    transition: all 0.2s ease;
}

.form-slider::-moz-range-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
}

.slider-value {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding: 12px 16px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 12px;
    font-weight: 600;
    color: #3b82f6;
    font-size: 16px;
}

.slider-value .material-icons {
    font-size: 20px;
}

.form-select, .form-input {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    font-size: 1.1rem;
    color: #1f2937;
    background: #ffffff;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.form-select:focus, .form-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 
        0 0 0 4px rgba(59, 130, 246, 0.1),
        0 4px 12px rgba(59, 130, 246, 0.15);
    transform: translateY(-2px);
}

.form-select:hover, .form-input:hover {
    border-color: #9ca3af;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.input-hint {
    display: block;
    font-size: 0.9rem;
    color: #6b7280;
    margin-top: 8px;
    font-weight: 400;
}

.calculator-results {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    border-radius: 24px;
    padding: 40px;
    position: sticky;
    top: 32px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    height: fit-content;
    z-index: 1; /* ниже активных dropdown */
}

.calculator-results::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05), rgba(139, 92, 246, 0.05));
    border-radius: 24px;
    z-index: 1;
}

.calculator-results > * {
    position: relative;
    z-index: 2;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.results-header h3 {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1e293b;
    letter-spacing: -0.01em;
}

.results-currency {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    letter-spacing: 0.5px;
}

.results-breakdown {
    margin-bottom: 40px;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
    transition: all 0.2s ease;
}

.result-row:hover {
    background: rgba(248, 250, 252, 0.5);
    margin: 0 -20px;
    padding: 16px 20px;
    border-radius: 12px;
}

.result-row:last-child {
    border-bottom: none;
}

.result-row.highlight {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    margin: 20px -20px 0;
    padding: 24px 20px;
    border-radius: 16px;
    color: white;
    border-bottom: none;
    box-shadow: 0 8px 32px rgba(59, 130, 246, 0.3);
    transform: scale(1.02);
}

.result-row.highlight:hover {
    transform: scale(1.02);
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

.result-row.highlight .result-label,
.result-row.highlight .result-value {
    color: white;
    font-weight: 700;
    font-size: 1.3rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.result-divider {
    height: 2px;
    background: linear-gradient(90deg, transparent, #e2e8f0, transparent);
    margin: 20px 0;
    border-radius: 1px;
}

.result-label {
    color: #64748b;
    font-size: 1.05rem;
    font-weight: 500;
}

.result-value {
    color: #1e293b;
    font-weight: 700;
    font-size: 1.1rem;
}

.calculator-actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 32px;
}

.btn-calculator-primary {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    border: none;
    padding: 18px 36px;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.3);
    letter-spacing: 0.3px;
    position: relative;
    overflow: hidden;
}

.btn-calculator-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn-calculator-primary:hover::before {
    left: 100%;
}

.btn-calculator-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(59, 130, 246, 0.4);
}

.btn-calculator-primary:active {
    transform: translateY(-1px);
}

.btn-calculator-secondary {
    background: transparent;
    color: #3b82f6;
    border: 2px solid #3b82f6;
    padding: 16px 34px;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.3px;
    position: relative;
    overflow: hidden;
}

.btn-calculator-secondary::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 100%;
    background: #3b82f6;
    transition: width 0.3s ease;
    z-index: -1;
}

.btn-calculator-secondary:hover::before {
    width: 100%;
}

.btn-calculator-secondary:hover {
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.3);
}

/* Enhanced animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-group-modern {
    animation: fadeInUp 0.6s ease forwards;
}

.form-group-modern:nth-child(1) { animation-delay: 0.1s; }
.form-group-modern:nth-child(2) { animation-delay: 0.2s; }
.form-group-modern:nth-child(3) { animation-delay: 0.3s; }
.form-group-modern:nth-child(4) { animation-delay: 0.4s; }
.form-group-modern:nth-child(5) { animation-delay: 0.5s; }

/* Responsive Design */
@media (max-width: 1024px) {
    .calculator-card {
        padding: 40px;
    }
    
    .form-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 24px;
    }
}

@media (max-width: 768px) {
    .calculator-section-light {
        padding: 60px 0;
    }
    
    /* Removed responsive h2 styles to allow section-title class to take effect */
    
    .calculator-header p {
        font-size: 1.1rem;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .calculator-card {
        padding: 20px 16px; /* Уменьшено с 32px 24px */
        margin: 0 -4px; /* Небольшой выход за контейнер */
        width: calc(100% + 8px);
        box-sizing: border-box;
        border-radius: 20px; /* Уменьшено с 24px */
    }
    
    .calculator-actions {
        flex-direction: column;
        gap: 16px;
    }
    
    .btn-calculator-primary,
    .btn-calculator-secondary {
        width: 100%;
        padding: 16px 24px;
    }
    
    .result-row.highlight {
        margin: 20px -12px 0;
        padding: 20px 12px;
    }
    
    .result-row:hover {
        margin: 0 -12px;
        padding: 16px 12px;
    }
}

@media (max-width: 480px) {
    .calculator-header {
        margin-bottom: 40px; /* Уменьшено с 60px */
    }
    
    /* Removed mobile h2 styles to allow section-title class to take effect */
    
    .calculator-single-column h3 {
        font-size: 1.5rem;
    }
    
    .form-select, .form-input {
        padding: 14px 16px;
        font-size: 1rem;
    }
    
    /* Максимальная оптимизация для маленьких экранов */
    .calculator-card {
        padding: 16px 12px; /* Еще меньше отступы */
        margin: 0 -8px; /* Больший выход за контейнер */
        width: calc(100% + 16px);
        border-radius: 16px;
    }
    
    .config-group {
        padding: 16px 12px; /* Минимальные отступы */
        border-radius: 12px;
        margin-bottom: 16px; /* Уменьшенные отступы между группами */
    }
    
    .calculator-results {
        padding: 20px 16px; /* Уменьшено с 40px */
    }
}
