/* ══════════════════════════════════════════════════════════
   SiMahasiswa — Premium Dark UI
   ══════════════════════════════════════════════════════════ */

/* ── CSS Variables ───────────────────────────────────────── */
:root {
    --bg-base:      #0d0f1a;
    --bg-card:      #13162b;
    --bg-card2:     #1a1d35;
    --bg-hover:     #1f2340;
    --border:       rgba(255,255,255,.07);
    --border-focus: #6366f1;

    --text-primary: #f0f2ff;
    --text-muted:   #8b93b8;
    --text-faint:   #4a5180;

    --purple:  #6366f1;
    --purple2: #818cf8;
    --green:   #10b981;
    --amber:   #f59e0b;
    --pink:    #ec4899;
    --red:     #ef4444;
    --red2:    #dc2626;

    --sidebar-w: 260px;
    --topbar-h:  64px;
    --radius:    12px;
    --radius-sm: 8px;
    --shadow:    0 4px 24px rgba(0,0,0,.4);
    --transition: .2s ease;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    font-size: 15px;
    line-height: 1.6;
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2d3168; border-radius: 99px; }

/* ══════════════════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════════════════ */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: transform var(--transition);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .875rem;
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.brand-icon {
    width: 42px; height: 42px;
    background: linear-gradient(135deg, var(--purple), var(--pink));
    border-radius: 10px;
    display: grid; place-items: center;
    flex-shrink: 0;
    box-shadow: 0 0 20px rgba(99,102,241,.35);
}
.brand-icon svg { width: 22px; height: 22px; color: #fff; }

.brand-name { display: block; font-weight: 700; font-size: 1rem; letter-spacing: -.3px; }
.brand-sub  { display: block; font-size: .7rem; color: var(--text-muted); margin-top: 2px; }

.sidebar-nav {
    flex: 1;
    padding: 1rem .75rem;
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: .875rem;
    font-weight: 500;
    transition: all var(--transition);
    position: relative;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
    background: rgba(99,102,241,.15);
    color: var(--purple2);
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 20%; height: 60%;
    width: 3px;
    background: var(--purple);
    border-radius: 0 4px 4px 0;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
}
.server-badge {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .75rem;
    color: var(--text-muted);
}
.server-dot {
    width: 8px; height: 8px;
    background: var(--green);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--green);
    animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
    0%,100% { opacity: 1; }
    50%      { opacity: .5; }
}

/* ══════════════════════════════════════════════════════════
   MAIN WRAPPER & TOPBAR
   ══════════════════════════════════════════════════════════ */
.main-wrapper {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--topbar-h);
    background: rgba(13,15,26,.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.75rem;
}

.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: .375rem;
}
.hamburger span {
    display: block;
    width: 22px; height: 2px;
    background: var(--text-muted);
    border-radius: 2px;
    transition: var(--transition);
}

.topbar-title { flex: 1; font-weight: 600; font-size: 1rem; }

/* ══════════════════════════════════════════════════════════
   PAGES
   ══════════════════════════════════════════════════════════ */
.page { display: none; padding: 2rem 1.75rem; animation: fadeIn .3s ease; }
.page.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.page-header { margin-bottom: 2rem; }
.page-header h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -.5px; }
.page-header p  { color: var(--text-muted); margin-top: .25rem; font-size: .9rem; }

/* ── Stats Grid ───────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0,0,0,.35);
}
.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    background: rgba(var(--accent-rgb, 99,102,241),.15);
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    display: grid; place-items: center;
    flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; color: var(--accent); }
.stat-label { display: block; font-size: .8rem; color: var(--text-muted); margin-bottom: .25rem; }
.stat-value { display: block; font-size: 2rem; font-weight: 800; letter-spacing: -1px; color: var(--text-primary); }

.stat-glow {
    position: absolute;
    top: -40px; right: -40px;
    width: 120px; height: 120px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    pointer-events: none;
}

/* ── Info Grid ────────────────────────────────────────────── */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.25rem;
}
.info-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}
.info-card h3 {
    display: flex; align-items: center; gap: .5rem;
    font-size: 1rem; font-weight: 600; margin-bottom: 1rem;
    color: var(--text-primary);
}
.info-card h3 svg { color: var(--purple); }
.info-card p { color: var(--text-muted); font-size: .875rem; line-height: 1.7; }

.feature-list {
    list-style: none;
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: .4rem;
}
.feature-list li { font-size: .875rem; color: var(--text-muted); }

.tech-badges { display: flex; flex-wrap: wrap; gap: .5rem; }
.tech-badge {
    padding: .3rem .75rem;
    background: rgba(99,102,241,.12);
    color: var(--purple2);
    border: 1px solid rgba(99,102,241,.25);
    border-radius: 99px;
    font-size: .75rem;
    font-weight: 600;
}

/* ══════════════════════════════════════════════════════════
   TOOLBAR
   ══════════════════════════════════════════════════════════ */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: 1.25rem;
    align-items: center;
}
.search-wrap {
    position: relative;
    flex: 1;
    min-width: 220px;
}
.search-icon {
    position: absolute;
    left: .875rem; top: 50%;
    transform: translateY(-50%);
    width: 16px; height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}
.search-input {
    width: 100%;
    padding: .625rem .875rem .625rem 2.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: .875rem;
    outline: none;
    transition: border-color var(--transition);
}
.search-input:focus { border-color: var(--border-focus); }
.search-input::placeholder { color: var(--text-faint); }

.filter-wrap { display: flex; gap: .75rem; flex-wrap: wrap; }
.filter-select {
    padding: .625rem .875rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: .875rem;
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition);
}
.filter-select:focus { border-color: var(--border-focus); }

/* ══════════════════════════════════════════════════════════
   TABLE
   ══════════════════════════════════════════════════════════ */
.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--bg-card2); border-bottom: 1px solid var(--border); }
th {
    padding: .875rem 1rem;
    text-align: left;
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    white-space: nowrap;
}
td {
    padding: .875rem 1rem;
    font-size: .875rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--bg-hover); }

/* IPK color coding */
.ipk-high   { color: var(--green);  font-weight: 600; }
.ipk-mid    { color: var(--amber);  font-weight: 600; }
.ipk-low    { color: var(--red);    font-weight: 600; }

/* Status badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .25rem .625rem;
    border-radius: 99px;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .03em;
}
.badge-aktif   { background: rgba(16,185,129,.15); color: var(--green); border: 1px solid rgba(16,185,129,.3); }
.badge-cuti    { background: rgba(245,158,11,.15); color: var(--amber); border: 1px solid rgba(245,158,11,.3); }
.badge-lulus   { background: rgba(99,102,241,.15); color: var(--purple2); border: 1px solid rgba(99,102,241,.3); }
.badge-dropout { background: rgba(239,68,68,.15); color: var(--red); border: 1px solid rgba(239,68,68,.3); }

/* Action buttons */
.action-btns { display: flex; gap: .5rem; }
.btn-icon {
    width: 32px; height: 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-base);
    color: var(--text-muted);
    cursor: pointer;
    display: grid; place-items: center;
    transition: all var(--transition);
}
.btn-icon svg { width: 14px; height: 14px; }
.btn-icon.edit:hover  { background: rgba(99,102,241,.15); border-color: var(--purple); color: var(--purple2); }
.btn-icon.del:hover   { background: rgba(239,68,68,.15);  border-color: var(--red);    color: var(--red); }

.loading-cell, .empty-cell {
    text-align: center;
    padding: 3rem !important;
    color: var(--text-muted);
}
.loading-cell { display: flex; flex-direction: column; align-items: center; gap: .75rem; }

.spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--purple);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Table Footer */
.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
    padding: .875rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-card2);
}
.table-info { font-size: .8rem; color: var(--text-muted); }

/* Pagination */
.pagination { display: flex; gap: .375rem; }
.page-btn {
    width: 32px; height: 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-base);
    color: var(--text-muted);
    cursor: pointer;
    font-size: .8rem;
    font-weight: 500;
    transition: all var(--transition);
    display: grid; place-items: center;
}
.page-btn:hover     { border-color: var(--purple); color: var(--purple2); }
.page-btn.active    { background: var(--purple); border-color: var(--purple); color: #fff; }
.page-btn:disabled  { opacity: .35; cursor: not-allowed; }

/* ══════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn-primary {
    background: linear-gradient(135deg, var(--purple), #7c3aed);
    color: #fff;
    box-shadow: 0 4px 15px rgba(99,102,241,.3);
}
.btn-primary:hover { opacity: .9; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(99,102,241,.4); }
.btn-ghost  { background: var(--bg-hover); color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text-primary); }
.btn-danger { background: var(--red2); color: #fff; }
.btn-danger:hover { background: var(--red); }

.btn-spinner {
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

/* ══════════════════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.65);
    backdrop-filter: blur(4px);
    z-index: 500;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn .2s ease;
}
.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    animation: slideUp .25s ease;
}
.modal-sm { max-width: 420px; }

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 1.5rem 0;
}
.modal-header h2 { font-size: 1.125rem; font-weight: 700; }
.modal-close {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted);
    width: 32px; height: 32px;
    display: grid; place-items: center;
    border-radius: 6px;
    transition: background var(--transition);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-body  { padding: 1.5rem; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
    padding: 0 1.5rem 1.5rem;
}

/* Form */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-full  { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-group label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.required { color: var(--pink); }

.form-group input,
.form-group select {
    padding: .625rem .875rem;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: .875rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition);
}
.form-group input:focus,
.form-group select:focus  { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(99,102,241,.1); }
.form-group input::placeholder { color: var(--text-faint); }

/* Confirm dialog */
.confirm-icon {
    width: 64px; height: 64px;
    background: rgba(239,68,68,.12);
    border-radius: 50%;
    display: grid; place-items: center;
    margin: 0 auto 1rem;
}
.confirm-icon svg { width: 28px; height: 28px; color: var(--red); }
.confirm-sub { font-size: .8rem; color: var(--text-faint); margin-top: .375rem; text-align: center; }
#confirmMsg  { text-align: center; font-weight: 500; }

/* ══════════════════════════════════════════════════════════
   TOAST
   ══════════════════════════════════════════════════════════ */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    max-width: 360px;
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: 1rem 1.25rem;
    background: var(--bg-card2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    animation: slideInRight .3s ease;
    font-size: .875rem;
}
.toast-success { border-left: 3px solid var(--green); }
.toast-error   { border-left: 3px solid var(--red); }
.toast-title   { font-weight: 600; margin-bottom: .125rem; }
.toast-msg     { color: var(--text-muted); font-size: .8rem; }
.toast-icon svg { width: 18px; height: 18px; flex-shrink: 0; }
.toast-success .toast-icon svg { color: var(--green); }
.toast-error   .toast-icon svg { color: var(--red); }

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.5); }
    .main-wrapper { margin-left: 0; }
    .hamburger { display: flex; }
    .form-grid { grid-template-columns: 1fr; }
    .form-full { grid-column: 1; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .page { padding: 1.25rem 1rem; }
    .topbar { padding: 0 1rem; }
    .btn-add .btn-text { display: none; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .filter-wrap { flex-direction: column; }
}
