/* =====================================================
   Teacher Housing Management System - Premium UI
   โรงเรียนปัว
   ===================================================== */

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

:root {
  --primary:       #4c1d95;
  --primary-light: #7c3aed;
  --primary-dark:  #2e1065;
  --secondary:     #c8a84b;
  --secondary-light:#e4c76b;
  --accent:        #e74c3c;
  --success:       #27ae60;
  --warning:       #f39c12;
  --info:          #2980b9;
  --danger:        #c0392b;
  --light-bg:      #f5f3ff;
  --card-bg:       #ffffff;
  --sidebar-w:     260px;
  --topbar-h:      64px;
  --shadow-sm:     0 2px 8px rgba(0,0,0,.08);
  --shadow-md:     0 4px 20px rgba(0,0,0,.12);
  --shadow-lg:     0 8px 40px rgba(0,0,0,.16);
  --radius:        12px;
  --radius-sm:     8px;
  --transition:    all .25s ease;
}

* { box-sizing: border-box; }

body {
  font-family: 'Sarabun', sans-serif;
  font-size: 15px;
  background: var(--light-bg);
  color: #2c3e50;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
  z-index: 1040;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 20px rgba(0,0,0,.2);
  transition: var(--transition);
  overflow: hidden;
}

.sidebar-brand {
  padding: 24px 20px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  text-decoration: none;
  flex-shrink: 0;
}

.sidebar-brand-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--secondary), var(--secondary-light));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(200,168,75,.4);
}

.sidebar-brand-text { flex: 1; }
.sidebar-brand-text .school-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--secondary-light);
  letter-spacing: .5px;
  line-height: 1.3;
}
.sidebar-brand-text .system-name {
  display: block;
  font-size: 11px;
  color: rgba(255,255,255,.6);
  line-height: 1.3;
  margin-top: 2px;
}

.sidebar-user-card {
  margin: 16px 12px;
  background: rgba(255,255,255,.08);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-avatar {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--secondary), #e8b84b);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-dark);
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 11px;
  color: rgba(255,255,255,.55);
  margin-top: 2px;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 2px; }

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,.35);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding: 16px 20px 6px;
}

.nav-item { margin: 1px 10px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
}
.nav-link:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
  transform: translateX(2px);
}
.nav-link.active {
  background: linear-gradient(135deg, var(--secondary), var(--secondary-light));
  color: var(--primary-dark);
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(200,168,75,.35);
}
.nav-link .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}
.nav-link .badge {
  margin-left: auto;
  font-size: 10px;
  padding: 2px 7px;
}

.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}
.sidebar-footer .nav-link { color: rgba(255,255,255,.6); }
.sidebar-footer .nav-link:hover { color: var(--accent); background: rgba(231,76,60,.1); }

/* ===== TOPBAR ===== */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #e8edf2;
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 1030;
  box-shadow: var(--shadow-sm);
  gap: 16px;
}

.topbar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--primary);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
}

.topbar-breadcrumb {
  flex: 1;
}
.topbar-breadcrumb .page-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
  line-height: 1;
}
.topbar-breadcrumb .breadcrumb {
  margin: 0;
  font-size: 12px;
  background: none;
  padding: 0;
}
.topbar-breadcrumb .breadcrumb-item + .breadcrumb-item::before { color: #aab4be; }
.topbar-breadcrumb .breadcrumb-item a { color: var(--primary-light); text-decoration: none; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.topbar-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid #e8edf2;
  background: #f8fafb;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: #5a6575;
  font-size: 16px;
  transition: var(--transition);
  position: relative;
  text-decoration: none;
}
.topbar-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.topbar-btn .badge { position: absolute; top: -4px; right: -4px; font-size: 9px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  color: inherit;
}
.topbar-user:hover { background: var(--light-bg); }
.topbar-user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}
.topbar-user-info .user-name { font-size: 13px; font-weight: 600; color: var(--primary); line-height: 1.2; }
.topbar-user-info .user-role { font-size: 11px; color: #8696a0; }

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-w);
  padding-top: var(--topbar-h);
  min-height: 100vh;
}

.content-wrapper {
  padding: 24px;
}

/* ===== CARDS ===== */
.card {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: var(--card-bg);
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  background: transparent;
  border-bottom: 1px solid #eef2f7;
  padding: 18px 22px 16px;
  border-radius: var(--radius) var(--radius) 0 0 !important;
}
.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
}
.card-body { padding: 22px; }

/* ===== STAT CARDS ===== */
.stat-card {
  border-radius: var(--radius);
  padding: 22px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  cursor: default;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card::before {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
}
.stat-card::after {
  content: '';
  position: absolute;
  bottom: -20px; right: 20px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,.07);
}
.stat-card-blue    { background: linear-gradient(135deg, #4c1d95, #7c3aed); color: #fff; }
.stat-card-gold    { background: linear-gradient(135deg, #b8860b, #c8a84b); color: #fff; }
.stat-card-green   { background: linear-gradient(135deg, #1a7a4e, #27ae60); color: #fff; }
.stat-card-red     { background: linear-gradient(135deg, #c0392b, #e74c3c); color: #fff; }
.stat-card-purple  { background: linear-gradient(135deg, #6c3483, #9b59b6); color: #fff; }
.stat-card-teal    { background: linear-gradient(135deg, #117a65, #1abc9c); color: #fff; }

.stat-icon {
  width: 52px; height: 52px;
  background: rgba(255,255,255,.2);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  margin-bottom: 16px;
  position: relative; z-index: 1;
}
.stat-value {
  font-size: 36px;
  font-weight: 800;
  line-height: 1;
  position: relative; z-index: 1;
}
.stat-label {
  font-size: 13px;
  opacity: .85;
  margin-top: 6px;
  font-weight: 500;
  position: relative; z-index: 1;
}
.stat-trend {
  font-size: 12px;
  opacity: .75;
  margin-top: 4px;
  position: relative; z-index: 1;
}

/* ===== STATUS BADGES ===== */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.status-pending      { background: #fef9e7; color: #d4a017; border: 1px solid #f9e07a; }
.status-staff_approved    { background: #e3f2fd; color: #1565c0; border: 1px solid #90caf9; }
.status-staff_rejected    { background: #fde8e8; color: #c62828; border: 1px solid #ef9a9a; }
.status-deputy_approved   { background: #e8eaf6; color: #3949ab; border: 1px solid #9fa8da; }
.status-deputy_rejected   { background: #fde8e8; color: #c62828; border: 1px solid #ef9a9a; }
.status-director_approved { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.status-director_rejected { background: #fde8e8; color: #c62828; border: 1px solid #ef9a9a; }
.status-completed    { background: #e0f7ef; color: #00695c; border: 1px solid #80cbc4; }
.status-cancelled    { background: #f5f5f5; color: #757575; border: 1px solid #e0e0e0; }

/* ===== BUTTONS ===== */
.btn { border-radius: 8px; font-weight: 600; font-size: 14px; padding: 8px 18px; transition: var(--transition); }
.btn-sm { font-size: 13px; padding: 5px 12px; }
.btn-primary { background: linear-gradient(135deg, var(--primary-light), var(--primary)); border: none; }
.btn-primary:hover { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); box-shadow: 0 4px 12px rgba(76,29,149,.3); }
.btn-gold { background: linear-gradient(135deg, var(--secondary), var(--secondary-light)); border: none; color: var(--primary-dark); }
.btn-gold:hover { box-shadow: 0 4px 12px rgba(200,168,75,.4); color: var(--primary-dark); }
.btn-success { background: linear-gradient(135deg, #1a7a4e, var(--success)); border: none; }
.btn-danger  { background: linear-gradient(135deg, #c0392b, var(--danger)); border: none; }
.btn-outline-primary { border: 2px solid var(--primary); color: var(--primary); background: transparent; }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }

/* ===== FORMS ===== */
.form-label { font-weight: 600; font-size: 14px; color: #3d4d5e; margin-bottom: 6px; }
.form-control, .form-select {
  border: 1.5px solid #dce4ef;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: 'Sarabun', sans-serif;
  transition: var(--transition);
  background: #fafcff;
  color: #2c3e50;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(124,58,237,.12);
  background: #fff;
}
.form-control.is-invalid { border-color: var(--danger); }
.input-group-text { background: var(--light-bg); border-color: #dce4ef; }
.required-mark { color: var(--danger); margin-left: 2px; }
textarea.form-control { resize: vertical; min-height: 100px; }

/* ===== TABLES ===== */
.table-container {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.table { margin-bottom: 0; font-size: 14px; }
.table thead th {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: rgba(255,255,255,.9);
  font-weight: 700;
  font-size: 13px;
  padding: 14px 16px;
  border: none;
  white-space: nowrap;
}
.table tbody tr { transition: var(--transition); }
.table tbody tr:hover { background: #f0f6ff; }
.table tbody td { padding: 13px 16px; vertical-align: middle; border-color: #eef2f7; }

/* ===== SIGNATURE PAD ===== */
.signature-wrapper {
  border: 2px dashed #c8d6e8;
  border-radius: var(--radius);
  padding: 10px;
  background: #fafcff;
  transition: var(--transition);
}
.signature-wrapper:hover { border-color: var(--primary-light); }
#signaturePad, canvas.sig-canvas {
  width: 100%;
  height: 200px;
  border-radius: 8px;
  cursor: crosshair;
  display: block;
  background: #fff;
}
.signature-controls {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* ===== FILE UPLOAD ===== */
.upload-zone {
  border: 2px dashed #c8d6e8;
  border-radius: var(--radius);
  padding: 30px 20px;
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
  background: #fafcff;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--primary-light);
  background: #eef5ff;
}
.upload-zone i { font-size: 36px; color: var(--primary-light); margin-bottom: 8px; }
.upload-zone p { margin: 4px 0; color: #6b7c93; font-size: 14px; }
.upload-zone .file-types { font-size: 12px; color: #aab4be; }
.file-preview-list { margin-top: 12px; }
.file-preview-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: #f0f6ff;
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}
.file-preview-item .file-icon { font-size: 18px; }
.file-preview-item .file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-preview-item .file-size { color: #8696a0; font-size: 12px; }
.file-preview-item .file-remove { cursor: pointer; color: var(--danger); font-size: 16px; }

/* ===== APPROVAL TIMELINE ===== */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 11px; top: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, var(--primary-light), #e8edf2);
}
.timeline-item { position: relative; padding-bottom: 24px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute;
  left: -24px; top: 2px;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  color: #fff;
  z-index: 1;
}
.timeline-dot.approved { background: var(--success); }
.timeline-dot.rejected { background: var(--danger); }
.timeline-dot.pending  { background: #e0e7ef; border: 2px solid #c8d6e8; }
.timeline-dot.active   { background: var(--warning); }
.timeline-content {
  background: #f8fafb;
  border-radius: 10px;
  padding: 14px 16px;
  border: 1px solid #eef2f7;
}
.timeline-header { display: flex; justify-content: space-between; align-items: flex-start; }
.timeline-title { font-weight: 700; font-size: 14px; color: var(--primary); }
.timeline-date { font-size: 12px; color: #8696a0; }
.timeline-body { margin-top: 8px; font-size: 14px; color: #4a5568; }
.timeline-sig { margin-top: 10px; }
.timeline-sig img { max-height: 60px; border: 1px solid #eef2f7; border-radius: 6px; background: #fff; padding: 4px; }

/* ===== ROOM GRID ===== */
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.room-card {
  border-radius: 10px;
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  border: 2px solid transparent;
  transition: var(--transition);
  position: relative;
}
.room-card.available  { background: #e8f5e9; border-color: #a5d6a7; }
.room-card.occupied   { background: #fff8e1; border-color: #ffe082; }
.room-card.full       { background: #fde8e8; border-color: #ef9a9a; }
.room-card.maintenance{ background: #f5f5f5; border-color: #e0e0e0; }
.room-card:hover:not(.full):not(.maintenance) { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.room-card.selected   { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(124,58,237,.2); }
.room-num { font-size: 20px; font-weight: 800; color: var(--primary); }
.room-occupancy { font-size: 11px; color: #6b7c93; margin-top: 4px; }
.room-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}
.room-card.available .room-status-dot  { background: var(--success); }
.room-card.occupied .room-status-dot   { background: var(--warning); }
.room-card.full .room-status-dot       { background: var(--danger); }
.room-card.maintenance .room-status-dot{ background: #9e9e9e; }

/* ===== LOGIN PAGE ===== */
.login-wrapper {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.login-wrapper::before {
  content: '';
  position: absolute;
  top: -100px; right: -100px;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: rgba(200,168,75,.15);
}
.login-wrapper::after {
  content: '';
  position: absolute;
  bottom: -100px; left: -100px;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
}
.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 48px 44px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  position: relative; z-index: 1;
  animation: slideUp .5s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}
.login-logo {
  text-align: center;
  margin-bottom: 30px;
}
.login-logo-icon {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 34px;
  color: #fff;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(76,29,149,.3);
}
.login-title { font-size: 22px; font-weight: 800; color: var(--primary); margin-bottom: 4px; }
.login-subtitle { font-size: 14px; color: #8696a0; }
.login-divider { height: 1px; background: #eef2f7; margin: 24px 0; }

/* ===== PRINT STYLES ===== */
@media print {
  .no-print { display: none !important; }
  .sidebar, .topbar, .topbar-toggle { display: none !important; }
  .main-content { margin-left: 0 !important; padding-top: 0 !important; }
  .content-wrapper { padding: 0 !important; }
  .card { box-shadow: none !important; }
  body { font-size: 14px; }
}

/* ===== RESPONSIVE ===== */

/* Tablet & Mobile: hide sidebar, show toggle */
@media (max-width: 991px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    transform: translateX(-260px);
    width: 260px;
    transition: transform .28s ease;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 8px 0 32px rgba(0,0,0,.35); }

  .topbar { left: 0; padding: 0 16px; }
  .topbar-toggle { display: flex; align-items: center; justify-content: center; }
  .main-content { margin-left: 0; }

  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5); z-index: 1035;
    cursor: pointer;
  }
  .sidebar-overlay.show { display: block; }

  /* Topbar title shorter on tablet */
  .topbar-breadcrumb .page-title { font-size: 16px; }
  .topbar-breadcrumb .breadcrumb { display: none; }

  /* Content */
  .content-wrapper { padding: 18px; }

  /* Stat cards: 2 per row on tablet */
  .stat-card { padding: 18px; }
  .stat-value { font-size: 30px; }
  .stat-icon { width: 44px; height: 44px; font-size: 20px; }

  /* Tables: horizontal scroll */
  .table-responsive { -webkit-overflow-scrolling: touch; }
  .table thead th { font-size: 12px; padding: 12px 10px; }
  .table tbody td { padding: 10px; font-size: 13px; }

  /* Room grid */
  .room-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }

  /* Card */
  .card-body { padding: 16px; }
  .card-header { padding: 14px 16px; }

  /* Timeline: no sticky */
  .sticky-top { position: static !important; }

  /* DataTables controls stack */
  .dataTables_wrapper .row > div { width: 100% !important; text-align: left !important; }
  .dataTables_wrapper .dataTables_filter,
  .dataTables_wrapper .dataTables_length { margin-bottom: 8px; }
  .dataTables_wrapper .dataTables_info,
  .dataTables_wrapper .dataTables_paginate { margin-top: 8px; }
}

/* Large phone / small tablet */
@media (max-width: 767px) {
  .content-wrapper { padding: 14px; }

  /* Stat cards: full width when stacked by Bootstrap col-12 */
  .stat-value { font-size: 28px; }

  /* Approval detail: stack columns */
  .col-lg-8, .col-lg-4 { width: 100% !important; max-width: 100% !important; }

  /* Modals full width */
  .modal-dialog { margin: 8px; }
  .modal-content { border-radius: 12px !important; }

  /* Signature pad */
  #signaturePad, canvas.sig-canvas { height: 160px; }

  /* Upload zone */
  .upload-zone { padding: 20px 14px; }
  .upload-zone i { font-size: 28px; }

  /* Status badge smaller */
  .status-badge { font-size: 11px; padding: 3px 9px; }

  /* Buttons in tables: icon only */
  .btn-sm { padding: 4px 8px; }

  /* Room card smaller text */
  .room-num { font-size: 16px; }
  .room-grid { grid-template-columns: repeat(auto-fill, minmax(85px, 1fr)); gap: 6px; }
  .room-card { padding: 10px 6px; }
}

/* Small phone */
@media (max-width: 575px) {
  :root { --topbar-h: 56px; }

  .content-wrapper { padding: 12px; }

  /* Topbar compact */
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-breadcrumb .page-title { font-size: 14px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-btn { width: 34px; height: 34px; font-size: 15px; }
  .topbar-user-info { display: none !important; }

  /* Login */
  .login-card { padding: 28px 18px; margin: 12px; border-radius: 16px; }
  .login-logo-icon { width: 60px; height: 60px; font-size: 28px; }
  .login-title { font-size: 18px; }

  /* Stat cards: full width, compact */
  .stat-card { padding: 14px 16px; }
  .stat-value { font-size: 26px; }
  .stat-label { font-size: 12px; }
  .stat-icon { width: 38px; height: 38px; font-size: 18px; margin-bottom: 10px; }

  /* Cards */
  .card-body { padding: 14px; }
  .card-header { padding: 12px 14px; }
  .card-title { font-size: 14px; }

  /* Table: only show key columns, let bootstrap handle */
  .table { font-size: 13px; }
  .table thead th { padding: 10px 8px; font-size: 11px; }
  .table tbody td { padding: 9px 8px; }

  /* Room grid: very small */
  .room-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 5px; }
  .room-card { padding: 8px 4px; }
  .room-num { font-size: 14px; }
  .room-occupancy { font-size: 10px; }

  /* Forms */
  .form-control, .form-select { font-size: 13px; padding: 8px 12px; }
  .form-label { font-size: 13px; }
  .btn { font-size: 13px; padding: 7px 14px; }
  .btn-sm { font-size: 12px; padding: 4px 8px; }

  /* Timeline compact */
  .timeline { padding-left: 22px; }
  .timeline-content { padding: 10px 12px; }
  .timeline-title { font-size: 13px; }
  .timeline-body { font-size: 13px; }

  /* Signature pad shorter */
  #signaturePad, canvas.sig-canvas { height: 130px; }

  /* Modal full screen feel */
  .modal-dialog { margin: 4px; }
  .modal-body { padding: 14px !important; }
  .modal-header { padding: 14px 16px !important; }
  .modal-footer { padding: 10px 14px !important; }

  /* Hide non-essential table columns via d-none helpers */
  .table .d-none-xs { display: none !important; }

  /* SweetAlert smaller */
  .swal2-popup { padding: 20px !important; }
  .swal2-title { font-size: 17px !important; }
}

/* ===== UTILITIES ===== */
.text-primary { color: var(--primary) !important; }
.text-gold { color: var(--secondary) !important; }
.bg-primary-soft { background: rgba(76,29,149,.06) !important; }
.avatar-sm { width: 32px; height: 32px; border-radius: 8px; font-size: 13px; }
.avatar-md { width: 42px; height: 42px; border-radius: 10px; font-size: 18px; }
.d-flex-center { display: flex; align-items: center; justify-content: center; }
.scrollable { overflow-y: auto; max-height: 400px; }

/* SweetAlert2 customization */
.swal2-popup { font-family: 'Sarabun', sans-serif !important; border-radius: 16px !important; }
.swal2-title { font-size: 20px !important; font-weight: 700 !important; }
.swal2-html-container { font-size: 15px !important; }
.swal2-confirm { border-radius: 8px !important; font-weight: 700 !important; }
.swal2-cancel  { border-radius: 8px !important; font-weight: 600 !important; }

/* DataTables */
.dataTables_wrapper .dataTables_filter input { border-radius: 8px; border: 1.5px solid #dce4ef; padding: 6px 12px; font-family: 'Sarabun', sans-serif; }
.dataTables_wrapper .dataTables_length select { border-radius: 8px; border: 1.5px solid #dce4ef; font-family: 'Sarabun', sans-serif; }
.dataTables_wrapper .dataTables_paginate .paginate_button { border-radius: 6px !important; font-family: 'Sarabun', sans-serif; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current { background: var(--primary) !important; border-color: var(--primary) !important; color: #fff !important; }

/* Notification pulse */
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(231,76,60,.4); }
  70%  { box-shadow: 0 0 0 8px rgba(231,76,60,0); }
  100% { box-shadow: 0 0 0 0 rgba(231,76,60,0); }
}
.pulse { animation: pulse 2s infinite; }

/* Loading */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(46,16,101,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.loading-spinner {
  width: 50px; height: 50px;
  border: 4px solid rgba(255,255,255,.3);
  border-top-color: var(--secondary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
