/* ==========================================================================
   SCIS Faculty Directory Premium Stylesheet (Vanilla CSS)
   Theme: High-End Dark-Mode Glassmorphism
   Fonts: Outfit (Headings) & Inter (Body)
   ========================================================================== */

/* --- Custom Variables & Theme Tokens --- */
:root {
    --bg-main: #060913;
    --bg-surface: rgba(18, 26, 47, 0.55);
    --bg-surface-hover: rgba(26, 38, 68, 0.75);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(212, 175, 55, 0.3);
    
    /* Accents */
    --accent-gold: #dfab1a;
    --accent-gold-glow: rgba(223, 171, 26, 0.4);
    --accent-indigo: #6366f1;
    --accent-teal: #14b8a6;
    
    /* Text Colors */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Layout Tokens */
    --border-radius-sm: 8px;
    --border-radius-md: 16px;
    --border-radius-lg: 24px;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    
    /* Shadow Utilities */
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 0 25px rgba(223, 171, 26, 0.15);
}

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

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
    border: 2px solid var(--bg-main);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-gold);
}

/* --- Dynamic Glowing Background Elements --- */
.bg-glow {
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(160px);
    opacity: 0.15;
    z-index: -1;
    pointer-events: none;
}

.bg-glow-1 {
    top: -100px;
    left: -200px;
    background: var(--accent-indigo);
}

.bg-glow-2 {
    top: 40%;
    right: -250px;
    background: var(--accent-gold);
}

.bg-glow-3 {
    bottom: -150px;
    left: 20%;
    background: var(--accent-teal);
}

/* --- Header & Navigation --- */
.app-header {
    background: rgba(6, 9, 19, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.25rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.logo-icon {
    font-size: 1.8rem;
    color: var(--accent-gold);
    background: rgba(223, 171, 26, 0.1);
    width: 45px;
    height: 45px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-glow);
    text-shadow: 0 0 10px var(--accent-gold-glow);
}

.logo-text h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-primary);
    line-height: 1.2;
}

.sub-logo {
    font-size: 0.75rem;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition-smooth);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
}

.nav-link:hover, .nav-link.active {
    color: var(--accent-gold);
    background: rgba(223, 171, 26, 0.05);
}

.nav-link.external {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid var(--border-color);
}

.nav-link.external:hover {
    border-color: var(--accent-gold);
}

/* --- Main Layout --- */
.main-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 3rem 2rem;
}

/* --- Hero Section & Dashboard --- */
.hero-section {
    margin-bottom: 3.5rem;
    display: grid;
    grid-template-columns: 1.2fr 2fr;
    gap: 2.5rem;
    align-items: center;
}

.hero-content h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 2.75rem;
    font-weight: 800;
    line-height: 1.25;
    margin-bottom: 1.25rem;
    background: linear-gradient(135deg, var(--text-primary) 30%, var(--accent-gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-content p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    max-width: 540px;
}

/* Stats Dashboard Grid */
.stats-dashboard {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}

.stat-card {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: var(--transition-smooth);
    box-shadow: var(--shadow-sm);
}

.stat-card:hover {
    border-color: var(--border-glow);
    transform: translateY(-3px);
    box-shadow: var(--shadow-glow);
}

.stat-icon {
    font-size: 1.75rem;
    color: var(--accent-gold);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(223, 171, 26, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(223, 171, 26, 0.15);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-family: 'Outfit', sans-serif;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- Controls Section (Search, Filters, Sort) --- */
.controls-section {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 2.25rem;
    margin-bottom: 3rem;
    box-shadow: var(--shadow-md);
}

.search-sort-row {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.search-box {
    position: relative;
    flex: 1;
}

.search-icon {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.1rem;
    pointer-events: none;
    transition: var(--transition-smooth);
}

.search-box input {
    width: 100%;
    background: rgba(6, 9, 19, 0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 1.1rem 1.25rem 1.1rem 3rem;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    transition: var(--transition-smooth);
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent-gold);
    box-shadow: 0 0 15px rgba(223, 171, 26, 0.15);
    background: rgba(6, 9, 19, 0.85);
}

.search-box input:focus + .search-icon {
    color: var(--accent-gold);
}

.clear-search-btn {
    position: absolute;
    right: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    display: none; /* Dynamic in JS */
    transition: var(--transition-smooth);
    padding: 0.25rem;
}

.clear-search-btn:hover {
    color: var(--accent-gold);
}

.sort-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(6, 9, 19, 0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 0 1.25rem;
    min-width: 200px;
}

.sort-box label {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.sort-box select {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    width: 100%;
    height: 100%;
    cursor: pointer;
    padding: 1.1rem 0;
}

.sort-box select:focus {
    outline: none;
}

.sort-box select option {
    background: var(--bg-main);
    color: var(--text-primary);
}

/* Filter Groups */
.filter-group {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.filter-group:last-of-type {
    margin-bottom: 0;
}

.filter-title {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-top: 0.5rem;
    white-space: nowrap;
    min-width: 100px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.filter-pill {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.5rem 1.1rem;
    border-radius: 50px;
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.filter-pill:hover {
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.filter-pill.active {
    background: var(--accent-gold);
    border-color: var(--accent-gold);
    color: #060913;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(223, 171, 26, 0.3);
}

/* Results Status */
.results-status {
    margin-top: 1.75rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    padding-top: 1.25rem;
    font-weight: 500;
}

.results-status span {
    color: var(--accent-gold);
    font-weight: 700;
}

/* --- Faculty Grid & Cards --- */
.faculty-grid-section {
    min-height: 400px;
    position: relative;
}

.faculty-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
}

/* Loader & Spinner */
.loader {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5rem 0;
    gap: 1.5rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.05);
    border-top: 3px solid var(--accent-gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow: 0 0 15px rgba(223, 171, 26, 0.1);
}

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

/* Teacher Card */
.faculty-card {
    background: var(--bg-surface);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: var(--transition-bounce);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    position: relative;
}

/* Hover effects */
.faculty-card:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: var(--accent-gold);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    background: var(--bg-surface-hover);
}

.faculty-card:hover .card-img {
    transform: scale(1.08);
}

.faculty-card:hover .card-readmore {
    color: var(--accent-gold);
    transform: translateX(4px);
}

/* Portrait Image Container */
.card-img-container {
    position: relative;
    width: 100%;
    padding-top: 110%; /* Beautiful aspect ratio */
    overflow: hidden;
    background: linear-gradient(180deg, #101726 0%, #060913 100%);
    border-bottom: 1px solid var(--border-color);
}

.card-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    transition: var(--transition-smooth);
    opacity: 0;
}

.card-img.loaded {
    opacity: 1;
}

/* Image skeleton / placeholder loading state */
.card-img-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(223, 171, 26, 0.05), rgba(99, 102, 241, 0.05));
}

.card-img-placeholder i {
    font-size: 2.5rem;
    color: var(--text-muted);
}

/* Card Details */
.card-info {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.card-campus {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
    display: inline-block;
}

/* Campus badge colors */
.campus-hongqiao-lower { color: #f59e0b; }
.campus-hongqiao-upper { color: #d97706; }
.campus-pudong-lower { color: #3b82f6; }
.campus-pudong-upper { color: #2563eb; }
.campus-system-wide { color: #10b981; }
.campus-default { color: var(--accent-gold); }

.card-name {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
    line-height: 1.2;
}

.card-title {
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 2.8rem;
    line-height: 1.4;
}

.card-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-education-badge {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.card-readmore {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.3rem;
    transition: var(--transition-smooth);
}

/* No Results Section */
.no-results {
    display: none; /* Block when search fails */
    text-align: center;
    padding: 6rem 2rem;
    grid-column: 1 / -1;
}

.no-results i {
    font-size: 4rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.no-results h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.no-results p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.btn {
    display: inline-block;
    padding: 0.75rem 1.75rem;
    border-radius: var(--border-radius-sm);
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: none;
}

.btn-primary {
    background: var(--accent-gold);
    color: #060913;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(223, 171, 26, 0.4);
}

/* --- Premium Details Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(3, 5, 10, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-container {
    background: rgba(14, 22, 42, 0.9);
    border: 1px solid var(--border-glow);
    border-radius: var(--border-radius-lg);
    width: 100%;
    max-width: 960px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg), 0 0 50px rgba(0, 0, 0, 0.8);
    transform: scale(0.95) translateY(20px);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-container {
    transform: scale(1) translateY(0);
}

.modal-close-btn {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
    z-index: 10;
}

.modal-close-btn:hover {
    background: var(--accent-gold);
    color: #060913;
    border-color: var(--accent-gold);
    transform: rotate(90deg);
}

/* Modal Content Grid */
.modal-content {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 3rem;
    padding: 3.5rem;
}

.modal-left {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-image-container {
    width: 100%;
    max-width: 320px;
    aspect-ratio: 1 / 1.1;
    border-radius: var(--border-radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: #0c1220;
    box-shadow: var(--shadow-md);
}

.modal-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
}

.modal-right {
    display: flex;
    flex-direction: column;
}

.modal-campus-badge {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--accent-gold);
    margin-bottom: 0.5rem;
}

.modal-name {
    font-family: 'Outfit', sans-serif;
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-section {
    margin-bottom: 1.75rem;
}

.modal-section:last-of-type {
    margin-bottom: 0;
}

.modal-section-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-section-title i {
    color: var(--accent-gold);
}

.modal-education {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 1rem 1.25rem;
    font-size: 0.92rem;
    color: var(--text-primary);
    line-height: 1.5;
}

.modal-biography {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.7;
    white-space: pre-line;
}

/* --- Footer Area --- */
.app-footer-bottom {
    border-top: 1px solid var(--border-color);
    background: rgba(3, 5, 10, 0.9);
    padding: 2.5rem 2rem;
    margin-top: 5rem;
}

.footer-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.footer-credits {
    font-style: italic;
    color: var(--text-muted);
}

/* ==========================================================================
   Responsive Adaptations & Media Queries
   ========================================================================== */

@media (max-width: 1100px) {
    .hero-section {
        grid-template-columns: 1fr;
        gap: 2rem;
        margin-bottom: 2.5rem;
    }
    
    .hero-content {
        text-align: center;
    }
    
    .hero-content h2 {
        font-size: 2.5rem;
    }
    
    .hero-content p {
        margin: 0 auto;
    }
}

@media (max-width: 900px) {
    .modal-content {
        grid-template-columns: 1fr;
        gap: 2rem;
        padding: 2.5rem;
    }
    
    .modal-left {
        align-items: center;
    }
    
    .modal-image-container {
        max-width: 240px;
    }
    
    .modal-close-btn {
        top: 1rem;
        right: 1rem;
    }
    
    .search-sort-row {
        flex-direction: column;
        gap: 1rem;
    }
    
    .sort-box {
        width: 100%;
    }
    
    .filter-group {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
}

@media (max-width: 600px) {
    .main-container {
        padding: 1.5rem 1rem;
    }
    
    .header-container {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .nav-links {
        width: 100%;
        justify-content: center;
    }
    
    .stats-dashboard {
        grid-template-columns: 1fr;
    }
    
    .controls-section {
        padding: 1.25rem;
        border-radius: var(--border-radius-md);
    }
    
    .filter-pills {
        gap: 0.5rem;
    }
    
    .filter-pill {
        padding: 0.4rem 0.85rem;
        font-size: 0.8rem;
    }
    
    .faculty-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-overlay {
        padding: 0.75rem;
    }
    
    .modal-container {
        max-height: 90vh;
    }
    
    .modal-content {
        padding: 2rem 1.25rem;
    }
    
    .modal-name {
        font-size: 1.75rem;
    }
    
    .footer-container {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }
}
