/* assets/css/styles.css */

body {
    font-family: 'Roboto', Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
    color: #444;
    line-height: 1.6;
}

.container {
    text-align: center;
    margin: 20px auto;
    max-width: 850px;
    background-color: #fff;
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

h2 {
    color: #2c3e50;
    margin-top: 0;
    font-weight: 500;
    position: relative;
    padding-bottom: 10px;
}

h2:after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 3px;
    background: #3498db;
    border-radius: 3px;
}

.data-source {
    font-size: 14px;
    color: #888;
    margin: 5px 0 20px;
}

/* --- Desktop Tab Styles --- */
.tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: none;
    justify-content: center;
    flex-wrap: wrap; /* Allow wrapping even on desktop if needed */
    gap: 8px;
}

.tab {
    padding: 12px 25px;
    cursor: pointer;
    background-color: #ecf0f1;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    color: #7f8c8d;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    flex-grow: 0; /* Don't grow by default */
    flex-shrink: 1; /* Allow shrinking */
    text-align: center; /* Ensure text is centered */
}

.tab:hover {
    background-color: #e3e8ea;
    transform: translateY(-2px);
}

.tab.active {
    background-color: #3498db;
    color: white;
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.2);
}

.tab-content {
    display: none;
    background-color: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.5s;
}

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

/* --- Input Styles (Unchanged) --- */
.input-group {
    margin: 5px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
    text-align: center;
}

input, select {
    padding: 12px 15px;
    margin: 5px 0;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    width: 100%;
    max-width: 200px;
    box-sizing: border-box;
    transition: all 0.3s;
    font-size: 15px;
    color: #333;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

input:focus, select:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

input::placeholder {
    color: #aaa;
}

.range-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.range-separator {
    color: #888;
    font-weight: bold;
}

/* --- Button Styles (Unchanged) --- */
button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 12px 25px;
    margin: 20px 5px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    box-shadow: 0 3px 8px rgba(52, 152, 219, 0.2);
    transition: all 0.3s;
    max-width: 200px;
    width: auto;
}

button:hover {
    transform: translateY(-2px);
    background-color: #2980b9;
    box-shadow: 0 5px 12px rgba(52, 152, 219, 0.3);
}

#exportBtn {
    background-color: #9b59b6;
}

#exportBtn:hover {
    background-color: #8e44ad;
}

/* --- Optional Fields Styles (Unchanged) --- */
.optional-fields {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    margin: 15px 0;
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05);
}

.optional-fields .input-group {
    flex: 1 1 200px;
    margin: 5px 10px;
}

.optional-title {
    width: 100%;
    text-align: left;
    margin-bottom: 10px;
    color: #7f8c8d;
    font-weight: 500;
}

/* --- Status & Loading Styles (Unchanged) --- */
#status {
    margin: 15px 0;
    padding: 10px;
    font-weight: 500;
    border-radius: 8px;
    background-color: #f8f9fa;
    display: inline-block;
    min-width: 200px;
    transition: all 0.3s ease;
}

.loading {
    display: inline-block;
    position: relative;
    width: 20px;
    height: 20px;
    margin-right: 10px;
}

.loading:after {
    content: " ";
    display: block;
    border-radius: 50%;
    width: 100%;
    height: 100%;
    border: 3px solid;
    border-color: #3498db transparent #3498db transparent;
    animation: loading 1.2s linear infinite;
}

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

/* --- Table Styles (Unchanged) --- */
table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    margin: 25px auto;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
    border: 1px solid #e0e0e0;
}

th, td {
    padding: 7px;
    text-align: center;
    border: 1px solid #e0e0e0;
}

th {
    background-color: #3498db;
    color: white;
    font-weight: 500;
    letter-spacing: 0.5px;
    border-color: #2980b9;
    cursor: pointer;
}

#resultTable th:nth-child(3) {
    min-width: 250px;
}


tr:nth-child(odd) {
    background-color: #f0f7fb;
}

tr:nth-child(even) {
    background-color: #f8f9fa;
}

tr:hover {
    background-color: #e9f7ef;
}

.major-link {
    color: #3498db;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.3s;
    position: relative;
}

.major-link:hover {
    color: #2980b9;
}

.major-link:after {
    content: '';
    position: absolute;
    width: 100%;
    height: 2px;
    bottom: -2px;
    left: 0;
    background-color: #3498db;
    transform: scaleX(0);
    transition: transform 0.3s;
}

.major-link:hover:after {
    transform: scaleX(1);
}


.empty-result {
    padding: 30px 20px;
    color: #7f8c8d;
    background-color: #f8f9fa;
    border-radius: 8px;
    margin: 20px 0;
    text-align: center;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05);
}

/* --- Modal Styles (Unchanged) --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: white;
    padding: 25px;
    border-radius: 10px;
    max-width: 500px;
    width: 80%;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    position: relative;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    border: none;
    background: none;
    font-size: 24px;
    cursor: pointer;
    color: #7f8c8d;
    padding: 0;
    width: 30px;
    height: 30px;
    box-shadow: none;
    line-height: 1;
}

.close-btn:hover {
    color: #e74c3c;
}


.modal-title {
    margin: 0 0 5px 0;
    color: #2c3e50;
    font-size: 20px;
    padding-right: 30px;
}

.modal-subtitle {
    color: #7f8c8d;
    margin-bottom: 20px;
}

.modal-detail-title {
    font-weight: 500;
    margin-bottom: 10px;
    color: #2c3e50;
}

.modal-details {
    background-color: #f0f7fb;
    border-left: 5px solid #3498db;
    padding: 15px;
    border-radius: 0 8px 8px 0;
    white-space: pre-line;
    max-height: 200px;
    overflow-y: auto;
    font-size: 16px;
    color: #2c3e50;
    margin-bottom: 10px;
}

.modal-loading {
    color: #3498db;
}

.modal-error {
    color: #e74c3c;
}

/* --- Rank/Score Span Styles (Unchanged) --- */
.rank-score {
    display: inline-block;
    margin: 3px 5px;
    padding: 4px 8px;
    background-color: #f0f7fb;
    border-radius: 4px;
    border-left: 3px solid #3498db;
    white-space: nowrap;
}

.year {
    font-weight: bold;
    color: #2c3e50;
}

.rank {
    color: #e74c3c;
    font-weight: bold;
}

.score {
    color: #26A69A;
    font-weight: bold;
}


/* ================================== */
/* === Checkbox Group Styling (Unchanged) === */
/* ================================== */
.year-selection .checkbox-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 15px;
    padding-top: 5px;
    width: 100%;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.year-selection .checkbox-group label {
    display: inline-flex;
    align-items: center;
    margin-bottom: 0;
    margin-right: 0;
    font-weight: normal;
    cursor: pointer;
    text-align: left;
    flex-grow: 0;
    flex-shrink: 0;
}

.year-selection .checkbox-group input[type="checkbox"] {
    margin-right: 6px;
    width: 1.2em;
    height: 1.2em;
    flex-shrink: 0;
    vertical-align: middle;
    padding: 0;
    max-width: none;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: #fff;
    border: 2px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    outline: none;
    transition: background-color 0.2s, border-color 0.2s;
}

.year-selection .checkbox-group input[type="checkbox"]:checked {
    background-color: #3498db;
    border-color: #3498db;
}

.year-selection .checkbox-group input[type="checkbox"]:checked::before {
    content: '\2714';
    font-size: 0.9em;
    color: white;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    line-height: 1;
}


/* ================================== */
/* === Responsive Design === */
/* ================================== */
@media (max-width: 768px) {
    .container {
        padding: 15px;
        margin: 10px;
        border-radius: 8px;
    }

    /* Ensure inputs/buttons take full width on mobile */
    input, select, button {
        width: 100%;
        max-width: none;
    }

    button {
        margin: 10px 0;
    }

    /* --- MODIFIED: Mobile Tab Layout --- */
    .tabs {
        /* Ensure flex and wrap */
        display: flex;
        flex-wrap: wrap;
        /* Justify content and gap remain */
        justify-content: center;
        gap: 8px;
        margin-bottom: 5px; /* Adjust margin if needed */
    }

    .tab {
        /* --- Force two items per row --- */
        flex-grow: 0; /* Do not allow growing */
        flex-shrink: 0; /* Do not allow shrinking */
        flex-basis: calc(50% - 4px); /* 50% width minus half the gap */
        box-sizing: border-box; /* Include padding/border in the width */

        /* Adjust padding for smaller buttons if needed */
        padding: 10px 5px;
        font-size: 14px; /* Slightly smaller text */
        margin-bottom: 0; /* Remove margin-bottom if it existed */
        text-align: center; /* Ensure text is centered */
    }
    /* --- End of Mobile Tab Layout Modification --- */


    table {
        font-size: 14px;
        overflow-x: auto;
        display: block;
    }

    th, td {
        padding: 4px 4px;
    }

    .combined-column {
        white-space: normal;
        word-break: break-all;
    }

    .optional-fields {
        flex-direction: column;
        padding: 10px;
    }

    .optional-fields .input-group {
        flex: none;
        width: 100%;
        margin: 5px 0;
    }

    /* --- Range Input Stacking (Unchanged) --- */
    .range-inputs {
        flex-direction: column;
        align-items: stretch;
        gap: 1px;
    }

    .range-separator {
        align-self: center;
        margin: 5px 0;
    }

    /* --- Modal (Unchanged) --- */
    .modal-content {
        width: 90%;
        padding: 15px;
    }

    .close-btn {
        top: 10px;
        right: 10px;
    }

    /* --- Table Min Widths (Unchanged) --- */
    #resultTable th:nth-child(3),
    #resultTable td:nth-child(3) {
        min-width: 150px;
        word-break: break-word;
    }

    /* --- Rank Score Spacing (Unchanged) --- */
    .rank-score {
        display: block !important;
        margin-top: 3px !important;
        margin-bottom: 5px !important;
    }
    #resultTable td:nth-child(3) .rank-score {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }


    /* --- Checkbox group horizontal scroll on mobile (Unchanged) --- */
    .year-selection .checkbox-group {
         gap: 10px 15px;
         justify-content: center; /* Centered */
         max-width: none;
         flex-wrap: nowrap;
         overflow-x: auto;
         padding-bottom: 5px;
         -webkit-overflow-scrolling: touch;
    }

    .year-selection .checkbox-group input[type="checkbox"] {
        width: 1.3em;
        height: 1.3em;
    }

    .year-selection .checkbox-group label {
        white-space: nowrap;
    }
}

/* --- 回到顶部按钮样式 --- */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background-color: #3498db;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(52, 152, 219, 0.3);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    transform: translateY(20px);
}

.back-to-top.show {
    opacity: 1;
    transform: translateY(0);
}

.back-to-top:hover {
    background-color: #2980b9;
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

.back-to-top-icon {
    font-size: 28px;
    font-weight: 900;
    text-shadow: 0 0 2px #fff;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .back-to-top {
        width: 40px;
        height: 40px;
        bottom: 20px;
        right: 20px;
    }
    
    .back-to-top-icon {
        font-size: 20px;
    }
}