/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #f3f4f8;
    color: #1f2937;
    min-height: 100vh;
    overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; }

/* ===== CSS VARIABLES (defaults, overridden by inline style from PHP) ===== */
:root {
    --color-primary: #1a56db;
    --color-secondary: #1e429f;
    --color-primary-light: #1a56db22;
    --color-primary-hover: #1e429f;
    --sidebar-width: 260px;
    --navbar-height: 60px;
    --radius: 10px;
    --shadow: 0 2px 12px rgba(0,0,0,.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
    --transition: all .25s ease;
}

/* ===== NAVBAR ===== */
.navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--navbar-height);
    background: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.navbar-left, .navbar-right { display: flex; align-items: center; gap: .75rem; }

/* Hamburger */
.hamburger {
    background: none; border: none; cursor: pointer;
    display: flex; flex-direction: column; gap: 5px;
    padding: 8px; border-radius: 6px;
    transition: var(--transition);
}
.hamburger:hover { background: rgba(255,255,255,.15); }
.hamburger span {
    display: block; width: 22px; height: 2px;
    background: #fff; border-radius: 2px;
    transition: var(--transition);
}
.hamburger.open span:nth-child(1) { transform: rotate(45deg) translate(5px,5px); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: rotate(-45deg) translate(5px,-5px); }

.navbar-brand { display: flex; align-items: center; gap: .5rem; color: #fff; font-weight: 700; font-size: 1.1rem; }
.navbar-brand i { font-size: 1.3rem; }
.brand-text { display: block; }

.tp-badge {
    background: rgba(255,255,255,.15);
    color: #fff; font-size: .75rem;
    padding: .25rem .75rem; border-radius: 20px;
    display: none;
}
@media(min-width:640px){ .tp-badge { display: flex; align-items: center; gap: .4rem; } }

/* User Menu */
.user-menu { position: relative; }
.user-btn {
    display: flex; align-items: center; gap: .5rem;
    background: rgba(255,255,255,.15); border: none; cursor: pointer;
    color: #fff; padding: .35rem .75rem; border-radius: 25px;
    font-size: .875rem; transition: var(--transition);
}
.user-btn:hover { background: rgba(255,255,255,.25); }
.user-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: rgba(255,255,255,.3);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .85rem;
}
.user-name { display: none; }
@media(min-width:480px){ .user-name { display: block; } }

.user-dropdown {
    display: none; position: absolute; right: 0; top: calc(100% + 8px);
    background: #fff; border-radius: var(--radius);
    box-shadow: var(--shadow-lg); min-width: 180px;
    overflow: hidden; z-index: 2000;
}
.user-dropdown.show { display: block; animation: fadeDown .2s ease; }
.user-dropdown a {
    display: flex; align-items: center; gap: .6rem;
    padding: .7rem 1rem; font-size: .875rem; color: #374151;
    transition: var(--transition);
}
.user-dropdown a:hover { background: var(--color-primary-light); color: var(--color-primary); }
.user-dropdown a i { width: 16px; text-align: center; }
.dropdown-divider { border-top: 1px solid #f3f4f6; }

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: var(--navbar-height); left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: #fff;
    box-shadow: var(--shadow-lg);
    z-index: 900;
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateX(-100%);
    transition: transform .3s ease;
}
.sidebar.open { transform: translateX(0); }
@media(min-width:1024px) {
    .sidebar { transform: translateX(0); box-shadow: none; border-right: 1px solid #e5e7eb; }
}

/* Sidebar header */
.sidebar-header {
    padding: 1.25rem 1rem;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: #fff;
}
.sidebar-logo { display: flex; align-items: center; gap: .75rem; }
.sidebar-logo > i { font-size: 1.8rem; opacity: .9; }
.sidebar-title { font-weight: 700; font-size: 1rem; line-height: 1.2; }
.sidebar-subtitle { font-size: .75rem; opacity: .8; }

/* Sidebar nav */
.sidebar-nav { padding: .5rem 0 2rem; }
.nav-section-label {
    font-size: .65rem; font-weight: 700;
    letter-spacing: .1em; text-transform: uppercase;
    color: #9ca3af; padding: 1rem 1rem .35rem;
}
.nav-item {
    display: flex; align-items: center; gap: .75rem;
    padding: .65rem 1rem; color: #4b5563;
    font-size: .875rem; font-weight: 500;
    border-left: 3px solid transparent;
    transition: var(--transition); cursor: pointer;
}
.nav-item i { width: 18px; text-align: center; font-size: .95rem; flex-shrink: 0; }
.nav-item:hover { background: var(--color-primary-light); color: var(--color-primary); border-left-color: var(--color-primary); }
.nav-item.active { background: var(--color-primary-light); color: var(--color-primary); border-left-color: var(--color-primary); font-weight: 600; }
.nav-item-danger { color: #ef4444; }
.nav-item-danger:hover { background: #fef2f2; color: #dc2626; border-left-color: #dc2626; }

/* Overlay mobile */
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.5); z-index: 850;
}
.sidebar-overlay.show { display: block; }

/* ===== MAIN CONTENT ===== */
.main-content {
    padding-top: var(--navbar-height);
    min-height: 100vh;
    transition: margin-left .3s ease;
}
@media(min-width:1024px) { .main-content { margin-left: var(--sidebar-width); } }

/* Page header */
.page-header {
    background: #fff; padding: 1rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex; flex-direction: column; gap: .35rem;
}
.page-title { font-size: 1.25rem; font-weight: 700; color: #111827; }
.breadcrumb { display: flex; align-items: center; gap: .35rem; font-size: .8rem; color: #6b7280; flex-wrap: wrap; }
.breadcrumb a { color: var(--color-primary); }
.breadcrumb .sep { font-size: .6rem; opacity: .6; }

/* Page content */
.page-content { padding: 1.25rem; }
@media(min-width:768px) { .page-content { padding: 1.5rem 2rem; } }

/* ===== CARDS ===== */
.card {
    background: #fff; border-radius: var(--radius);
    box-shadow: var(--shadow); overflow: hidden;
    margin-bottom: 1.25rem;
}
.card-header {
    padding: 1rem 1.25rem; border-bottom: 1px solid #f3f4f6;
    display: flex; align-items: center; justify-content: space-between;
    gap: .5rem; flex-wrap: wrap;
}
.card-title { font-size: 1rem; font-weight: 700; color: #111827; display: flex; align-items: center; gap: .5rem; }
.card-title i { color: var(--color-primary); }
.card-body { padding: 1.25rem; }

/* ===== STATS GRID ===== */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
@media(min-width:640px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media(min-width:1024px) { .stats-grid { grid-template-columns: repeat(4, 1fr); } }

.stat-card {
    background: #fff; border-radius: var(--radius);
    padding: 1.25rem; box-shadow: var(--shadow);
    display: flex; align-items: center; gap: 1rem;
    transition: var(--transition); border-left: 4px solid var(--color-primary);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-icon {
    width: 50px; height: 50px; border-radius: 10px;
    background: var(--color-primary-light);
    display: flex; align-items: center; justify-content: center;
    color: var(--color-primary); font-size: 1.4rem; flex-shrink: 0;
}
.stat-icon.green { background: #d1fae5; color: #059669; }
.stat-icon.orange { background: #fef3c7; color: #d97706; }
.stat-icon.red { background: #fee2e2; color: #dc2626; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-value { font-size: 1.8rem; font-weight: 800; color: #111827; line-height: 1; }
.stat-label { font-size: .8rem; color: #6b7280; margin-top: .2rem; }

/* ===== GRID LAYOUT ===== */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 1.25rem; }
@media(min-width:768px) { .grid-2 { grid-template-columns: repeat(2, 1fr); } }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: 1.25rem; }
@media(min-width:640px) { .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media(min-width:1024px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

/* ===== TABLES ===== */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead tr { background: var(--color-primary); color: #fff; }
thead th { padding: .75rem 1rem; text-align: left; font-weight: 600; white-space: nowrap; }
tbody tr { border-bottom: 1px solid #f3f4f6; transition: var(--transition); }
tbody tr:hover { background: var(--color-primary-light); }
tbody td { padding: .7rem 1rem; color: #374151; }
tbody tr:last-child { border-bottom: none; }

/* ===== BADGES ===== */
.badge {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .2rem .65rem; border-radius: 20px;
    font-size: .72rem; font-weight: 600; white-space: nowrap;
}
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-gray { background: #f3f4f6; color: #374151; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-orange { background: #ffedd5; color: #9a3412; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .5rem 1rem; border-radius: 8px; border: none;
    font-size: .875rem; font-weight: 600; cursor: pointer;
    transition: var(--transition); white-space: nowrap;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-secondary); transform: translateY(-1px); }
.btn-secondary { background: #f3f4f6; color: #374151; }
.btn-secondary:hover { background: #e5e7eb; }
.btn-success { background: #059669; color: #fff; }
.btn-success:hover { background: #047857; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-sm { padding: .3rem .75rem; font-size: .8rem; }
.btn-lg { padding: .7rem 1.5rem; font-size: 1rem; }
.btn-outline { background: transparent; border: 2px solid var(--color-primary); color: var(--color-primary); }
.btn-outline:hover { background: var(--color-primary); color: #fff; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .875rem; font-weight: 600; color: #374151; margin-bottom: .4rem; }
.form-control {
    width: 100%; padding: .6rem .875rem;
    border: 2px solid #e5e7eb; border-radius: 8px;
    font-size: .875rem; color: #374151;
    transition: var(--transition); background: #fff;
    font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-light); }
.form-control:disabled { background: #f9fafb; cursor: not-allowed; }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media(min-width:640px) { .form-row.cols-2 { grid-template-columns: repeat(2, 1fr); } }
@media(min-width:768px) { .form-row.cols-3 { grid-template-columns: repeat(3, 1fr); } }
.form-hint { font-size: .75rem; color: #9ca3af; margin-top: .25rem; }
.form-error { font-size: .75rem; color: #ef4444; margin-top: .25rem; }

/* ===== ALERTS ===== */
.alert {
    padding: .85rem 1rem; border-radius: 8px;
    margin-bottom: 1rem; display: flex; align-items: flex-start; gap: .6rem;
    font-size: .875rem; border-left: 4px solid;
}
.alert i { margin-top: .1rem; flex-shrink: 0; }
.alert-success { background: #d1fae5; color: #065f46; border-color: #059669; }
.alert-danger { background: #fee2e2; color: #991b1b; border-color: #ef4444; }
.alert-warning { background: #fef3c7; color: #92400e; border-color: #f59e0b; }
.alert-info { background: #dbeafe; color: #1e40af; border-color: #3b82f6; }

/* ===== MODAL ===== */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.5); z-index: 3000;
    align-items: center; justify-content: center;
    padding: 1rem;
}
.modal-overlay.show { display: flex; animation: fadeIn .2s ease; }
.modal {
    background: #fff; border-radius: 14px;
    width: 100%; max-width: 600px;
    box-shadow: var(--shadow-lg); max-height: 90vh;
    display: flex; flex-direction: column;
}
.modal-header {
    padding: 1.25rem 1.5rem; border-bottom: 1px solid #f3f4f6;
    display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 1.1rem; font-weight: 700; color: #111827; }
.modal-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #9ca3af; transition: var(--transition); }
.modal-close:hover { color: #ef4444; }
.modal-body { padding: 1.5rem; overflow-y: auto; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid #f3f4f6; display: flex; justify-content: flex-end; gap: .75rem; }

/* ===== TIMELINE ===== */
.timeline { position: relative; padding-left: 1.5rem; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 0; bottom: 0; width: 2px; background: #e5e7eb; }
.timeline-item { position: relative; margin-bottom: 1.25rem; }
.timeline-item::before {
    content: ''; position: absolute; left: -1.5rem; top: 4px;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--color-primary); border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--color-primary);
}
.timeline-date { font-size: .75rem; color: #9ca3af; margin-bottom: .2rem; }
.timeline-title { font-size: .875rem; font-weight: 600; color: #111827; }
.timeline-desc { font-size: .8rem; color: #6b7280; margin-top: .15rem; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 3rem 1rem; color: #9ca3af; }
.empty-state i { font-size: 3rem; margin-bottom: 1rem; opacity: .5; }
.empty-state h3 { font-size: 1rem; color: #6b7280; margin-bottom: .5rem; }
.empty-state p { font-size: .875rem; }

/* ===== SEARCH & FILTER BAR ===== */
.filter-bar {
    display: flex; flex-wrap: wrap; gap: .75rem;
    align-items: center; margin-bottom: 1rem;
}
.search-box { position: relative; flex: 1; min-width: 200px; }
.search-box i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: #9ca3af; font-size: .875rem; }
.search-box input { padding-left: 2.25rem; }
.filter-selects { display: flex; gap: .5rem; flex-wrap: wrap; }
.filter-selects select { width: auto; }

/* ===== PROGRESS BAR ===== */
.progress { background: #f3f4f6; border-radius: 20px; height: 8px; overflow: hidden; margin-top: .35rem; }
.progress-bar { height: 100%; background: var(--color-primary); border-radius: 20px; transition: width .4s ease; }
.progress-bar.green { background: #059669; }
.progress-bar.orange { background: #f59e0b; }
.progress-bar.red { background: #ef4444; }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { transform: translateX(-20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== UTILITIES ===== */
.text-primary { color: var(--color-primary) !important; }
.text-muted { color: #9ca3af !important; }
.text-sm { font-size: .8rem; }
.text-xs { font-size: .72rem; }
.fw-bold { font-weight: 700; }
.mt-1 { margin-top: .5rem; }
.mb-1 { margin-bottom: .5rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.justify-between { justify-content: space-between; }
.action-btns { display: flex; gap: .4rem; flex-wrap: wrap; }

/* ===== LOGIN PAGE ===== */
.login-page { min-height: 100vh; background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card { background: #fff; border-radius: 16px; padding: 2.5rem 2rem; width: 100%; max-width: 420px; box-shadow: var(--shadow-lg); }
.login-logo { text-align: center; margin-bottom: 1.5rem; }
.login-logo i { font-size: 3rem; color: var(--color-primary); }
.login-logo h1 { font-size: 1.4rem; font-weight: 800; color: #111827; margin-top: .5rem; }
.login-logo p { font-size: .875rem; color: #6b7280; margin-top: .25rem; }

/* ===== CALENDAR ===== */
.calendar-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 3px; }
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.cal-day-name { text-align: center; font-size: .7rem; font-weight: 700; color: #9ca3af; padding: .3rem; }
.cal-day {
    aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
    border-radius: 8px; font-size: .8rem; cursor: default; transition: var(--transition);
    position: relative;
}
.cal-day.other-month { opacity: .35; }
.cal-day.today { background: var(--color-primary); color: #fff; font-weight: 700; }
.cal-day.has-event { font-weight: 700; }
.cal-day .event-dot { width: 5px; height: 5px; border-radius: 50%; position: absolute; bottom: 3px; }
.cal-day.libur .event-dot { background: #ef4444; }
.cal-day.ujian .event-dot { background: #f59e0b; }
.cal-day.kegiatan .event-dot { background: #059669; }

/* Print */
@media print {
    .sidebar, .navbar, .hamburger, .btn, .filter-bar { display: none !important; }
    .main-content { margin: 0 !important; padding: 0 !important; }
}
