/* ==========================================================================
   Base Theme Variables & Reset
   ========================================================================== */
:root {
    /* Dark Mode Colors (Default) */
    --bg-app: #070a13;
    --bg-card: rgba(18, 24, 43, 0.7);
    --bg-card-hover: rgba(28, 37, 65, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-hover: rgba(72, 202, 228, 0.3);
    
    --text-primary: #f8f9fa;
    --text-secondary: #a0aec0;
    --text-muted: #718096;
    
    --color-accent: #00f5d4;
    --color-blue: #00b4d8;
    --color-purple: #7209b7;
    --color-purple-light: #9d4edd;
    --color-gold: #ffb703;
    --color-green: #2ec4b6;
    
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 20px rgba(0, 245, 212, 0.15);
    
    --font-heading: 'Outfit', 'Inter', sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;
}

.light-mode {
    /* Light Mode Colors */
    --bg-app: #f4f6fc;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: #ffffff;
    --border-color: rgba(0, 0, 0, 0.06);
    --border-color-hover: rgba(0, 180, 216, 0.35);
    
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    
    --color-accent: #00b4d8;
    --color-blue: #0077b6;
    --color-purple: #7209b7;
    --color-purple-light: #9d4edd;
    --color-gold: #e89b00;
    --color-green: #0fa3b1;
    
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 8px 16px rgba(100, 110, 140, 0.08);
    --shadow-lg: 0 16px 32px rgba(100, 110, 140, 0.15);
    --shadow-glow: 0 0 15px rgba(0, 180, 216, 0.12);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: 1.5;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Layout Containers
   ========================================================================== */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ==========================================================================
   Header Component
   ========================================================================== */
.app-header {
    height: 80px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 32px;
    filter: drop-shadow(0 0 8px var(--color-accent));
    animation: pulse 2.5s infinite alternate;
}

.logo-text h1 {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.logo-subtitle {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 1.5px;
}

/* Theme Toggle Button */
.theme-toggle-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    width: 42px;
    height: 42px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.theme-toggle-btn:hover {
    border-color: var(--color-accent);
    transform: scale(1.05);
}

.toggle-icon {
    font-size: 18px;
}

/* ==========================================================================
   Main Content Sections
   ========================================================================== */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 32px;
    padding-bottom: 60px;
}

/* Hero Section */
.hero-section {
    position: relative;
    padding: 40px;
    border-radius: 24px;
    background: linear-gradient(135deg, rgba(28,37,65,0.4) 0%, rgba(11,19,43,0.4) 100%);
    border: 1px solid var(--border-color);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.hero-bg-glow {
    position: absolute;
    top: -50px;
    right: -50px;
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, rgba(0, 245, 212, 0.15) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.hero-content {
    max-width: 900px;
    position: relative;
    z-index: 1;
}

.hero-content h2 {
    font-family: var(--font-heading);
    font-size: 32px;
    font-weight: 800;
    line-height: 1.25;
    margin-top: 12px;
    margin-bottom: 16px;
    letter-spacing: -0.5px;
    background: linear-gradient(90deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-content p {
    color: var(--text-secondary);
    font-size: 16px;
    line-height: 1.6;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.badge-accent {
    background: rgba(0, 245, 212, 0.1);
    color: var(--color-accent);
    border: 1px solid rgba(0, 245, 212, 0.3);
}

/* ==========================================================================
   Dashboard Statistics Cards
   ========================================================================== */
.stats-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    backdrop-filter: blur(8px);
}

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

.stat-icon {
    font-size: 28px;
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
}

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

.stat-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 26px;
    font-weight: 700;
    line-height: 1.1;
}

.stat-trend {
    font-size: 12px;
    font-weight: 500;
}

.text-green { color: var(--color-green); }
.text-blue { color: var(--color-blue); }
.text-purple { color: var(--color-purple-light); }
.text-gold { color: var(--color-gold); }

/* ==========================================================================
   Charts Section
   ========================================================================== */
.charts-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));
    gap: 24px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chart-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chart-header h4 {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 600;
}

.chart-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* ==========================================================================
   Controls (Filters & Search)
   ========================================================================== */
.controls-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: var(--shadow-md);
}

/* Search Box */
.search-box {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    padding: 16px 20px 16px 50px;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    color: var(--text-primary);
    font-size: 15px;
    font-family: var(--font-body);
    transition: all 0.2s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--color-blue);
    background: rgba(0, 0, 0, 0.25);
    box-shadow: 0 0 12px rgba(0, 180, 216, 0.15);
}

/* Filters Row */
.filters-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

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

.btn {
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-secondary);
    transition: all 0.2s ease;
    font-family: var(--font-body);
}

.btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.btn-filter.active {
    background: var(--color-blue);
    color: #ffffff;
    border-color: var(--color-blue);
    box-shadow: 0 4px 10px rgba(0, 180, 216, 0.3);
}

/* Dropdowns Group */
.dropdowns-group {
    display: flex;
    gap: 12px;
}

.select-wrapper {
    position: relative;
}

.select-wrapper select {
    appearance: none;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 10px 40px 10px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-body);
    outline: none;
}

.select-wrapper select:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.select-wrapper select:focus {
    border-color: var(--color-blue);
    color: var(--text-primary);
}

.select-wrapper::after {
    content: "▼";
    font-size: 8px;
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-muted);
}

/* ==========================================================================
   Directory Header & PIs Grid
   ========================================================================== */
.directory-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.directory-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.results-count {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.pis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 24px;
}

/* PI Card */
.pi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.pi-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--color-blue);
    opacity: 0.8;
}

.pi-card:hover {
    transform: translateY(-5px);
    border-color: var(--border-color-hover);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.pi-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.pi-card-header h3 {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

/* University Badges */
.uni-badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.uni-badge.hku { background: #1a5f3a; color: #f5df4d; }
.uni-badge.cuhk { background: #4b164c; color: #dfb824; }
.uni-badge.hkust { background: #0f2c59; color: #dfb53d; }
.uni-badge.polyu { background: #a6192e; color: #ffffff; }
.uni-badge.hkbu { background: #eab308; color: #1e3a8a; }
.uni-badge.cityu { background: #2563eb; color: #ffffff; }

.pi-card-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pi-title-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.pi-dept-text {
    font-size: 12px;
    color: var(--text-secondary);
}

.pi-card-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.funding-block {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border: 1px solid var(--border-color);
}

.funding-lbl {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.funding-val {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 700;
    color: var(--color-accent);
}

.research-focus-block {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.focus-lbl {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.focus-val {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.pi-card-footer {
    display: flex;
    justify-content: flex-end;
}

.btn-detail {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-body);
}

.btn-detail:hover {
    background: var(--color-blue);
    color: #ffffff;
    border-color: var(--color-blue);
    box-shadow: 0 4px 10px rgba(0, 180, 216, 0.25);
}

/* ==========================================================================
   Modal Overlay & Card Components
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 24px;
}

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

.modal-card {
    background: var(--bg-app);
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 1050px;
    max-height: 90vh;
    border-radius: 28px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow-y: auto;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-overlay.open .modal-card {
    transform: scale(1) translateY(0);
}

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

.modal-close-btn:hover {
    background: rgba(255, 0, 0, 0.15);
    border-color: rgba(255, 0, 0, 0.3);
    color: #ff4d4d;
}

.modal-content {
    padding: 40px;
}

/* Modal Header */
.modal-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 24px;
    margin-bottom: 28px;
}

.modal-title-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.modal-title-row h2 {
    font-family: var(--font-heading);
    font-size: 32px;
    font-weight: 800;
}

.modal-pi-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-pi-dept {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Modal Grid */
.modal-body-grid {
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    gap: 32px;
}

.modal-col-left {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-col-right {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.detail-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
}

.funding-detail {
    border-left: 4px solid var(--color-accent);
}

.detail-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.funding-value-large {
    font-family: var(--font-heading);
    font-size: 26px;
    font-weight: 800;
    color: var(--color-accent);
    margin-top: 4px;
}

.detail-card h5, .modal-col-right h5 {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.detail-card p {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

/* Highlight / Blockquote */
.highlight-card {
    background: linear-gradient(135deg, rgba(0, 245, 212, 0.03) 0%, rgba(0, 180, 216, 0.03) 100%);
    border: 1px solid rgba(0, 245, 212, 0.15);
}

blockquote {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    font-style: italic;
    border-left: 3px solid var(--color-accent);
    padding-left: 12px;
}

/* Projects Table */
.projects-table-wrapper {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
}

.projects-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.projects-table th {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.projects-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    vertical-align: middle;
}

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

.projects-table tr:hover td {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.01);
}

/* ==========================================================================
   Footer Component
   ========================================================================== */
.app-footer {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-top: 1px solid var(--border-color);
    margin-top: 60px;
}

.app-footer p {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes pulse {
    0% { filter: drop-shadow(0 0 4px var(--color-accent)); }
    100% { filter: drop-shadow(0 0 12px var(--color-accent)); }
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 1024px) {
    .modal-body-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    
    .charts-section {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 0 16px;
    }
    
    .hero-section {
        padding: 24px;
    }
    
    .hero-content h2 {
        font-size: 24px;
    }
    
    .stats-section {
        grid-template-columns: 1fr;
    }
    
    .filters-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .dropdowns-group {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
    
    .pis-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        padding: 24px;
    }
    
    .modal-title-row h2 {
        font-size: 24px;
    }
}
