﻿/* ============================================= */
/* ===== Course Selector Table                    */
/* ============================================= */

.selector-count-bar {
    padding: 10px 24px; font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    background: var(--header-bg);
}

.selector-table {
    width: 100%; border-collapse: collapse; table-layout: auto;
}

.selector-table thead { background-color: var(--header-bg); position: sticky; top: 0; z-index: 1; }

.selector-table th {
    padding: 12px 16px; font-size: 12px; font-weight: 700;
    color: var(--text-secondary); text-transform: uppercase;
    letter-spacing: 0.5px; text-align: right;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.sortable-header {
    cursor: pointer; user-select: none;
    transition: color 0.2s;
}
.sortable-header:hover { color: var(--primary-color); }

.selector-table td {
    padding: 12px 16px; vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.selector-table tbody tr { transition: background 0.15s; cursor: default; }
.selector-table tbody tr:hover { background: transparent; }

.selector-table tbody tr.already-added {
    opacity: 0.5; background: #f8f9fa;
}

.selector-course-info .name { font-weight: 600; font-size: 14px; color: var(--text-primary); }
.selector-course-info .code { font-size: 12px; color: var(--text-secondary); }

.selector-add-btn {
    padding: 5px 14px;
    background: var(--primary-color); color: white;
    border: none; border-radius: 6px;
    font-size: 12px; font-weight: 700;
    font-family: inherit; cursor: pointer;
    white-space: nowrap; transition: background 0.2s;
}
.selector-add-btn:hover { background: #0b5ed7; }

/* ============================================= */
/* ===== Modal System                             */
/* ============================================= */

.modal-overlay {
    position: fixed; top: 0; right: 0; bottom: 0; left: 0;
    background-color: rgba(33, 37, 41, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000; display: flex;
    align-items: center; justify-content: center;
    padding: 20px;
}

.modal-content {
    background: var(--bg-surface); border-radius: 16px;
    width: 90%; max-width: 600px; max-height: 85vh;
    overflow: hidden; display: flex; flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}
.modal-content-lg {
    max-width: 1250px;
    width: 95%;
    overflow: hidden;
}

.selector-filters-row {
    display: flex;
    align-items: flex-end;
    gap: 20px;
    width: 100%;
    flex-wrap: wrap;
}

.selector-filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.selector-filter-group.expand-group {
    flex: 1;
    min-width: 180px;
}

.selector-filter-group label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.selector-dropdown {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    background: white;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
    min-width: 140px;
    height: 38px;
}

.selector-dropdown:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.filter-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}

.avg-slider-input {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-color);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.avg-slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.dual-range-input {
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    height: 6px;
}

.dual-range-input::-webkit-slider-thumb {
    pointer-events: auto;
    position: relative;
    z-index: 10;
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.dual-range-input::-webkit-slider-runnable-track {
    background: transparent;
    height: 6px;
}

.clear-filters-btn {
    background: none;
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.2s;
    height: 38px;
    white-space: nowrap;
}

.clear-filters-btn:hover {
    background-color: #fee2e2;
    color: var(--text-danger);
    border-color: var(--text-danger);
}

@media (max-width: 1100px) {
    .selector-filters-row {
        align-items: flex-start;
    }
    .selector-filter-group.expand-group {
        min-width: 100%;
    }
}

/* ===== English Badge ===== */
.eng-badge {
    display: inline-block;
    background: var(--cat-english-bg);
    color: var(--side-color-english);
    border: 1px solid var(--side-color-english);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
}

@media (max-width: 768px) {
    .selector-filters-row {
        flex-direction: column;
        gap: 12px;
    }
    
    .selector-filter-group {
        width: 100%;
    }
    
    .selector-dropdown {
        width: 100%;
    }

    .modal-content-lg { max-width: 100%; }
}
.modal-header {
    display: flex; justify-content: space-between;
    align-items: center; padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--header-bg); flex-shrink: 0;
}
.modal-header h2 { margin: 0; font-size: 20px; }

.modal-close-btn {
    background: none; border: none; font-size: 28px;
    color: var(--text-secondary); cursor: pointer;
    line-height: 1; padding: 0;
}
.modal-close-btn:hover { color: var(--text-primary); }

.controls-container {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 45vh;
    overflow-y: auto;
}

.search-group { width: 100%; }

.search-input {
    width: 100%; padding: 12px 16px;
    border: 1px solid var(--border-color); border-radius: 10px;
    font-size: 15px; font-family: inherit;
    outline: none; transition: border-color 0.2s;
}
.search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; }

.filter-chip {
    padding: 6px 14px;
    border: 1px solid var(--border-color); border-radius: 50px;
    font-size: 13px; font-weight: 600; font-family: inherit;
    cursor: pointer; background: white;
    color: var(--text-secondary); transition: all 0.2s;
}
.filter-chip:hover { border-color: var(--primary-color); color: var(--primary-color); }
.filter-chip.active { background: var(--primary-color); color: white; border-color: var(--primary-color); }

.modal-body { flex: 1; overflow-y: auto; padding: 0; }
.courses-table-container { flex: 1; overflow-y: auto; }

/* ===== Advanced Filters Grid (Redesigned) ===== */
.advanced-filters-grid {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    margin-top: 10px;
    border-top: 1px solid var(--border-color);
    padding-top: 14px;
    flex-wrap: wrap;
}

.adv-filter-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.adv-filter-item > label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
}

/* Dual range slider */
.adv-filter-range {
    flex: 1;
    min-width: 200px;
}

.dual-range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}

.dual-range-labels strong {
    color: var(--text-primary);
    font-size: 13px;
}

.dual-range-container {
    position: relative;
    height: 28px;
    display: flex;
    align-items: center;
    width: 100%;
    min-width: 0;
    overflow: visible;
}

.dual-range-input {
    position: absolute;
    left: 0;
    right: 0;
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    outline: none;
    cursor: pointer;
    pointer-events: none;
    margin: 0;
}

.dual-range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
    pointer-events: all;
    position: relative;
    z-index: 2;
}

.dual-range-input::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
    pointer-events: all;
}

.dual-range-input:first-child::-webkit-slider-runnable-track {
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
}

.dual-range-input:first-child::-moz-range-track {
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
}

.dual-range-input:last-child::-webkit-slider-runnable-track {
    height: 6px;
    background: transparent;
}

.dual-range-input:last-child::-moz-range-track {
    height: 6px;
    background: transparent;
}

/* Checkbox filters */
.adv-filter-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 160px;
}

.filter-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
}

.filter-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

/* Clear filters button */
.adv-filter-actions {
    display: flex;
    align-items: flex-end;
    min-width: 120px;
}

.clear-filters-btn {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.clear-filters-btn:hover {
    border-color: var(--danger-color);
    color: var(--danger-color);
    background: #fef2f2;
}

/* Tau Factor Link */
.tau-factor-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    transition: color 0.2s, transform 0.2s;
    text-decoration: none;
}

.tau-factor-link:hover {
    color: #0b5ed7;
    transform: scale(1.15);
}

.tau-factor-link svg {
    width: 20px;
    height: 20px;
}

/* Semester cell in selector */
.semester-cell {
    font-size: 12px;
    color: var(--text-secondary);
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Responsive: filters + selector columns */
@media (max-width: 768px) {
    .advanced-filters-grid {
        flex-direction: column;
        gap: 16px;
    }

    .adv-filter-range {
        width: 100%;
    }

    .header-action-btn span { display: none; }

    .selector-table th:nth-child(5),
    .selector-table td:nth-child(5),
    .selector-table th:nth-child(6),
    .selector-table td:nth-child(6),
    .selector-table th:nth-child(7),
    .selector-table td:nth-child(7),
    .selector-table th:nth-child(9),
    .selector-table td:nth-child(9) {
        display: none;
    }
}

@media (max-width: 480px) {
    .selector-table th:nth-child(4),
    .selector-table td:nth-child(4) {
        display: none;
    }
}

/* ===== Toast ===== */
.toast-notification {
    position: fixed; z-index: 10001;
    bottom: 24px; left: 24px;
    background: white; color: var(--text-primary);
    padding: 16px 24px; border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    border-right: 5px solid var(--success-color);
    min-width: 300px; max-width: 90vw;
    display: flex; align-items: center; gap: 16px;
    direction: rtl; font-family: var(--font-family);
    animation: slideUp 0.4s ease-out;
}
.toast-notification.hidden { display: none; }
.toast-content { display: flex; align-items: flex-start; gap: 12px; width: 100%; }
.toast-icon { font-size: 24px; }
.toast-text h4 { margin: 0 0 4px 0; font-size: 16px; font-weight: 800; }
.toast-text p { margin: 0; font-size: 14px; color: var(--text-secondary); line-height: 1.4; }

.toast-close {
    background: transparent; border: none; font-size: 20px;
    color: #aaa; cursor: pointer; padding: 4px;
    margin-right: auto; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; transition: all 0.2s;
}
.toast-close:hover { background-color: #f0f0f0; color: #333; }

@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
