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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'PingFang TC', 'Microsoft JhengHei', 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

/* Color Variables */
:root {
    --primary-color: #1e3a8a;
    --secondary-color: #dc2626;
    --accent-color: #059669;
    --text-color: #1f2937;
    --text-light: #6b7280;
    --bg-color: #ffffff;
    --bg-light: #f8f9fa;
    --border-color: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 1rem;
}

h1 {
    font-size: 2.5rem;
}

h2 {
    font-size: 2rem;
    color: var(--primary-color);
}

h3 {
    font-size: 1.5rem;
    color: var(--text-color);
}

p {
    margin-bottom: 1rem;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header and Navigation */
.header {
    background: var(--bg-color);
    box-shadow: var(--shadow);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.nav-logo h1 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin: 0;
}

.nav-menu {
    display: flex;
    gap: 2rem;
}

.nav-link {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    transition: color 0.3s ease;
    padding: 0.5rem 0;
}

.nav-link:hover {
    color: var(--primary-color);
}

.nav-toggle {
    display: none;
    flex-direction: column;
    cursor: pointer;
}

.bar {
    width: 25px;
    height: 3px;
    background-color: var(--text-color);
    margin: 3px 0;
    transition: 0.3s;
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, var(--primary-color) 0%, #3b82f6 100%);
    color: white;
    padding: 120px 0 80px;
    text-align: center;
}

.hero-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.hero-title {
    font-size: 3rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.hero-subtitle {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    opacity: 0.9;
}

.hero-description {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    opacity: 0.9;
}

.hero-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

.btn-primary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #b91c1c;
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: transparent;
    color: white;
    border: 2px solid white;
}

.btn-secondary:hover {
    background-color: white;
    color: var(--primary-color);
}

/* Sections */
.subjects-section, .calculator-section, .about-section {
    padding: 80px 0;
}

.subjects-section:nth-child(even) {
    background-color: var(--bg-light);
}

.section-title {
    text-align: center;
    margin-bottom: 1rem;
}

.section-description {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 3rem;
    font-size: 1.1rem;
}

/* Filter Controls */
.filter-controls {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    justify-content: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.filter-select {
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--bg-color);
    font-size: 1rem;
    min-width: 150px;
    transition: border-color 0.3s ease;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Table Styles */
.table-container {
    background-color: var(--bg-color);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    overflow-x: auto;
}

.cutoff-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.cutoff-table th {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
    position: relative;
}

.cutoff-table th:hover {
    background-color: #1e40af;
}

.cutoff-table th::after {
    content: '↕';
    position: absolute;
    right: 1rem;
    opacity: 0.5;
}

.cutoff-table th.sorted-asc::after {
    content: '↑';
    opacity: 1;
}

.cutoff-table th.sorted-desc::after {
    content: '↓';
    opacity: 1;
}

.cutoff-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.3s ease;
}

.cutoff-table tbody tr:hover {
    background-color: #f3f4f6;
}

.cutoff-table tbody tr:last-child td {
    border-bottom: none;
}

/* Grade Colors */
.grade-5xx { color: #dc2626; font-weight: 600; }
.grade-5x { color: #ea580c; font-weight: 600; }
.grade-5 { color: #d97706; font-weight: 600; }
.grade-4 { color: #059669; font-weight: 600; }
.grade-3 { color: #0891b2; font-weight: 600; }
.grade-2 { color: #7c3aed; font-weight: 600; }

/* Calculator Section */
.calculator-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    max-width: 800px;
    margin: 0 auto;
}

.calculator-form {
    background-color: var(--bg-color);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-color);
}

.form-select, .form-input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-select:focus, .form-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.calculator-result {
    background-color: var(--bg-color);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.result-placeholder {
    text-align: center;
    color: var(--text-light);
}

.result-content {
    text-align: center;
}

.result-grade {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.result-score {
    font-size: 1.2rem;
    color: var(--text-light);
    margin-bottom: 1rem;
}

.result-description {
    font-size: 1rem;
    color: var(--text-color);
}

/* About Section */
.about-content {
    max-width: 800px;
    margin: 0 auto;
    background-color: var(--bg-color);
    padding: 3rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.about-content h3 {
    color: var(--primary-color);
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.about-content h3:first-child {
    margin-top: 0;
}

.about-content ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.about-content li {
    margin-bottom: 0.5rem;
}

.about-content strong {
    color: var(--primary-color);
}

/* Footer */
.footer {
    background-color: var(--text-color);
    color: white;
    padding: 3rem 0 1rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section h3, .footer-section h4 {
    margin-bottom: 1rem;
    color: white;
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 0.5rem;
}

.footer-section a {
    color: #d1d5db;
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-section a:hover {
    color: white;
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid #374151;
    color: #9ca3af;
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-menu {
        position: fixed;
        left: -100%;
        top: 70px;
        flex-direction: column;
        background-color: var(--bg-color);
        width: 100%;
        text-align: center;
        transition: 0.3s;
        box-shadow: var(--shadow);
        padding: 2rem 0;
    }

    .nav-menu.active {
        left: 0;
    }

    .nav-toggle {
        display: flex;
    }

    .nav-toggle.active .bar:nth-child(2) {
        opacity: 0;
    }

    .nav-toggle.active .bar:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }

    .nav-toggle.active .bar:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg);
    }

    .hero-title {
        font-size: 2rem;
    }

    .hero-subtitle {
        font-size: 1.1rem;
    }

    .hero-buttons {
        flex-direction: column;
        align-items: center;
    }

    .btn {
        width: 200px;
    }

    .filter-controls {
        flex-direction: column;
        align-items: center;
    }

    .calculator-container {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .cutoff-table {
        font-size: 0.85rem;
    }

    .cutoff-table th,
    .cutoff-table td {
        padding: 0.75rem 0.5rem;
    }

    .about-content {
        padding: 2rem 1rem;
    }

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.75rem;
    }

    h3 {
        font-size: 1.25rem;
    }
}

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

    .nav-container {
        padding: 0 0.5rem;
    }

    .hero {
        padding: 100px 0 60px;
    }

    .hero-title {
        font-size: 1.75rem;
    }

    .subjects-section, .calculator-section, .about-section {
        padding: 60px 0;
    }

    .cutoff-table th,
    .cutoff-table td {
        padding: 0.5rem 0.25rem;
        font-size: 0.8rem;
    }

    .calculator-form,
    .calculator-result {
        padding: 1.5rem;
    }

    .about-content {
        padding: 1.5rem 0.5rem;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Smooth Transitions */
* {
    transition: color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
}

/* Focus Styles for Accessibility */
.btn:focus,
.nav-link:focus,
.filter-select:focus,
.form-select:focus,
.form-input:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Subject Page Styles */
.breadcrumb {
    background-color: var(--bg-light);
    padding: 1rem 0;
    margin-top: 70px;
    border-bottom: 1px solid var(--border-color);
}

.breadcrumb a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.breadcrumb a:hover {
    color: var(--secondary-color);
}

.breadcrumb span {
    color: var(--text-light);
}

.subject-overview {
    padding: 60px 0;
    background-color: var(--bg-color);
}

.subject-overview h2 {
    margin-bottom: 2rem;
    text-align: center;
}

.overview-content {
    max-width: 800px;
    margin: 0 auto;
}

.overview-content h3 {
    color: var(--primary-color);
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.overview-content ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.overview-content li {
    margin-bottom: 0.5rem;
}

.overview-content strong {
    color: var(--primary-color);
}

.cutoff-section {
    padding: 60px 0;
    background-color: var(--bg-light);
}

.study-tips {
    padding: 60px 0;
    background-color: var(--bg-color);
}

.tips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.tip-card {
    background-color: var(--bg-light);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease;
}

.tip-card:hover {
    transform: translateY(-5px);
}

.tip-card h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.tip-card ul {
    list-style: none;
    padding: 0;
}

.tip-card li {
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
    position: relative;
}

.tip-card li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--accent-color);
    font-weight: bold;
}

.related-subjects {
    padding: 60px 0;
    background-color: var(--bg-light);
}

.subject-links {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

.subject-link {
    display: inline-block;
    padding: 12px 24px;
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.subject-link:hover {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
}

.subject-links-section {
    margin-top: 3rem;
    text-align: center;
}

.subject-links-section h3 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

/* Navigation logo link */
.nav-logo a {
    text-decoration: none;
    color: inherit;
}

.nav-logo a:hover {
    color: var(--primary-color);
}

/* Print Styles */
@media print {
    .header,
    .hero,
    .filter-controls,
    .calculator-section,
    .footer,
    .breadcrumb {
        display: none;
    }

    .subjects-section,
    .about-section,
    .subject-overview,
    .cutoff-section,
    .study-tips,
    .related-subjects {
        padding: 0;
    }

    .table-container {
        box-shadow: none;
        border: 1px solid #ccc;
    }

    .cutoff-table th {
        background-color: #f0f0f0 !important;
        color: #000 !important;
    }
}
