/* Modern CSS Reset and Base Styles */
*,
*::before,
*::after {
    box-sizing: border-box;
}

* {
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #2563eb;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    min-height: 100vh;
    font-feature-settings: 'kern' 1, 'liga' 1;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Skip Link for Accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #000;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 9999;
    font-weight: 600;
}

.skip-link:focus {
    top: 6px;
}

/* Screen Reader Only Content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Main Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
}

/* Header Styles */
header {
    text-align: center;
    margin-bottom: 3rem;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 3rem 2rem;
    box-shadow: 
        0 10px 15px -3px rgba(0, 0, 0, 0.1),
        0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(203, 213, 224, 0.3);
}

header h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 800;
    color: #1e40af;
    margin-bottom: 1rem;
    letter-spacing: -0.025em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.subtitle {
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    color: #3b82f6;
    margin-bottom: 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    font-weight: 400;
}


/* Main Layout Grid */
.input-and-chart-section {
    display: grid;
    grid-template-columns: minmax(300px, 450px) 1fr;
    gap: 2rem;
    margin-bottom: 3rem;
    align-items: start;
}

/* Input Section */
.input-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1.5rem;
    border-radius: 16px;
    box-shadow: 
        0 20px 25px -5px rgba(0, 0, 0, 0.1),
        0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: sticky;
    top: 2rem;
}

.input-section h2 {
    color: #1e40af;
    margin-bottom: 1rem;
    font-size: 1.4rem;
    font-weight: 600;
    text-align: center;
}

.input-vertical {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Input Groups */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.input-group.horizontal {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 0.75rem;
    align-items: center;
}

.label-container {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.input-label {
    font-weight: 600;
    color: #1e40af;
    font-size: 0.95rem;
    line-height: 1.4;
}

.help-text {
    display: block;
    font-weight: 400;
    color: #6366f1;
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.input-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #f7fafc;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.input-container:focus-within {
    border-color: #4299e1;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

/* Range Input Styles */
.range-input {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: #e2e8f0;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    touch-action: none;
}

.range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.range-input::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.range-input::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.range-input::-moz-range-thumb:hover {
    transform: scale(1.1);
}

.value {
    font-weight: 700;
    color: #1e40af;
    font-size: 0.95rem;
    min-width: 75px;
    text-align: right;
    background: #e2e8f0;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    font-feature-settings: 'tnum' 1;
}

.calculated-value {
    background: #dbeafe;
    border: 2px solid #3b82f6;
    font-weight: 800;
    width: 100%;
    text-align: center;
    padding: 0.6rem;
    font-size: 1.05rem;
}

/* Live Chart Section */
.live-chart-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 
        0 20px 25px -5px rgba(0, 0, 0, 0.1),
        0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 3px solid #4299e1;
    position: relative;
}

.live-chart-section h2 {
    color: #1e40af;
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
}

.chart-description {
    color: #3b82f6;
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.live-chart-container {
    position: relative;
    height: 500px;
    margin-bottom: 1.5rem;
}

.live-chart-container canvas {
    max-height: 100%;
    border-radius: 8px;
}

.chart-explanation {
    background: #f7fafc;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid #4299e1;
}

.chart-explanation h3 {
    color: #1e40af;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.chart-explanation ul {
    list-style: none;
    padding: 0;
}

.chart-explanation li {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: #3b82f6;
}

/* Results Section */
.results-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 
        0 20px 25px -5px rgba(0, 0, 0, 0.1),
        0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 3rem;
}

.results-section h2 {
    color: #1e40af;
    margin-bottom: 2rem;
    font-size: 1.75rem;
    font-weight: 600;
    text-align: center;
}

.comparison-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.comparison-grid.three-column {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.5rem;
}

.comparison-column h3 {
    color: #1e40af;
    margin-bottom: 1rem;
    text-align: center;
    padding: 1rem;
    background: linear-gradient(135deg, #edf2f7 0%, #e2e8f0 100%);
    border-radius: 12px;
    font-weight: 600;
}

.results-card {
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.5rem;
    background: #f7fafc;
    transition: all 0.2s ease;
}

.results-card:hover {
    border-color: #cbd5e0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e2e8f0;
}

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

.result-label {
    font-weight: 600;
    color: #3b82f6;
    font-size: 0.9rem;
}

.result-value {
    color: #1e40af;
    font-weight: 700;
    font-feature-settings: 'tnum' 1;
}

.positive {
    color: #38a169;
}

.negative {
    color: #e53e3e;
}

/* Chart Section */
.chart-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 
        0 20px 25px -5px rgba(0, 0, 0, 0.1),
        0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 3rem;
}

.chart-section h2 {
    color: #1e40af;
    margin-bottom: 2rem;
    font-size: 1.75rem;
    font-weight: 600;
    text-align: center;
}

.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.chart-container {
    background: #f7fafc;
    padding: 1.5rem;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    transition: all 0.2s ease;
}

.chart-container:hover {
    border-color: #cbd5e0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.chart-container h3 {
    margin: 0 0 1rem 0;
    color: #1e40af;
    font-size: 1.1rem;
    text-align: center;
    font-weight: 600;
}

.chart-wrapper {
    position: relative;
    height: 350px;
    margin-bottom: 0.75rem;
}

.chart-wrapper canvas {
    max-height: 100%;
    border-radius: 8px;
}

.chart-container .chart-description {
    font-size: 0.85rem;
    color: #6366f1;
    text-align: center;
    font-style: italic;
}

/* Footer */
.footer {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 
        0 20px 25px -5px rgba(0, 0, 0, 0.1),
        0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-top: 3rem;
    text-align: center;
}

.disclaimer {
    color: #3b82f6;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.footer-link {
    color: #4299e1;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.footer-link:hover {
    color: #3182ce;
    text-decoration: underline;
}

/* Loading Indicator */
.loading-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 
        0 20px 25px -5px rgba(0, 0, 0, 0.1),
        0 10px 10px -5px rgba(0, 0, 0, 0.04);
    z-index: 1000;
    display: none;
    align-items: center;
    gap: 1rem;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e2e8f0;
    border-top: 2px solid #4299e1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error Message */
.error-message {
    position: fixed;
    top: 2rem;
    right: 2rem;
    background: #fed7d7;
    color: #c53030;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #feb2b2;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-width: 400px;
}

.error-message h3 {
    margin-bottom: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
}

/* Focus Styles for Accessibility */
*:focus {
    outline: 2px solid #4299e1;
    outline-offset: 2px;
}

button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #4299e1;
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    body {
        background: #000;
        color: #fff;
    }

    .input-section,
    .live-chart-section,
    .results-section,
    .chart-section,
    .footer,
    header {
        background: #000;
        border: 2px solid #fff;
    }

    .badge {
        background: #fff;
        color: #000;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }
}

/* Print Styles */
@media print {
    body {
        background: #fff;
        color: #000;
    }

    .container {
        max-width: none;
        padding: 0;
    }

    .live-chart-section,
    .chart-section {
        page-break-inside: avoid;
    }

    .footer-links {
        display: none;
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .container {
        padding: 1rem;
    }

    .input-and-chart-section {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .input-section {
        position: static;
    }

    .live-chart-container {
        height: 400px;
    }

    .chart-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .comparison-grid,
    .comparison-grid.three-column {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    header {
        padding: 2rem 1rem;
    }


    .input-section,
    .live-chart-section,
    .results-section,
    .chart-section {
        padding: 1.5rem;
    }

    .live-chart-container {
        height: 350px;
    }

    .chart-wrapper {
        height: 300px;
    }

    .footer-links {
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0.5rem;
    }

    header {
        padding: 1.5rem 1rem;
        margin-bottom: 1.5rem;
    }

    .input-section,
    .live-chart-section,
    .results-section,
    .chart-section {
        padding: 1rem;
        margin-bottom: 1.5rem;
    }

    .live-chart-container {
        height: 300px;
    }

    .chart-wrapper {
        height: 250px;
    }

    .input-group.horizontal {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .slider-container {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .value {
        text-align: center;
        min-width: auto;
        padding: 0.75rem;
        font-size: 1.1rem;
    }

    .range-input {
        height: 12px;
        margin: 0.5rem 0;
    }

    .range-input::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
    }

    .range-input::-moz-range-thumb {
        width: 28px;
        height: 28px;
    }

    .input-label {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }

    .help-text {
        font-size: 0.9rem;
    }
}

/* Extra small mobile devices */
@media (max-width: 360px) {
    .container {
        padding: 0.25rem;
    }

    header {
        padding: 1rem 0.5rem;
    }

    .input-section,
    .live-chart-section,
    .results-section,
    .chart-section {
        padding: 0.75rem;
        border-radius: 12px;
    }

    .live-chart-container {
        height: 250px;
    }

    .chart-wrapper {
        height: 200px;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
    }

    header,
    .input-section,
    .live-chart-section,
    .results-section,
    .chart-section,
    .footer {
        background: rgba(26, 32, 44, 0.95);
        border-color: rgba(255, 255, 255, 0.1);
    }

    h1, h2, h3, h4, h5, h6 {
        color: #f7fafc;
    }

    .subtitle,
    .chart-description,
    .disclaimer {
        color: #cbd5e0;
    }

    .input-label {
        color: #e2e8f0;
    }

    .help-text {
        color: #a0aec0;
    }

    .input-container {
        background: #2d3748;
    }

    .results-card,
    .chart-container {
        background: #2d3748;
        border-color: #4a5568;
    }

    .result-label {
        color: #cbd5e0;
    }

    .result-value {
        color: #f7fafc;
    }

    .value {
        background: #4a5568;
        color: #f7fafc;
    }

    .chart-explanation {
        background: #2d3748;
    }

    .chart-explanation li {
        color: #cbd5e0;
    }
}