/* Variance Calculator Styles */
.variance-calculator {
    margin: 2rem 0;
}

.calculator-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* Input Panel */
.input-panel {
    background: #ffffff;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
    border: 1px solid #e5e7eb;
}

.panel-header {
    margin-bottom: 1.75rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.panel-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 0.5rem 0;
}

.panel-subtitle {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0;
    line-height: 1.5;
}

/* Input Field Wrapper */
.input-field-wrapper {
    margin-bottom: 1.5rem;
}

.input-field-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    gap: 1rem;
}

.input-field-label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.label-text {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.4;
}

.label-hint {
    font-size: 0.8125rem;
    color: #6b7280;
    line-height: 1.4;
    font-weight: 400;
}

.input-field-counter {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
    padding: 0.375rem 0.75rem;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
    flex-shrink: 0;
}

.input-field-counter #input-count {
    color: #6366f1;
    font-size: 0.875rem;
}

.counter-text {
    color: #6b7280;
    font-weight: 500;
}

.input-field-container {
    position: relative;
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    transition: all 0.2s ease;
    overflow: hidden;
}

.input-field-container:focus-within {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.variance-input {
    width: 100%;
    min-height: 180px;
    padding: 1rem 1.125rem;
    font-size: 0.9375rem;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: #1a1a1a;
    resize: vertical;
    transition: all 0.2s ease;
    line-height: 1.7;
    box-sizing: border-box;
    outline: none;
}

.variance-input:focus {
    outline: none;
}

.variance-input::placeholder {
    color: #9ca3af;
    font-style: normal;
}

/* Variance Type Selector */
.variance-type-selector {
    margin-bottom: 1.5rem;
}

.selector-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.75rem;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.radio-option {
    display: flex;
    align-items: flex-start;
    padding: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    background: #ffffff;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.radio-option:hover {
    border-color: #6366f1;
    background: #f8f9ff;
}

.radio-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.radio-option input[type="radio"]:checked + .radio-custom {
    background: #6366f1;
    border-color: #6366f1;
}

.radio-option input[type="radio"]:checked + .radio-custom::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: #ffffff;
    border-radius: 50%;
}

.radio-option input[type="radio"]:checked ~ .radio-content {
    color: #6366f1;
}

.radio-option input[type="radio"]:checked {
    border-color: #6366f1;
}

.radio-custom {
    width: 20px;
    height: 20px;
    border: 2px solid #adb5bd;
    border-radius: 50%;
    margin-right: 0.75rem;
    margin-top: 0.125rem;
    flex-shrink: 0;
    transition: all 0.3s ease;
    position: relative;
}

.radio-content {
    flex: 1;
    transition: color 0.3s ease;
}

.radio-title {
    display: block;
    font-weight: 600;
    font-size: 0.95rem;
    color: #1a1a1a;
    margin-bottom: 0.25rem;
}

.radio-formula {
    display: block;
    font-size: 0.8rem;
    color: #6c757d;
}

.radio-option input[type="radio"]:checked ~ .radio-content .radio-title {
    color: #6366f1;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-primary,
.btn-secondary {
    flex: 1;
    min-width: 140px;
    padding: 0.875rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

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

.btn-secondary {
    background: #ffffff;
    color: #495057;
    border: 2px solid #e0e0e0;
}

.btn-secondary:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
}

.btn-icon {
    font-size: 1.1rem;
}

/* Error Alert */
.error-alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 10px;
    margin-top: 1rem;
    color: #856404;
}

.alert-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.alert-message {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Results Panel */
.results-panel {
    background: #ffffff;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
    border: 1px solid #e5e7eb;
    min-height: 400px;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 1rem;
    min-height: 300px;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 0.75rem 0;
}

.empty-description {
    font-size: 0.95rem;
    color: #6c757d;
    max-width: 400px;
    margin: 0;
    line-height: 1.6;
}

/* Results Content */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.results-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0;
}

.variance-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #ffffff;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.badge-label {
    opacity: 0.9;
}

.badge-value {
    font-weight: 700;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.metric-card {
    background: #ffffff;
    border: 2px solid #e0e0e0;
    border-radius: 16px;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.metric-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    border-color: #6366f1;
}

.metric-card.primary {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-color: #6366f1;
    color: #ffffff;
}

.metric-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.metric-icon {
    font-size: 1.25rem;
    font-weight: 700;
}

.metric-label {
    font-size: 0.85rem;
    font-weight: 600;
    opacity: 0.8;
}

.metric-card.primary .metric-label {
    opacity: 0.95;
}

.metric-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1a1a1a;
    word-break: break-all;
}

.metric-card.primary .metric-value {
    color: #ffffff;
}

/* Calculation Details */
.calculation-details {
    margin-top: 2rem;
}

.detail-section {
    background: #ffffff;
    border: 2px solid #e0e0e0;
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.detail-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 1rem 0;
}

.formula-display {
    font-size: 1.25rem;
    color: #6366f1;
    font-weight: 600;
    padding: 1rem;
    background: #f8f9ff;
    border-radius: 10px;
    text-align: center;
}

.steps-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.step-item {
    padding: 0.75rem;
    background: #f8f9fa;
    border-left: 3px solid #6366f1;
    border-radius: 6px;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #495057;
}

.step-item:first-child {
    font-weight: 600;
    color: #1a1a1a;
}

.step-item code {
    background: #e9ecef;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.85em;
}

/* Mobile Responsive */
@media (min-width: 768px) {
    .calculator-container {
        grid-template-columns: 1fr 1fr;
    }
    
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 767px) {
    .input-panel,
    .results-panel {
        padding: 1.25rem;
    }
    
    .panel-header {
        margin-bottom: 1.5rem;
        padding-bottom: 0.75rem;
    }
    
    .panel-title {
        font-size: 1.125rem;
    }
    
    .panel-subtitle {
        font-size: 0.8125rem;
    }
    
    .input-field-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .input-field-counter {
        align-self: flex-start;
    }
    
    .variance-input {
        min-height: 160px;
        padding: 0.875rem 1rem;
        font-size: 0.875rem;
    }
    
    .label-text {
        font-size: 0.875rem;
    }
    
    .label-hint {
        font-size: 0.75rem;
    }
    
    .input-field-counter {
        font-size: 0.75rem;
        padding: 0.3125rem 0.625rem;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .btn-primary,
    .btn-secondary {
        width: 100%;
    }
    
    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .variance-badge {
        align-self: flex-start;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .metric-value {
        font-size: 1.5rem;
    }
    
    .formula-display {
        font-size: 1rem;
    }
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.results-content {
    animation: fadeIn 0.4s ease-out;
}

.metric-card {
    animation: fadeIn 0.4s ease-out;
}

.metric-card:nth-child(1) { animation-delay: 0.1s; }
.metric-card:nth-child(2) { animation-delay: 0.2s; }
.metric-card:nth-child(3) { animation-delay: 0.3s; }
.metric-card:nth-child(4) { animation-delay: 0.4s; }
