/* Base Styles */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #7c3aed;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
    color: var(--gray-800);
}

.tax-calculator {
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

/* Header */
.tax-header {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 1.5rem;
    text-align: center;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.header-icon {
    font-size: 1.75rem;
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.header-subtitle {
    opacity: 0.9;
    font-size: 0.9rem;
}

/* Main Layout */
.calculator-main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 500px;
}

@media (max-width: 768px) {
    .calculator-main {
        grid-template-columns: 1fr;
    }
}

/* Input Column */
.input-column {
    padding: 1.5rem;
    background: var(--gray-50);
    border-right: 1px solid var(--gray-200);
}

.input-card {
    background: white;
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.input-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.input-icon {
    font-size: 1.25rem;
}

.input-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-700);
    flex: 1;
}

.toggle-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--gray-300);
    background: white;
    border-radius: 6px;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.toggle-btn:hover {
    background: var(--gray-100);
    border-color: var(--gray-400);
}

/* Select Field */
.select-field {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.select-field:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Income Input */
.income-input {
    position: relative;
    margin-bottom: 1rem;
}

.currency {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 600;
    color: var(--gray-600);
}

.income-input input {
    width: 100%;
    padding: 0.75rem 0.75rem 0.75rem 2.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    background: white;
}

.income-input input:focus {
    outline: none;
    border-color: var(--primary);
}

.income-slider {
    margin-top: 1rem;
}

.income-slider input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--gray-300);
    outline: none;
    -webkit-appearance: none;
}

.income-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 3px solid white;
    box-shadow: var(--shadow);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* Option Groups */
.option-group {
    margin-top: 1rem;
}

.toggle-options {
    display: flex;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    overflow: hidden;
}

.toggle-option {
    flex: 1;
    text-align: center;
    padding: 0.5rem;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    border-right: 1px solid var(--gray-300);
}

.toggle-option:last-child {
    border-right: none;
}

.toggle-option.active {
    background: var(--primary);
    color: white;
}

.toggle-label {
    font-size: 0.875rem;
    font-weight: 500;
}

.radio-group {
    display: flex;
    gap: 1rem;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.radio-text {
    font-size: 0.875rem;
    color: var(--gray-700);
}

/* Advanced Panel */
.advanced-panel {
    background: white;
    border-radius: var(--radius);
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid var(--gray-300);
    box-shadow: var(--shadow);
    display: none;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.advanced-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.advanced-header h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-700);
}

.close-advanced {
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--gray-500);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.close-advanced:hover {
    background: var(--gray-100);
}

.deduction-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.deduction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--gray-100);
}

.deduction-label {
    font-size: 0.875rem;
    color: var(--gray-700);
}

.deduction-input {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.deduction-input span {
    color: var(--gray-600);
    font-weight: 500;
}

.deduction-field {
    width: 100px;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-size: 0.875rem;
    text-align: right;
}

.deduction-field:focus {
    outline: none;
    border-color: var(--primary);
}

/* Calculate Button */
.calculate-btn {
    width: 100%;
    padding: 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: background 0.2s;
    margin-top: 1rem;
}

.calculate-btn:hover {
    background: var(--primary-dark);
}

.btn-icon {
    font-size: 1.25rem;
}

/* Results Column */
.results-column {
    padding: 1.5rem;
    background: white;
    display: flex;
    flex-direction: column;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--gray-200);
}

.results-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-800);
}

.results-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--gray-300);
    background: white;
    border-radius: 6px;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--gray-100);
    border-color: var(--gray-400);
}

/* States */
.loading-state, .empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-icon {
    font-size: 3rem;
    opacity: 0.3;
    margin-bottom: 1rem;
}

.empty-state p {
    color: var(--gray-500);
}

.results-state {
    flex: 1;
}

/* Metrics */
.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.metric-card {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 1rem;
    border: 1px solid var(--gray-200);
}

.metric-card.highlight {
    background: var(--primary-light);
    border-color: var(--primary);
}

.metric-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
}

.metric-card.highlight .metric-value {
    color: var(--primary-dark);
}

/* Breakdown */
.breakdown-section {
    margin-bottom: 1.5rem;
}

.breakdown-section h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.breakdown-list {
    background: var(--gray-50);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--gray-200);
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.breakdown-item:last-child {
    border-bottom: none;
}

.breakdown-item span:first-child {
    color: var(--gray-600);
    font-size: 0.875rem;
}

.breakdown-item span:last-child {
    font-weight: 600;
    color: var(--gray-800);
}

/* Graph Section */
.graph-section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}

.graph-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.graph-header h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.graph-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.pie-chart {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    position: relative;
    overflow: hidden;
}

.graph-legend {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.legend-label {
    color: var(--gray-600);
}

/* Slabs Section */
.slabs-section {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
}

.slabs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    cursor: pointer;
}

.slabs-header h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.slabs-toggle {
    transition: transform 0.3s;
}

.slabs-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.slabs-content.expanded {
    max-height: 300px;
}

.slab-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.875rem;
}

.slab-item:last-child {
    border-bottom: none;
}

.slab-range {
    color: var(--gray-700);
}

.slab-rate {
    color: var(--primary);
    font-weight: 600;
}

.slab-amount {
    color: var(--gray-900);
    font-weight: 600;
}

/* Results Footer */
.results-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-200);
}

.disclaimer {
    font-size: 0.75rem;
    color: var(--gray-500);
    line-height: 1.4;
}

/* Responsive */
@media (max-width: 768px) {
    .tax-calculator {
        border-radius: 0;
        margin: 0;
    }
    
    .calculator-main {
        min-height: auto;
    }
    
    .input-column {
        border-right: none;
        border-bottom: 1px solid var(--gray-200);
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .graph-container {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .pie-chart {
        width: 150px;
        height: 150px;
    }
}

@media (max-width: 480px) {
    .tax-header {
        padding: 1rem;
    }
    
    .header-content {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .input-column,
    .results-column {
        padding: 1rem;
    }
    
    .input-card {
        padding: 1rem;
    }
}