/**
 * SAT Score Calculator - Modern Responsive Design
 * Mobile-first approach with professional styling
 */

/* CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color Palette */
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --secondary-color: #64748b;
    --accent-color: #10b981;
    --background-color: #f8fafc;
    --card-background: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --error-color: #ef4444;
    --success-color: #10b981;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    --spacing-3xl: 4rem;
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    /* Transitions */
    --transition-fast: 150ms ease-in-out;
    --transition-normal: 250ms ease-in-out;
    --transition-slow: 350ms ease-in-out;
}

/* Base Typography */
body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--background-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html, body { overflow-x: hidden; }

/* Container */
.container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: var(--spacing-xl) var(--spacing-md);
    text-align: center;
    box-shadow: var(--shadow-md);
}

.title {
    font-size: var(--font-size-4xl);
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
    letter-spacing: -0.025em;
}

.subtitle {
    font-size: var(--font-size-lg);
    opacity: 0.9;
    font-weight: 400;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: var(--spacing-2xl) var(--spacing-md);
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Calculator Section */
.calculator-section {
    margin-bottom: var(--spacing-3xl);
}

.calculator-card {
    background: var(--card-background);
    border-radius: var(--radius-xl);
    padding: var(--spacing-2xl);
    box-shadow: var(--shadow-lg);
    margin-bottom: var(--spacing-xl);
    border: 1px solid var(--border-color);
}

.section-title {
    font-size: var(--font-size-2xl);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.section-description {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xl);
    font-size: var(--font-size-lg);
}

/* Form Styles */
.calculator-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xl);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.input-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: var(--font-size-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.score-range {
    font-weight: 400;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.score-input {
    padding: var(--spacing-md) var(--spacing-lg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: var(--font-size-lg);
    transition: all var(--transition-fast);
    background: var(--card-background);
}

.score-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.score-input.error {
    border-color: var(--error-color);
}

.score-input.error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.input-help {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    font-style: italic;
}

/* Button */
.calculate-button {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: var(--spacing-lg) var(--spacing-2xl);
    border-radius: var(--radius-md);
    font-size: var(--font-size-lg);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-md);
}

.calculate-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.calculate-button:active {
    transform: translateY(0);
    box-shadow: var(--shadow-md);
}

/* Results Card */
.results-card {
    background: var(--card-background);
    border-radius: var(--radius-xl);
    padding: var(--spacing-2xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    animation: fadeIn var(--transition-normal);
}

.score-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-xl);
    margin-bottom: var(--spacing-2xl);
}

.score-item {
    text-align: center;
    padding: var(--spacing-xl);
    background: var(--background-color);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
}

.score-item.total-score {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
}

.score-label {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
}

.score-value {
    font-size: var(--font-size-4xl);
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: var(--spacing-xs);
}

.score-item.total-score .score-value {
    color: white;
}

.score-range-text {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.score-item.total-score .score-range-text {
    color: rgba(255, 255, 255, 0.9);
}

/* Score Breakdown */
.score-breakdown {
    background: var(--background-color);
    padding: var(--spacing-lg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
}

.score-breakdown h3 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--border-light);
}

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

/* Instructions Section */
.instructions-section {
    background: var(--card-background);
    border-radius: var(--radius-xl);
    padding: var(--spacing-2xl);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.instructions-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-xl);
    margin-top: var(--spacing-lg);
}

.instruction-item {
    padding: var(--spacing-lg);
    background: var(--background-color);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
}

.instruction-item h3 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: var(--spacing-sm);
}

.instruction-item p {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Footer */
.footer {
    background: var(--text-primary);
    color: white;
    padding: var(--spacing-2xl) var(--spacing-md);
    margin-top: auto;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.disclaimer {
    margin-bottom: var(--spacing-xl);
}

.disclaimer h3 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--spacing-md);
}

.disclaimer p {
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.6;
}

.footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    padding-top: var(--spacing-xl);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.copyright p {
    color: rgba(255, 255, 255, 0.7);
    font-size: var(--font-size-sm);
}

.contact a {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 500;
}

.contact a:hover {
    text-decoration: underline;
}

/* Error Messages */
.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    color: var(--error-color);
}

.error-message strong {
    display: block;
    margin-bottom: var(--spacing-sm);
}

.error-message ul {
    margin-left: var(--spacing-lg);
}

.error-message li {
    margin-bottom: var(--spacing-xs);
}

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

.fade-in {
    animation: fadeIn var(--transition-normal);
}

/* Analysis Section */
.analysis-card {
    margin-top: var(--spacing-2xl);
    background: var(--background-color);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: var(--spacing-2xl);
}

.schools-section {
    margin-top: var(--spacing-2xl);
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--spacing-2xl);
    box-shadow: var(--shadow-lg);
}

.schools-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-lg);
}

.filters-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.filter-item label {
    font-weight: 600;
    color: var(--text-primary);
}

.filter-item input[type="text"],
.filter-item input[type="number"],
.filter-item select {
    padding: var(--spacing-md);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    background: var(--card-background);
}

.score-control .score-inputs {
    display: grid;
    grid-template-columns: 140px 1fr 80px;
    gap: var(--spacing-md);
    align-items: center;
}

.score-display {
    font-weight: 700;
    color: var(--primary-color);
    text-align: right;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--spacing-lg);
}

.school-card {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    background: var(--background-color);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.school-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-sm);
}

.school-name {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.school-name:hover { color: var(--primary-color); }

.chip {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    font-size: var(--font-size-xs);
    font-weight: 700;
    line-height: 1;
    border: 1px solid transparent;
}

.chip.public { color: #1d4ed8; background: #dbeafe; border-color: #bfdbfe; }
.chip.private { color: #0f766e; background: #d1fae5; border-color: #a7f3d0; }
.chip.country { color: #374151; background: #f3f4f6; border-color: #e5e7eb; }
.chip.tag.fit { color: #15803d; background: #dcfce7; border-color: #bbf7d0; }
.chip.tag.safety { color: #1d4ed8; background: #dbeafe; border-color: #bfdbfe; }
.chip.tag.reach { color: #b91c1c; background: #fee2e2; border-color: #fecaca; }

.chip.tag {
    height: 24px;
    min-width: 64px;
    padding: 0 0.6rem;
    justify-content: center;
}

.school-header .chip { margin-left: var(--spacing-sm); }
.school-meta .chip { margin-right: var(--spacing-sm); }

.school-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.no-results {
    text-align: center;
    color: var(--text-secondary);
    padding: var(--spacing-xl);
}

.school-meta {
    display: flex;
    gap: var(--spacing-md);
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.stat {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.recommend {
    display: grid;
    grid-template-columns: 100px 1fr;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.recommend-meter {
    position: relative;
    height: 8px;
    background: var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.recommend-meter.fit { background: #d1fae5; }
.recommend-meter.safety { background: #dbeafe; }
.recommend-meter.reach { background: #fee2e2; }

.recommend-fill {
    height: 100%;
    background: var(--accent-color);
}
.recommend-meter.safety .recommend-fill { background: var(--primary-light); }
.recommend-meter.reach .recommend-fill { background: #ef4444; }

.group-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin: var(--spacing-lg) 0 var(--spacing-sm);
}

.group-title {
    font-weight: 700;
    color: var(--text-primary);
}

.school-actions {
    display: flex;
    justify-content: flex-end;
}

.btn-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.btn-link:hover { text-decoration: underline; }

.load-more {
    display: flex;
    justify-content: center;
    margin-top: var(--spacing-lg);
}

.analysis-header {
    display: flex;
    justify-content: flex-start;
    margin-bottom: var(--spacing-lg);
}

.badge {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    font-weight: 700;
    font-size: var(--font-size-sm);
    letter-spacing: 0.02em;
    color: #fff;
}

.badge.basic { background: #6b7280; }
.badge.advanced { background: var(--primary-light); }
.badge.intensive { background: var(--accent-color); }
.badge.elite { background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%); }

.analysis-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
}

.analysis-col h4,
.advice h4 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
}

#rwAnalysis,
#mathAnalysis,
#adviceList {
    list-style: disc inside;
    color: var(--text-secondary);
}

#rwAnalysis li,
#mathAnalysis li,
#adviceList li {
    margin-bottom: var(--spacing-sm);
    line-height: 1.7;
}

@media (max-width: 768px) {
    .analysis-card { padding: var(--spacing-lg); }
    .analysis-grid { grid-template-columns: 1fr; }
    .score-control .score-inputs { grid-template-columns: 120px 1fr 60px; }
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Header */
    .header {
        padding: var(--spacing-lg) var(--spacing-md);
    }
    
    .title {
        font-size: var(--font-size-3xl);
    }
    
    .subtitle {
        font-size: var(--font-size-base);
    }
    
    /* Main Content */
    .main-content {
        padding: var(--spacing-lg) var(--spacing-md);
    }
    
    /* Cards */
    .calculator-card,
    .results-card,
    .instructions-section {
        padding: var(--spacing-lg);
        margin-bottom: var(--spacing-lg);
    }
    
    /* Score Results */
    .score-results {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }
    
    .score-item {
        padding: var(--spacing-lg);
    }
    
    .score-value {
        font-size: var(--font-size-3xl);
    }
    
    /* Instructions */
    .instructions-content {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }
    
    /* Footer */
    .footer {
        padding: var(--spacing-lg) var(--spacing-md);
    }
    
    .footer-bottom {
        flex-direction: column;
        text-align: center;
        gap: var(--spacing-sm);
    }
}

@media (max-width: 480px) {
    /* Extra small devices */
    .title {
        font-size: var(--font-size-2xl);
    }
    
    .section-title {
        font-size: var(--font-size-xl);
    }
    
    .score-value {
        font-size: var(--font-size-2xl);
    }
    
    .calculator-form {
        gap: var(--spacing-lg);
    }
    
    .input-label {
        font-size: var(--font-size-base);
    }
    
    .score-input {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: var(--font-size-base);
    }
    
    .calculate-button {
        padding: var(--spacing-md) var(--spacing-lg);
        font-size: var(--font-size-base);
    }

    .results-grid { grid-template-columns: 1fr; }
    .filters-bar { grid-template-columns: 1fr; width: 100%; }
    .schools-section { padding: var(--spacing-md); max-width: 100%; overflow: hidden; }
    .instructions-section { display: none; }
    .score-breakdown { display: none; }
    .analysis-card .analysis-grid { display: none; }
    .analysis-card .advice { display: none; }
    .school-header { flex-wrap: wrap; align-items: flex-start; gap: var(--spacing-xs); }
    .school-name { flex: 1 1 100%; white-space: normal; line-height: 1.4; font-size: var(--font-size-base); }
    .school-card { overflow: hidden; max-width: 100%; }
    .school-header .chip { margin-top: var(--spacing-xs); }
    .school-meta .chip.country { display: none; }
    .school-header, .school-meta { width: 100%; }
    .score-control .score-inputs { grid-template-columns: 1fr; row-gap: var(--spacing-sm); }
    .filter-item input[type="text"],
    .filter-item input[type="number"],
    .filter-item select { width: 100%; min-width: 0; }
    #schoolScoreRange { width: 100%; }
    .stat { font-size: var(--font-size-xs); }
    .chip { font-size: var(--font-size-xs); }
    .recommend { grid-template-columns: 80px 1fr; }
}

/* Print Styles */
@media print {
    .footer {
        position: static;
    }
    
    .calculate-button {
        display: none;
    }
    
    .results-card {
        break-inside: avoid;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #0000ff;
        --text-primary: #000000;
        --background-color: #ffffff;
        --card-background: #ffffff;
    }
}

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