/* ============================================================
   PULSE - Design System
   Dark cyberpunk theme — inspired by distilled dashboard aesthetic
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;700&display=swap');

/* --- Variables -------------------------------------------- */
:root {
    --bg-base:      #0a0a0f;
    --bg-card:      #111118;
    --bg-card2:     #16161f;
    --bg-input:     #1a1a24;
    --border:       #1e1e2e;
    --border-hover: #2a2a3e;

    --accent:       #00e5b0;
    --accent-dim:   rgba(0,229,176,.15);
    --accent-glow:  0 0 20px rgba(0,229,176,.25);

    --cyan:         #00c8e0;
    --purple:       #7c6af7;
    --amber:        #f0b429;
    --red:          #f05050;
    --green:        #00d97e;

    --text-primary:   #e8e8f0;
    --text-secondary: #8888a0;
    --text-muted:     #4a4a60;

    --font-main:  'Space Grotesk', system-ui, sans-serif;
    --font-mono:  'JetBrains Mono', monospace;

    --radius-sm:  6px;
    --radius-md:  10px;
    --radius-lg:  16px;

    --sidebar-w:  240px;
    --header-h:   60px;
}

/* --- Reset ------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { opacity: .8; }

/* --- Layout ------------------------------------------------ */
.layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: var(--header-h) 1fr;
    min-height: 100vh;
}

/* --- Sidebar ---------------------------------------------- */
.sidebar {
    grid-row: 1 / -1;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    height: var(--header-h);
    border-bottom: 1px solid var(--border);
}

.sidebar-logo .logo-text {
    font-family: var(--font-mono);
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 3px;
    text-shadow: var(--accent-glow);
}

.sidebar-logo .logo-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: var(--accent-glow);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .5; transform: scale(0.7); }
}

.sidebar-section {
    padding: 20px 12px 8px;
}

.sidebar-section-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 0 8px;
    margin-bottom: 6px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    transition: all .15s;
    margin-bottom: 2px;
}

.sidebar-nav a:hover {
    background: var(--accent-dim);
    color: var(--text-primary);
}

.sidebar-nav a.active {
    background: var(--accent-dim);
    color: var(--accent);
    border-left: 2px solid var(--accent);
}

.sidebar-nav a svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.sidebar-footer {
    margin-top: auto;
    padding: 12px;
    border-top: 1px solid var(--border);
}

.sidebar-nav-logout {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    transition: all .15s;
    text-decoration: none;
}

.sidebar-nav-logout:hover {
    background: rgba(240,80,80,.1);
    color: var(--red);
    opacity: 1;
}

.sidebar-nav-logout svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* --- Header ----------------------------------------------- */
.topbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: var(--header-h);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--accent);
    background: var(--accent-dim);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid rgba(0,229,176,.2);
}

.status-badge .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse-dot 2s infinite;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 13px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
}

/* --- Main content ----------------------------------------- */
.main-content {
    padding: 24px;
    overflow-y: auto;
}

/* --- Cards ------------------------------------------------ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: border-color .2s;
}

.card:hover {
    border-color: var(--border-hover);
}

.card-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* --- Stat cards ------------------------------------------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--accent);
    opacity: 0;
    transition: opacity .2s;
}

.stat-card:hover::before { opacity: 1; }

.stat-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.stat-value.accent { color: var(--accent); text-shadow: var(--accent-glow); }
.stat-value.cyan   { color: var(--cyan); }
.stat-value.amber  { color: var(--amber); }
.stat-value.purple { color: var(--purple); }

.stat-sub {
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-muted);
}

.stat-icon {
    position: absolute;
    top: 16px; right: 16px;
    opacity: .15;
    width: 32px;
    height: 32px;
}

/* --- Room occupancy grid ---------------------------------- */
.rooms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.room-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    position: relative;
}

.room-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
}

.room-name {
    font-weight: 600;
    font-size: 14px;
}

.room-capacity-badge {
    font-size: 10px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 2px 7px;
    border-radius: 10px;
}

.room-count {
    font-family: var(--font-mono);
    font-size: 40px;
    font-weight: 700;
    color: var(--accent);
    text-shadow: var(--accent-glow);
    line-height: 1;
}

.room-count-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.room-bar {
    margin-top: 14px;
    height: 3px;
    background: var(--bg-input);
    border-radius: 2px;
    overflow: hidden;
}

.room-bar-fill {
    height: 100%;
    border-radius: 2px;
    background: var(--accent);
    transition: width .5s ease;
}

.room-bar-fill.warn  { background: var(--amber); }
.room-bar-fill.full  { background: var(--red); }

/* --- Tables ----------------------------------------------- */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background .15s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-card2); }

tbody td {
    padding: 12px;
    vertical-align: middle;
    color: var(--text-primary);
}

/* --- Badges ----------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font-mono);
    letter-spacing: .5px;
}

.badge-green  { background: rgba(0,217,126,.15); color: var(--green); }
.badge-red    { background: rgba(240,80,80,.15);  color: var(--red); }
.badge-amber  { background: rgba(240,180,41,.15); color: var(--amber); }
.badge-cyan   { background: rgba(0,200,224,.15);  color: var(--cyan); }
.badge-purple { background: rgba(124,106,247,.15);color: var(--purple); }
.badge-muted  { background: var(--bg-input);      color: var(--text-muted); }

/* --- Student avatar --------------------------------------- */
.student-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.student-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    color: var(--accent);
    flex-shrink: 0;
    overflow: hidden;
}

.student-name { font-weight: 500; }
.student-email { font-size: 12px; color: var(--text-muted); }

/* --- Buttons ---------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all .15s;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #000;
}
.btn-primary:hover { background: #00ffc4; opacity: 1; color: #000; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-hover);
    color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger {
    background: rgba(240,80,80,.15);
    border: 1px solid rgba(240,80,80,.3);
    color: var(--red);
}
.btn-danger:hover { background: rgba(240,80,80,.25); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px; }

/* --- Forms ------------------------------------------------ */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: .5px;
}

.form-control {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 9px 12px;
    font-family: var(--font-main);
    font-size: 14px;
    outline: none;
    transition: border-color .15s;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238888a0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

/* --- Grid layouts ----------------------------------------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

/* --- Section header --------------------------------------- */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

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

/* --- Chart container -------------------------------------- */
.chart-container {
    position: relative;
    height: 220px;
}

/* --- Search ----------------------------------------------- */
.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 12px;
    transition: border-color .15s;
}

.search-bar:focus-within { border-color: var(--accent); }

.search-bar svg { color: var(--text-muted); flex-shrink: 0; }

.search-bar input {
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 14px;
    padding: 9px 0;
    width: 100%;
}

.search-bar input::placeholder { color: var(--text-muted); }

/* --- Toolbar ---------------------------------------------- */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.toolbar .search-bar { flex: 1; min-width: 200px; }

/* --- Alerts ----------------------------------------------- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert-success { background: rgba(0,217,126,.1); border: 1px solid rgba(0,217,126,.3); color: var(--green); }
.alert-error   { background: rgba(240,80,80,.1);  border: 1px solid rgba(240,80,80,.3);  color: var(--red); }
.alert-info    { background: var(--accent-dim);   border: 1px solid rgba(0,229,176,.2);  color: var(--accent); }

/* --- Modal ------------------------------------------------ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-lg);
    padding: 28px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-title {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* --- Live indicator --------------------------------------- */
.live-tag {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--red);
    background: rgba(240,80,80,.15);
    border: 1px solid rgba(240,80,80,.3);
    padding: 2px 8px;
    border-radius: 4px;
    animation: blink 1.2s step-end infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: .4; }
}

/* --- Scrollbar -------------------------------------------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- Utilities -------------------------------------------- */
.mt-0 { margin-top: 0; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-mono { font-family: var(--font-mono); }
.text-right { text-align: right; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
