:root {
    --primary: #4f46e5;
    --primary-dark: #3730a3;
    --secondary: #6366f1;
    --sidebar-width: 260px;
    --sidebar-bg: #1e1b4b;
    --sidebar-text: #c7d2fe;
    --sidebar-active: #4f46e5;
    --topbar-h: 56px;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
}

* { box-sizing: border-box; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); margin: 0; }

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1000;
    transition: transform .3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}
.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    min-width: 0;
}
.sidebar-logo {
    display: block;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px;
    max-width: 36px;
    flex-shrink: 0;
    object-fit: contain;
    border-radius: 6px;
}
.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}
.sidebar-brand-name {
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}
.sidebar-school {
    color: var(--sidebar-text);
    font-size: .68rem;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    margin-top: 1px;
}
.sidebar-brand i { font-size: 1.4rem; color: #818cf8; }

.sidebar-menu { list-style: none; padding: 12px 0; margin: 0; flex: 1; }
.sidebar-menu li a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 20px; color: var(--sidebar-text);
    text-decoration: none; font-size: .875rem; border-radius: 0;
    transition: all .2s;
}
.sidebar-menu li a:hover, .sidebar-menu li a.active {
    background: var(--sidebar-active); color: #fff;
}
.sidebar-menu li a i { font-size: 1rem; width: 18px; text-align: center; }
.sidebar-title {
    padding: 14px 20px 4px;
    font-size: .68rem; font-weight: 600; letter-spacing: .08em;
    text-transform: uppercase; color: #6366f1;
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex; align-items: center; justify-content: space-between;
}
.user-info { display: flex; align-items: center; gap: 10px; }
.user-info .avatar { font-size: 1.6rem; color: #818cf8; }
.user-info .fw-semibold { color: #fff; font-size: .875rem; }
.user-info small { color: var(--sidebar-text); font-size: .75rem; }
.btn-logout { color: #f87171; font-size: 1.2rem; text-decoration: none; }
.btn-logout:hover { color: #fff; }

/* ===== MAIN CONTENT ===== */
.wrapper { display: flex; }
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1; min-height: 100vh;
    display: flex; flex-direction: column;
    transition: margin-left .3s ease;
}
.topbar {
    height: var(--topbar-h); background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px;
    padding: 0 20px; position: sticky; top: 0; z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.content-area { padding: 24px; flex: 1; }

/* ===== CARDS ===== */
.card {
    border: 1px solid var(--border); border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05); background: var(--card-bg);
}
.card-header { background: transparent; border-bottom: 1px solid var(--border); font-weight: 600; padding: 16px 20px; }
.card-body { padding: 20px; }

/* ===== STAT CARDS ===== */
.stat-card {
    border-radius: 12px; padding: 20px;
    display: flex; align-items: center; gap: 16px;
    background: var(--card-bg); border: 1px solid var(--border);
    transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.stat-icon {
    width: 52px; height: 52px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
}
.stat-icon.purple { background: #ede9fe; color: var(--primary); }
.stat-icon.blue   { background: #dbeafe; color: var(--info); }
.stat-icon.green  { background: #d1fae5; color: var(--success); }
.stat-icon.orange { background: #ffedd5; color: #f97316; }
.stat-icon.red    { background: #fee2e2; color: var(--danger); }
.stat-icon.teal   { background: #ccfbf1; color: #0d9488; }
.stat-num { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.stat-label { color: var(--muted); font-size: .8rem; margin-top: 4px; }

/* ===== TABLE ===== */
.table-responsive { border-radius: 8px; overflow: hidden; }
.table th { background: #f8fafc; font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 2px solid var(--border); }
.table td { vertical-align: middle; font-size: .875rem; }
.table-hover tbody tr:hover { background-color: #f8fafc; }

/* ===== BADGES ===== */
.badge-status { padding: 4px 10px; border-radius: 20px; font-size: .75rem; font-weight: 500; }
.badge-draft       { background: #f1f5f9; color: #475569; }
.badge-generated   { background: #dbeafe; color: #1e40af; }
.badge-conflict    { background: #fee2e2; color: #991b1b; }
.badge-approved    { background: #d1fae5; color: #065f46; }
.badge-published   { background: #bbf7d0; color: #14532d; }
.badge-archived    { background: #f3f4f6; color: #6b7280; }

/* ===== FORMS ===== */
.form-label { font-weight: 500; font-size: .875rem; margin-bottom: 6px; }
.form-control, .form-select {
    border: 1px solid var(--border); border-radius: 8px;
    font-size: .875rem; padding: 8px 12px;
    transition: border-color .2s, box-shadow .2s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}

/* ===== BUTTONS ===== */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn { border-radius: 8px; font-weight: 500; font-size: .875rem; }

/* ===== AUTH ===== */
.auth-wrapper {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%);
}
.auth-card {
    background: #fff; border-radius: 16px; padding: 40px;
    width: 100%; max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo i { font-size: 2.5rem; color: var(--primary); }
.auth-logo-img {
    width: 80px;
    height: 80px;
    max-width: 80px;
    max-height: 80px;
    object-fit: contain;
    margin: 0 auto 12px;
    display: block;
}
.auth-logo h1 { font-size: 1.5rem; font-weight: 700; color: var(--text); margin: 8px 0 4px; }
.auth-logo p { color: var(--muted); font-size: .85rem; }

/* ===== ROSTER GRID ===== */
.roster-grid { overflow-x: auto; }
.roster-table { min-width: 900px; border-collapse: collapse; width: 100%; }
.roster-table th, .roster-table td {
    border: 1px solid var(--border); padding: 6px 8px;
    font-size: .78rem; text-align: center; min-width: 90px;
}
.roster-table th { background: #f8fafc; font-weight: 600; }
.slot-kbm {
    background: #eff6ff; border-radius: 6px; padding: 4px 6px;
    cursor: pointer; transition: background .2s;
}
.slot-kbm:hover { background: #dbeafe; }
.slot-locked { background: #fee2e2; cursor: not-allowed; }
.slot-istirahat { background: #f0fdf4; }
.slot-event { background: #fef3c7; }
.slot-empty { color: #cbd5e1; font-style: italic; }

.mapel-name { font-weight: 600; color: var(--primary); font-size: .75rem; }
.guru-name  { font-size: .72rem; color: var(--muted); }

/* ===== SIDEBAR COLLAPSED ===== */
.sidebar-collapsed .sidebar { transform: translateX(-100%); }
.sidebar-collapsed .main-content { margin-left: 0; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .content-area { padding: 16px; }
}

/* ===== PAGE HEADER ===== */
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 1.4rem; font-weight: 700; margin: 0; }
.page-header p { color: var(--muted); margin: 4px 0 0; font-size: .875rem; }

/* ===== CONFLICT ITEMS ===== */
.conflict-item {
    border-left: 4px solid var(--danger);
    background: #fff5f5; padding: 12px 16px;
    border-radius: 0 8px 8px 0; margin-bottom: 8px;
}
.conflict-item.resolved { border-left-color: var(--success); background: #f0fdf4; }
