@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --c-primary: #4f46e5;
  --c-primary-dk: #4338ca;
  --c-primary-lt: #eef2ff;
  --c-success: #10b981;
  --c-success-lt: #d1fae5;
  --c-warning: #f59e0b;
  --c-warning-lt: #fef3c7;
  --c-danger: #ef4444;
  --c-danger-lt: #fee2e2;
  --c-info: #3b82f6;
  --c-info-lt: #dbeafe;
  --sb-bg: #0f172a;
  --sb-text: #94a3b8;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.1);
  --t-base: #1e293b;
  --t-muted: #64748b;
  --t-light: #94a3b8;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
}

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

html, body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  color: var(--t-base);
  background: var(--bg);
  height: 100%;
}

/* ===== LAYOUT ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  transform: translateX(-100%); /* HIDE BY DEFAULT */
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.active {
  transform: translateX(0); /* SHOW WHEN TOGGLED */
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand .brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--c-primary), #7c3aed);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.brand-text { color: #fff; }
.brand-text h2 { font-size: 15px; font-weight: 700; line-height: 1.2; }
.brand-text span { font-size: 11px; color: var(--sb-text); }

.sidebar-nav { flex: 1; padding: 16px 12px; }

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
  padding: 8px 10px 6px;
  margin-top: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  color: var(--sb-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.18s ease;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}

.nav-item.active {
  background: linear-gradient(135deg, var(--c-primary), #6d28d9);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79,70,229,0.35);
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 1.8; }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--c-primary), #7c3aed);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: 13px;
  flex-shrink: 0;
}

.user-name { color: #fff; font-size: 13px; font-weight: 600; line-height: 1.2; }
.user-role {
  font-size: 11px; color: var(--sb-text);
  text-transform: capitalize;
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  background: rgba(239,68,68,0.12);
  color: #f87171;
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.18s;
}
.btn-logout:hover { background: rgba(239,68,68,0.22); color: #fca5a5; }
.btn-logout svg { width: 16px; height: 16px; stroke-width: 2; }

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: 0; /* WIDE BY DEFAULT */
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-content.shifted {
  margin-left: var(--sidebar-w); /* SHIFT WHEN SIDEBAR ACTIVE */
}

.btn-sidebar-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--t-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: var(--r-sm);
  transition: background 0.2s, color 0.2s;
}

.btn-sidebar-toggle:hover {
  background: var(--border);
  color: var(--t-base);
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.active {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .main-content {
    margin-left: 0;
  }
  .main-content.shifted {
    margin-left: 0; /* Don't shift main content on mobile */
  }
}

.topbar {
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}

.topbar-left h1 { font-size: 18px; font-weight: 700; color: var(--t-base); }
.topbar-left .breadcrumb { font-size: 12px; color: var(--t-muted); margin-top: 1px; }

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

.content-area {
  flex: 1;
  padding: 28px;
}

/* ===== CARDS ===== */
.card {
  background: var(--card);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title { font-size: 15px; font-weight: 700; }
.card-body { padding: 22px; }

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

.stat-card {
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-icon.primary { background: var(--c-primary-lt); }
.stat-icon.success { background: var(--c-success-lt); }
.stat-icon.warning { background: var(--c-warning-lt); }
.stat-icon.danger { background: var(--c-danger-lt); }

.stat-value { font-size: 26px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 12px; color: var(--t-muted); margin-top: 3px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.18s;
  white-space: nowrap;
}

.btn svg { width: 15px; height: 15px; stroke-width: 2.2; }

.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-dk); box-shadow: 0 4px 12px rgba(79,70,229,0.3); transform: translateY(-1px); }

.btn-success { background: var(--c-success); color: #fff; }
.btn-success:hover { background: #059669; box-shadow: 0 4px 12px rgba(16,185,129,0.3); transform: translateY(-1px); }

.btn-warning { background: var(--c-warning); color: #fff; }
.btn-warning:hover { background: #d97706; }

.btn-danger { background: var(--c-danger); color: #fff; }
.btn-danger:hover { background: #dc2626; box-shadow: 0 4px 12px rgba(239,68,68,0.3); }

.btn-secondary { background: #f1f5f9; color: var(--t-base); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e2e8f0; }

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

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 600;
}

.badge-success { background: var(--c-success-lt); color: #065f46; }
.badge-warning { background: var(--c-warning-lt); color: #92400e; }
.badge-danger { background: var(--c-danger-lt); color: #991b1b; }
.badge-info { background: var(--c-info-lt); color: #1e40af; }
.badge-secondary { background: #f1f5f9; color: var(--t-muted); }
.badge-primary { background: var(--c-primary-lt); color: #3730a3; }

/* ===== TABLE ===== */
.table-container {
  overflow: auto;
  border-radius: var(--r-lg);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table thead th {
  background: #f8fafc;
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--t-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafbff; }

.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }

/* ===== FORMS ===== */
.form-grid { display: grid; gap: 16px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }

.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--t-base);
}

.form-label span { color: var(--c-danger); margin-left: 2px; }

.form-control, .form-select {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--t-base);
  background: #fff;
  transition: border-color 0.18s, box-shadow 0.18s;
  width: 100%;
}

.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

.form-control::placeholder { color: var(--t-light); }
.form-hint { font-size: 11.5px; color: var(--t-muted); margin-top: 3px; }

/* ===== FILTER BAR ===== */
.filter-bar {
  background: var(--card);
  border-radius: var(--r-xl);
  padding: 16px 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filter-bar label { font-size: 12.5px; font-weight: 600; color: var(--t-muted); white-space: nowrap; }
.filter-bar .form-control,
.filter-bar .form-select { max-width: 200px; padding: 7px 10px; }
.filter-bar .sep { flex: 1; }

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.show { display: flex; }

.modal-box {
  background: var(--card);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 540px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.22s ease;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-box.modal-lg { max-width: 720px; }
.modal-box.modal-sm { max-width: 400px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { font-size: 16px; font-weight: 700; }

.modal-close {
  width: 30px; height: 30px;
  border: none;
  background: #f1f5f9;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--t-muted);
  transition: all 0.15s;
}
.modal-close:hover { background: #e2e8f0; color: var(--t-base); }

.modal-body { padding: 22px; }
.modal-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ===== ALERTS ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.alert-success { background: var(--c-success-lt); color: #065f46; border-left: 4px solid var(--c-success); }
.alert-danger { background: var(--c-danger-lt); color: #991b1b; border-left: 4px solid var(--c-danger); }
.alert-warning { background: var(--c-warning-lt); color: #92400e; border-left: 4px solid var(--c-warning); }
.alert-info { background: var(--c-info-lt); color: #1e40af; border-left: 4px solid var(--c-info); }

/* ===== OCCUPANCY GRID ===== */
.occ-wrapper {
  overflow: auto;
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.occ-break-row td {
  background-color: rgba(239, 68, 68, 0.08) !important;
  color: #ef4444;
  font-weight: 500;
  border-bottom: 1px solid rgba(239, 68, 68, 0.2);
}
.occ-break-row .occ-time-col {
  color: #ef4444;
}

table.occ-table {
  border-collapse: collapse;
  font-size: 11px;
  width: 100%;
  table-layout: fixed; /* Ensures columns fit equally */
}

.occ-table th, .occ-table td {
  border: 1px solid #e2e8f0;
  text-align: center;
  vertical-align: middle;
}

.occ-time-col {
  background: #f8fafc;
  font-weight: 700;
  font-size: 10px;
  color: var(--t-muted);
  width: 55px;
  position: sticky;
  left: 0;
  z-index: 20;
  padding: 4px 2px;
  border-right: 2px solid #cbd5e1;
  text-align: center;
}

.occ-gedung-th {
  background: linear-gradient(135deg, #1e3a8a, #1e40af);
  color: #fff;
  font-weight: 700;
  padding: 6px 2px;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.occ-room-th {
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  padding: 4px 2px;
  font-size: 10px;
  min-width: 40px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.occ-cell {
  position: relative;
  height: 44px;
  min-width: 40px;
  cursor: pointer;
  transition: background 0.15s;
  padding: 2px;
}

.occ-cell:hover { background: #f0f4ff; }

.occ-cell.has-event { cursor: default; }

.event-block {
  position: absolute;
  inset: 1px;
  border-radius: 4px;
  padding: 2px 3px;
  font-size: 9px;
  color: #000;
  text-shadow: 0 1px 1px rgba(255,255,255,0.7);
  overflow: hidden;
  line-height: 1.1;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.event-block:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  z-index: 10;
}

.event-block.ev-jadwal {
  background: linear-gradient(135deg, #4f46e5, #6d28d9);
}

.event-block.ev-approved {
  background: linear-gradient(135deg, #059669, #047857);
}

.event-block.ev-pending {
  background: linear-gradient(135deg, #d97706, #b45309);
}

.event-block.ev-rejected {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  opacity: 0.7;
}

.event-block .ev-code { font-weight: 700; font-size: 8px; opacity: 0.85; display: none; }
.event-block .ev-name { font-weight: 700; font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-block .ev-info { font-size: 8px; opacity: 0.85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Occupancy legend */
.occ-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 12px; height: 12px;
  border-radius: 3px;
}

.ld-jadwal { background: #4f46e5; }
.ld-approved { background: #059669; }
.ld-pending { background: #d97706; }
.ld-empty { background: #e2e8f0; border: 1px solid #cbd5e1; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--t-muted);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--t-base); margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

/* ===== UTILITIES ===== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-sm { font-size: 12.5px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--t-muted); }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ===== TOAST ===== */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #1e293b;
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease;
  max-width: 340px;
}

.toast.toast-success { background: #065f46; border-left: 4px solid var(--c-success); }
.toast.toast-error { background: #7f1d1d; border-left: 4px solid var(--c-danger); }

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

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { width: 220px; transform: translateX(-220px); transition: transform 0.25s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}