/* =========================================================
   main.css — Global layout, typography, and component styles
   ========================================================= */

/* ── CSS variables ───────────────────────────────────────── */
:root {
  --color-primary:     #2563eb;
  --color-primary-dk:  #1d4ed8;
  --color-danger:      #dc2626;
  --color-success:     #16a34a;
  --color-warning:     #d97706;
  --color-bg:          #f1f5f9;
  --color-surface:     #ffffff;
  --color-border:      #e2e8f0;
  --color-text:        #1e293b;
  --color-text-muted:  #64748b;
  --color-sidebar-bg:  #1e293b;
  --color-sidebar-txt: #cbd5e1;
  --color-sidebar-act: #2563eb;
  --sidebar-width:     220px;
  --topbar-height:     56px;
  --radius:            8px;
  --shadow:            0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --transition:        0.18s ease;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  display: flex;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar-bg);
  color: var(--color-sidebar-txt);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 200;
  transition: transform var(--transition);
}
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo { font-size: 1.4rem; }
.sidebar-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .5px;
}
.nav-list { list-style: none; padding: 12px 0; flex: 1; overflow-y: auto; }
.nav-section {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--color-text-muted);
  padding: 14px 16px 4px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border-radius: 6px;
  margin: 1px 8px;
  font-size: 0.92rem;
  color: var(--color-sidebar-txt);
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-link.active { background: var(--color-sidebar-act); color: #fff; }
.nav-icon { font-size: 1rem; width: 20px; text-align: center; }
.sidebar-footer {
  padding: 12px 16px;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  border-top: 1px solid rgba(255,255,255,.08);
}

/* ── Layout ──────────────────────────────────────────────── */
.layout {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.topbar-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
}
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--color-text);
  padding: 4px;
}
.content {
  flex: 1;
  padding: 28px 28px 40px;
}

/* ── Card ────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 500;
  border: none;
  transition: background var(--transition), opacity var(--transition);
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary   { background: var(--color-primary); color: #fff; }
.btn-primary:hover   { background: var(--color-primary-dk); }
.btn-danger    { background: var(--color-danger);  color: #fff; }
.btn-danger:hover    { background: #b91c1c; }
.btn-secondary {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}
.btn-secondary:hover { background: #eff6ff; }
.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.btn-ghost:hover { background: var(--color-bg); }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

/* ── Table ───────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
thead th {
  text-align: left;
  padding: 10px 14px;
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--color-border);
}
tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: background var(--transition);
}
tbody tr:hover { background: #f8fafc; }
tbody td { padding: 10px 14px; vertical-align: middle; }
.actions-cell { display: flex; gap: 6px; align-items: center; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.badge-theory   { background: #dbeafe; color: #1d4ed8; }
.badge-lab      { background: #dcfce7; color: #15803d; }
.badge-combined { background: #fef9c3; color: #92400e; }
.badge-conflict { background: #fee2e2; color: #b91c1c; margin-right: 6px; }

/* Conflict details inside the timetable create modal */
.conflict-box {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-left: 4px solid var(--color-danger);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  line-height: 1.45;
}
.conflict-box.hidden { display: none; }
.conflict-list {
  list-style: none;
  margin-top: 8px;
}
.conflict-item { margin-top: 8px; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--color-text);
}
.form-label .required { color: var(--color-danger); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-control.is-invalid { border-color: var(--color-danger); }
.form-error {
  font-size: 0.8rem;
  color: var(--color-danger);
  margin-top: 4px;
}
.form-hint {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}
select.form-control { appearance: auto; }

/* Availability slot rows inside faculty form */
.slot-list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.slot-row {
  display: grid;
  grid-template-columns: 100px 1fr 1fr 32px;
  gap: 6px;
  align-items: center;
}
.btn-remove-slot {
  background: none;
  border: none;
  color: var(--color-danger);
  font-size: 1.1rem;
  padding: 0;
  line-height: 1;
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 16px;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--color-text-muted);
  line-height: 1;
  padding: 2px 6px;
}
.modal-close:hover { color: var(--color-text); }
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Toast ───────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 280px;
  max-width: 380px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--color-surface);
  border-left: 4px solid var(--color-primary);
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  font-size: 0.88rem;
  animation: slideIn .2s ease;
}
.toast.success { border-color: var(--color-success); }
.toast.error   { border-color: var(--color-danger); }
.toast.warning { border-color: var(--color-warning); }
.toast-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.toast-msg  { flex: 1; line-height: 1.4; }
.toast-close {
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--color-text-muted);
  padding: 0;
  flex-shrink: 0;
}
@keyframes slideIn {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Dashboard stat cards ────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-label { font-size: 0.78rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--color-primary); }

/* ── Misc helpers ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--color-text-muted);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 12px; }
.loading-text { color: var(--color-text-muted); padding: 40px; text-align: center; }
.text-muted { color: var(--color-text-muted); }
.mt-2  { margin-top: 8px; }
.mt-4  { margin-top: 16px; }

/* ── Responsive — collapse sidebar on narrow screens ─────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
  }
  .sidebar.open { transform: translateX(0); }
  .layout { margin-left: 0; }
  .menu-toggle { display: block; }
  .content { padding: 16px; }
}
