/* Import a modern, clean font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* --- THEME VARIABLES --- */
:root, [data-theme="dark"] {
    --bg-main: #050505;
    --bg-sidebar: #050505;
    --primary-neon: #a855f7; 
    --primary-dark: #7e22ce;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-bg: linear-gradient(145deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.01) 100%);
    --glass-border: rgba(255, 255, 255, 0.05);
    --glass-border-top: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 15px 35px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    --input-bg: rgba(0, 0, 0, 0.3);
    --glow-shadow: 0 0 20px rgba(168, 85, 247, 0.3);
    --radius-lg: 24px;
    --radius-md: 16px;
}

[data-theme="light"] {
    --bg-main: #f1f5f9;
    --bg-sidebar: #e2e8f0;
    --primary-neon: #9333ea; 
    --primary-dark: #6b21a8;
    --text-main: #0f172a;
    --text-muted: #475569;
    --glass-bg: linear-gradient(145deg, rgba(255,255,255,0.8) 0%, rgba(255,255,255,0.4) 100%);
    --glass-border: rgba(0, 0, 0, 0.05);
    --glass-border-top: rgba(255, 255, 255, 0.8);
    --glass-shadow: 0 15px 35px rgba(0, 0, 0, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.5);
    --input-bg: rgba(255, 255, 255, 0.5);
    --glow-shadow: 0 0 20px rgba(147, 51, 234, 0.2);
}

[data-theme="custom"] {
    --bg-main: transparent; /* Lets the body background image show */
    --bg-sidebar: rgba(0, 0, 0, 0.4);
    --primary-neon: #c084fc; 
    --primary-dark: #9333ea;
    --text-main: #ffffff;
    --text-muted: #e2e8f0;
    --glass-bg: linear-gradient(145deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.02) 100%);
    --glass-border: rgba(255, 255, 255, 0.15);
    --glass-border-top: rgba(255, 255, 255, 0.3);
    --glass-shadow: 0 15px 35px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    --input-bg: rgba(0, 0, 0, 0.4);
    --glow-shadow: 0 0 20px rgba(192, 132, 252, 0.4);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text-main);
    margin: 0;
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.5s ease;
}

/* ========================================= */
/* --- AUTH PAGES (Login / Register) --- */
/* ========================================= */
.auth-container {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-top: 1px solid var(--glass-border-top);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    width: 100%;
    max-width: 400px;
    text-align: center;
    margin: auto;
    position: relative;
    top: 50%;
    transform: translateY(-50%);
}

.auth-container h2, .auth-container h3 { margin-top: 0; color: var(--text-main); }

.auth-container input {
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 15px;
    border-radius: 12px;
    width: 100%;
    margin-bottom: 15px;
    outline: none;
    transition: 0.3s;
}

.auth-container input:focus {
    border-color: var(--primary-neon);
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.2);
}

.auth-container button {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-neon));
    color: white;
    border: none;
    padding: 15px;
    width: 100%;
    border-radius: 12px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: 0.3s;
    box-shadow: var(--glow-shadow);
}

.auth-container button:hover {
    box-shadow: 0 0 25px rgba(168, 85, 247, 0.6);
    transform: translateY(-2px);
}

.google-btn { background: var(--input-bg) !important; border: 1px solid var(--glass-border) !important; box-shadow: none !important; color: var(--text-main) !important;}
.google-btn:hover { border-color: var(--primary-neon) !important; }
.auth-container a { color: var(--primary-neon); text-decoration: none; }
.auth-container p { color: var(--text-muted); }
hr { border-color: var(--glass-border); margin: 25px 0; }

/* ========================================= */
/* --- MAIN DASHBOARD APP --- */
/* ========================================= */
.app-container { display: flex; height: 100vh; width: 100vw; }

/* --- Sidebar Navigation --- */
.sidebar {
    width: 280px;
    background: var(--bg-sidebar);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    transition: background 0.5s ease;
}

.sidebar-brand {
    padding: 0 30px 30px 30px;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-accent { 
    color: var(--primary-neon); 
    text-shadow: 0 0 15px rgba(168, 85, 247, 0.5);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0 20px;
}

.nav-item {
    padding: 16px 20px;
    color: var(--text-muted);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 15px;
    border-radius: 16px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-item:hover, .nav-item.active {
    background: rgba(168, 85, 247, 0.1);
    color: var(--primary-neon);
    box-shadow: inset 0 0 20px rgba(168, 85, 247, 0.05);
}

.nav-item .lucide { width: 20px; height: 20px; }

/* --- Main Content Area --- */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: transparent;
}

.top-bar {
    padding: 40px 40px 30px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    /* Dynamic gradient adapting to theme */
    background: linear-gradient(to bottom, var(--bg-sidebar) 0%, transparent 100%);
}

.top-bar h2 { margin: 0; font-weight: 600; font-size: 28px; display: flex; align-items: center; gap: 10px;}

.content-area { padding: 0 40px 40px 40px; }

/* --- Glassmorphism Panels --- */
.glass, .glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-top: 1px solid var(--glass-border-top);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
}

.glass-panel { padding: 30px; margin-bottom: 30px; }
.glass-panel h3 { margin-top: 0; margin-bottom: 20px; font-weight: 500; color: var(--text-muted); display: flex; align-items: center; gap: 10px;}

/* --- Dashboard Grid --- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 25px; margin-bottom: 30px; }

.stat-card {
    padding: 30px;
    text-align: center;
    transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50px; left: -50px;
    width: 100px; height: 100px;
    background: var(--primary-neon);
    filter: blur(60px);
    opacity: 0.2;
}

.stat-card:hover { 
    transform: translateY(-5px); 
    border-color: rgba(168, 85, 247, 0.3);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), 0 0 25px rgba(168, 85, 247, 0.15);
}

.stat-card h3 { margin: 0 0 12px 0; font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1.2px; font-weight: 600; }
.stat-value { font-size: 42px; font-weight: 700; color: var(--text-main); text-shadow: 0 0 20px rgba(255, 255, 255, 0.15); }

.dashboard-sections { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }

/* --- Lists & Trees --- */
.upcoming-list { list-style: none; padding: 0; margin: 0; }
.upcoming-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    margin: 0 -20px;
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-main);
    transition: background 0.2s;
    border-radius: 12px;
}
.upcoming-list li:hover { background: rgba(255, 255, 255, 0.05); }
.upcoming-list li:last-child { border-bottom: none; }

.tree-subject { font-weight: 700; font-size: 22px; margin-bottom: 15px; color: var(--text-main); }
.tree-title { margin-left: 20px; color: var(--text-muted); margin-bottom: 15px; font-size: 16px; border-left: 2px solid var(--glass-border); padding-left: 15px;}
.row-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    margin-left: 40px;
    margin-bottom: 15px;
    background: rgba(255,255,255,0.02);
    border-radius: var(--radius-md);
    transition: background 0.2s;
}
.row-flex:hover { background: rgba(255, 255, 255, 0.05); }
.sub-info h4 { margin: 0 0 5px 0; font-size: 18px; font-weight: 500; }
.q-count { font-size: 14px; color: var(--primary-neon); }
.sub-actions { display: flex; align-items: center; gap: 20px; }

/* --- Forms & Inputs --- */
.forms-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
.full-width { grid-column: 1 / -1; }
.form-row { display: flex; gap: 20px; margin-bottom: 20px; }

.glass-input, .glass-select {
    width: 100%;
    padding: 16px 20px;
    margin-bottom: 20px;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    border-radius: 14px;
    outline: none;
    transition: 0.3s;
    font-size: 15px;
}
.glass-input:focus, .glass-select:focus { 
    border-color: var(--primary-neon); 
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.2);
}
.glass-input::placeholder { color: var(--text-muted); }
.glass-select option { background: var(--bg-main); color: var(--text-main); }
.auto-width { width: auto; min-width: 250px; margin-bottom: 0; }

.filter-bar { display: flex; align-items: center; gap: 20px; }
.filter-bar label { color: var(--text-muted); font-weight: 500;}

/* --- Buttons --- */
.action-btn {
    background: var(--input-bg);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    padding: 15px 30px;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.action-btn.accent { 
    background: linear-gradient(135deg, var(--primary-neon), #c084fc); 
    border: none; 
    color: white; 
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.action-btn:hover { 
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.1);
}

.action-btn.accent:hover {
    background: #b975f8;
    box-shadow: 0 0 25px rgba(168, 85, 247, 0.5);
}

.glass-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--glass-border);
    padding: 10px 20px;
    border-radius: 12px;
    cursor: pointer;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.glass-btn:hover { background: rgba(255,255,255,0.05); color: var(--text-main); border-color: var(--primary-neon); }
.glass-btn.logout-btn:hover { background: rgba(239, 68, 68, 0.1); color: #ef4444; border-color: #ef4444; }

.hidden { display: none !important; }

/* Theme Settings Specific */
.theme-preview-box {
    width: 100%;
    height: 100px;
    border-radius: 12px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}
.theme-preview-box.selected { border-color: var(--primary-neon); box-shadow: 0 0 15px rgba(168, 85, 247, 0.3); }

/* --- TIMETABLE GLASSY UI STYLES --- */
.timetable-wrapper {
    background: transparent;
    padding: 10px 0;
    overflow-x: auto;
    position: relative;
    display: flex;
    flex-direction: column;
}
.tt-header-row {
    display: flex;
    padding-bottom: 10px;
    margin-bottom: 10px;
    width: max-content;
    min-width: 100%;
}
.tt-time-cell {
    width: 100px;
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    text-align: left;
    padding-left: 10px;
}
.tt-time-cell.sticky-corner {
    width: 70px;
    position: sticky;
    left: 0;
    background: var(--bg-main); /* Blends with app background to look 'outside' */
    z-index: 5;
    padding: 0;
}
.tt-day-row {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    width: max-content;
    min-width: 100%;
}
.tt-day-label {
    width: 70px;
    flex-shrink: 0;
    color: var(--text-main);
    font-size: 14px;
    font-weight: 600;
    position: sticky;
    left: 0;
    background: var(--bg-main); /* Blends with app background to look 'outside' */
    z-index: 4;
    display: flex;
    align-items: center;
}
.tt-events-container {
    position: relative;
    height: 55px;
    width: 2400px;
    background: var(--glass-bg); /* Glassy Background */
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.1);
}
/* Grid lines inside the container */
.tt-events-container::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: linear-gradient(to right, var(--glass-border) 1px, transparent 1px);
    background-size: 100px 100%; /* Matches hour width */
    pointer-events: none;
}
.tt-event-pill {
    position: absolute;
    height: calc(100% - 14px);
    top: 7px;
    border-radius: 8px; /* Boxy */
    display: flex;
    align-items: center;
    padding: 0 12px;
    font-size: 12px;
    font-weight: 600;
    /* Soft drop shadow + inner white highlight for 3D glass effect */
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3), inset 0 1px 1px rgba(255, 255, 255, 0.2);
    cursor: pointer;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    /* Stronger blur for the frosted look */
    backdrop-filter: blur(12px); 
    -webkit-backdrop-filter: blur(12px);
    /* Glass edge reflection */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.4); 
}
.tt-event-pill:hover {
    transform: scale(1.02) translateY(-2px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.4), inset 0 1px 2px rgba(255,255,255,0.4);
    z-index: 10;
}
.tt-pill-repeating {
    /* Dropped opacity to 40% (0.4) so the grid shows through */
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.4), rgba(4, 120, 87, 0.5));
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8); /* Keeps text readable */
}
.tt-pill-once {
    /* Dropped opacity to 50% */
    background: rgba(248, 250, 252, 0.5);
    color: #0f172a;
}
/* --- CUSTOM UI: TOASTS, MODALS, SELECT --- */
/* ========================================= */

/* Custom Glass Select Arrow */
.glass-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a855f7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 16px;
    padding-right: 45px;
}

/* Toast Notification Container */
#toast-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-left: 4px solid var(--primary-neon);
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideInRight 0.3s ease forwards;
    opacity: 0;
    transform: translateX(100%);
}

.toast.error { border-left-color: #ef4444; }
.toast.success { border-left-color: #10b981; }

@keyframes slideInRight {
    to { opacity: 1; transform: translateX(0); }
}
@keyframes fadeOut {
    to { opacity: 0; transform: translateY(-10px); }
}

/* Custom Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: 0.3s ease;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }

.custom-modal {
    background: var(--bg-main);
    border: 1px solid var(--glass-border);
    padding: 30px;
    border-radius: var(--radius-lg);
    width: 400px;
    max-width: 90%;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    transform: translateY(20px);
    transition: 0.3s ease;
}
.modal-overlay.active .custom-modal { transform: translateY(0); }

.modal-btns { display: flex; gap: 15px; margin-top: 25px; justify-content: flex-end; }

/* Calendar Grid */
.calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.calendar-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-weight: bold; color: var(--text-muted); margin-bottom: 10px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }

.cal-day {
    aspect-ratio: 1;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    position: relative;
}
.cal-day:hover { transform: scale(1.05); border-color: var(--primary-neon); }
.cal-day.empty { visibility: hidden; }
.cal-day .date-num { font-size: 18px; font-weight: 600; }
.cal-day .cal-mins { font-size: 11px; color: var(--text-muted); margin-top: 5px; }
.cal-day .note-indicator { position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; background: #f59e0b; border-radius: 50%; }

/* Heatmap Colors */
.cal-day.heat-1 { background: rgba(168, 85, 247, 0.2); border-color: rgba(168, 85, 247, 0.3); }
.cal-day.heat-2 { background: rgba(168, 85, 247, 0.5); border-color: rgba(168, 85, 247, 0.6); }
.cal-day.heat-3 { background: rgba(168, 85, 247, 0.9); border-color: var(--primary-neon); color: white; box-shadow: 0 0 15px rgba(168,85,247,0.4); }

/* --- FULLY ROUND INPUTS --- */
.glass-input, .glass-select {
    border-radius: 30px !important; 
}

/* --- CUSTOM DROPDOWN ENGINE --- */
.custom-select-container {
    position: relative;
    width: 100%;
    z-index: 100; /* Ensure it stays above the card below */
}

.custom-select-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    cursor: pointer;
}

.custom-select-options {
    position: absolute;
    top: calc(100% + 5px); /* Small gap below the trigger */
    left: 0;
    width: 100%;
    z-index: 1000; /* High z-index to float over everything */
    border-radius: 20px;
    max-height: 250px;
    overflow-y: auto;
    display: none;
    flex-direction: column;
    padding: 10px;
    background: var(--bg-main); 
    backdrop-filter: blur(25px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 15px 35px rgba(0,0,0,0.5);
}

.custom-select-options.open {
    display: flex;
}

.custom-option {
    padding: 12px 20px;
    color: var(--text-main);
    cursor: pointer;
    border-radius: 12px;
    transition: 0.2s;
    margin-bottom: 5px;
}

.custom-option:last-child { margin-bottom: 0; }

.custom-option:hover, .custom-option.selected {
    background: rgba(168, 85, 247, 0.2);
    color: var(--primary-neon);
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}