/* ============================================================
   Modern UI Framework — School CMS
   Primary: #0A4D3C (Lotus Green)  |  Secondary: #8BC34A (Banana Leaf)
   ============================================================ */

/* === CSS VARIABLES ========================================== */
:root {
  --lotus-green:        #0A4D3C;
  --lotus-green-dark:   #073528;
  --lotus-green-mid:    #0d6349;
  --lotus-green-light:  #e8f5f0;
  --banana-leaf:        #8BC34A;
  --banana-leaf-dark:   #6d9e33;
  --banana-leaf-light:  #f1f8e9;

  --gradient:           linear-gradient(135deg, #0A4D3C 0%, #8BC34A 100%);
  --gradient-dark:      linear-gradient(135deg, #073528 0%, #5a8a2e 100%);
  --gradient-soft:      linear-gradient(135deg, #e8f5f0 0%, #f1f8e9 100%);

  /* Neutrals */
  --white:   #ffffff;
  --gray-50: #f8f9fa;
  --gray-100:#f0f2f5;
  --gray-200:#e9ecef;
  --gray-300:#dee2e6;
  --gray-400:#ced4da;
  --gray-500:#adb5bd;
  --gray-600:#6c757d;
  --gray-700:#495057;
  --gray-800:#343a40;
  --gray-900:#212529;

  /* Status */
  --danger:  #dc3545;
  --warning: #ff9800;
  --info:    #0288d1;
  --success: #2e7d32;

  /* Layout */
  --sidebar-width:     260px;
  --sidebar-collapsed: 72px;
  --topbar-height:     64px;

  /* Shadows */
  --shadow-xs: 0 1px 3px rgba(0,0,0,.06);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.08);
  --shadow:    0 4px 16px rgba(0,0,0,.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
  --shadow-green: 0 4px 16px rgba(10,77,60,.25);

  /* Border Radius */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transition */
  --transition: all 0.25s ease;
  --transition-fast: all 0.15s ease;
}

/* === RESET & BASE =========================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Sarabun', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--gray-800);
  background: var(--gray-100);
}

a { color: var(--lotus-green); text-decoration: none; }
a:hover { color: var(--lotus-green-mid); }

img { max-width: 100%; height: auto; }

/* === ADMIN LAYOUT =========================================== */
.admin-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--gradient-dark);
  position: fixed;
  top: 0; left: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease;
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-logo {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--topbar-height);
  flex-shrink: 0;   /* must not shrink — locks nav height calculation */
}

.sidebar-logo img {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: rgba(255,255,255,.2);
}

.sidebar-logo-placeholder {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
  color: #fff;
}

.sidebar-school-name {
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  flex: 1;
  overflow: hidden;
}

.sidebar-school-name small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  opacity: .7;
}

/* Sidebar Nav */
.sidebar-nav {
  flex: 1;
  min-height: 0;        /* critical: allows flex child to shrink below content size */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0;
  /* Always show scrollbar track so users know it's scrollable */
  scrollbar-gutter: stable;
}

.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-track { background: rgba(255,255,255,.05); }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.25); border-radius: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.45); }

.nav-label {
  color: rgba(255,255,255,.45);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 16px 20px 6px;
  white-space: nowrap;
  overflow: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,.8);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition-fast);
  border-left: 3px solid transparent;
  white-space: nowrap;
  text-decoration: none;
}

.nav-item:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
  border-left-color: var(--banana-leaf);
}

.nav-item.active {
  background: rgba(255,255,255,.12);
  color: #fff;
  border-left-color: var(--banana-leaf);
  font-weight: 600;
}

.nav-item i {
  font-size: 17px;
  width: 20px;
  flex-shrink: 0;
  text-align: center;
}

.nav-item span { flex: 1; overflow: hidden; }

.nav-badge {
  background: var(--banana-leaf);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;   /* must not shrink — keeps footer pinned at bottom */
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.9);
  cursor: pointer;
  transition: var(--transition-fast);
}

.sidebar-user:hover { background: rgba(255,255,255,.08); }

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--gradient);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.user-info { flex: 1; overflow: hidden; line-height: 1.3; }
.user-info strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info small { font-size: 11px; opacity: .6; }

/* ── Main Content ── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}

.main-content.expanded { margin-left: var(--sidebar-collapsed); }

/* ── Topbar ── */
.topbar {
  height: var(--topbar-height);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-xs);
}

.topbar-toggle {
  width: 36px; height: 36px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-700);
  font-size: 18px;
  transition: var(--transition-fast);
}

.topbar-toggle:hover { background: var(--gray-100); }

.topbar-breadcrumb {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--gray-600);
  font-size: 13px;
}

.topbar-breadcrumb a { color: var(--gray-600); }
.topbar-breadcrumb a:hover { color: var(--lotus-green); }
.topbar-breadcrumb .current { color: var(--gray-800); font-weight: 500; }

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

.topbar-btn {
  width: 36px; height: 36px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-600);
  font-size: 18px;
  position: relative;
  transition: var(--transition-fast);
}

.topbar-btn:hover { background: var(--gray-100); color: var(--lotus-green); }

.topbar-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--gradient);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  overflow: hidden;
}

/* ── Page Content ── */
.page-content {
  flex: 1;
  padding: 24px;
}

/* ── Page Header (Gradient) ── */
.page-header {
  background: var(--gradient);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow-green);
}

.page-header-left { flex: 1; }

.page-title {
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.page-subtitle {
  color: rgba(255,255,255,.75);
  font-size: 13px;
}

.page-header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Gradient title (for modals) */
.gradient-title {
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
}

/* === CARDS ================================================== */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title i { color: var(--lotus-green); }

.card-body { padding: 20px; }
.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
}

/* Section Card */
.section-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  margin-bottom: 20px;
  overflow: hidden;
}

.section-card-header {
  background: var(--gradient-soft);
  padding: 12px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--lotus-green-dark);
}

.section-card-header i { font-size: 16px; color: var(--lotus-green); }

.section-card-body { padding: 20px; }

/* Stat Cards */
.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.stat-icon {
  width: 56px; height: 56px;
  border-radius: var(--radius);
  background: var(--gradient-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  color: var(--lotus-green);
  flex-shrink: 0;
}

.stat-icon.green  { background: linear-gradient(135deg,#e8f5f0,#c8e6c9); color: var(--lotus-green); }
.stat-icon.blue   { background: linear-gradient(135deg,#e3f2fd,#bbdefb); color: #1565c0; }
.stat-icon.orange { background: linear-gradient(135deg,#fff3e0,#ffe0b2); color: #e65100; }
.stat-icon.purple { background: linear-gradient(135deg,#f3e5f5,#e1bee7); color: #6a1b9a; }
.stat-icon.red    { background: linear-gradient(135deg,#ffebee,#ffcdd2); color: #b71c1c; }
.stat-icon.teal   { background: linear-gradient(135deg,#e0f2f1,#b2dfdb); color: #00695c; }

.stat-info { flex: 1; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--gray-900); line-height: 1; }
.stat-label { font-size: 13px; color: var(--gray-600); margin-top: 4px; }
.stat-change { font-size: 12px; margin-top: 6px; }
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* === BUTTONS ================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: 'Sarabun', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-sm  { padding: 6px 12px; font-size: 13px; }
.btn-lg  { padding: 12px 24px; font-size: 16px; }
.btn-xs  { padding: 4px 8px; font-size: 12px; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: var(--radius-sm); }

/* Primary */
.btn-primary {
  background: var(--gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(10,77,60,.3);
}
.btn-primary:hover {
  background: var(--gradient-dark);
  box-shadow: var(--shadow-green);
  transform: translateY(-1px);
  color: #fff;
}

/* Secondary */
.btn-secondary {
  background: var(--gray-600);
  color: #fff;
  border-color: transparent;
}
.btn-secondary:hover { background: var(--gray-700); color: #fff; }

/* Outline */
.btn-outline {
  background: transparent;
  color: var(--lotus-green);
  border-color: var(--lotus-green);
}
.btn-outline:hover {
  background: var(--lotus-green);
  color: #fff;
}

/* Light */
.btn-light {
  background: rgba(255,255,255,.15);
  color: #fff;
  border-color: rgba(255,255,255,.3);
  backdrop-filter: blur(4px);
}
.btn-light:hover {
  background: rgba(255,255,255,.25);
  color: #fff;
}

/* Danger */
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: transparent;
}
.btn-danger:hover { background: #b02a37; color: #fff; transform: translateY(-1px); }

/* Warning */
.btn-warning {
  background: var(--warning);
  color: #fff;
  border-color: transparent;
}
.btn-warning:hover { background: #e68900; color: #fff; }

/* Info */
.btn-info {
  background: var(--info);
  color: #fff;
  border-color: transparent;
}
.btn-info:hover { background: #0270b5; color: #fff; }

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--gray-700);
  border-color: var(--gray-300);
}
.btn-ghost:hover { background: var(--gray-100); }

/* === FORMS ================================================== */
.form-group { margin-bottom: 18px; }

.form-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-label i { color: var(--lotus-green); font-size: 15px; }
.form-label .required { color: var(--danger); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-family: 'Sarabun', sans-serif;
  font-size: 14px;
  color: var(--gray-800);
  background: var(--white);
  transition: var(--transition-fast);
  outline: none;
}

.form-control:focus {
  border-color: var(--lotus-green);
  box-shadow: 0 0 0 3px rgba(10,77,60,.12);
}

.form-control:disabled,
.form-control[readonly] {
  background: var(--gray-100);
  color: var(--gray-600);
  cursor: not-allowed;
}

textarea.form-control { resize: vertical; min-height: 100px; }

select.form-control { cursor: pointer; }

.form-hint {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
}

.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
}

.form-control.is-invalid { border-color: var(--danger); }
.form-control.is-valid   { border-color: var(--success); }

/* Input Group */
.input-group {
  display: flex;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: var(--transition-fast);
}

.input-group:focus-within {
  border-color: var(--lotus-green);
  box-shadow: 0 0 0 3px rgba(10,77,60,.12);
}

.input-group .form-control {
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.input-group-text {
  padding: 10px 12px;
  background: var(--gray-100);
  color: var(--lotus-green);
  font-size: 16px;
  display: flex;
  align-items: center;
  border-right: 1.5px solid var(--gray-300);
  white-space: nowrap;
}

.input-group .input-group-text:last-child {
  border-right: none;
  border-left: 1.5px solid var(--gray-300);
}

/* Checkbox & Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 0;
}

.form-check-input {
  width: 18px; height: 18px;
  border: 2px solid var(--gray-400);
  border-radius: var(--radius-xs);
  cursor: pointer;
  accent-color: var(--lotus-green);
}

.form-check-label { font-size: 14px; cursor: pointer; }

/* Switch */
.form-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.switch-input {
  appearance: none;
  width: 44px; height: 24px;
  border-radius: 12px;
  background: var(--gray-300);
  cursor: pointer;
  transition: background 0.25s;
  position: relative;
}

.switch-input::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
  transition: left 0.25s;
}

.switch-input:checked { background: var(--lotus-green); }
.switch-input:checked::after { left: 23px; }

/* Two Column layout */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* === TABLES ================================================= */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  font-size: 14px;
}

.table th {
  background: var(--gradient-soft);
  color: var(--lotus-green-dark);
  font-weight: 600;
  font-size: 13px;
  padding: 12px 16px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 2px solid var(--gray-200);
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
  color: var(--gray-800);
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr:hover td { background: var(--gray-50); }

.table-striped tbody tr:nth-child(even) td { background: var(--gray-50); }

/* Table Actions */
.table-actions { display: flex; gap: 6px; align-items: center; }

/* Table Toolbar */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--gray-100);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  min-width: 240px;
  transition: var(--transition-fast);
}

.search-box:focus-within {
  border-color: var(--lotus-green);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(10,77,60,.12);
}

.search-box i { color: var(--gray-400); font-size: 15px; }

.search-box input {
  border: none;
  background: none;
  font-family: 'Sarabun', sans-serif;
  font-size: 14px;
  color: var(--gray-800);
  outline: none;
  width: 100%;
}

/* === BADGES ================================================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-green   { background: var(--banana-leaf-light); color: var(--banana-leaf-dark); }
.badge-red     { background: #ffebee; color: #c62828; }
.badge-orange  { background: #fff3e0; color: #e65100; }
.badge-blue    { background: #e3f2fd; color: #1565c0; }
.badge-purple  { background: #f3e5f5; color: #6a1b9a; }
.badge-yellow  { background: #fef9c3; color: #a16207; }
.badge-gray    { background: var(--gray-200); color: var(--gray-700); }
.badge-primary { background: var(--lotus-green-light); color: var(--lotus-green-dark); }

/* Role Badges */
.role-badge { border-radius: 6px; padding: 3px 10px; font-size: 12px; font-weight: 600; }
.role-superadmin { background: #fff3e0; color: #e65100; }
.role-admin      { background: var(--lotus-green-light); color: var(--lotus-green-dark); }
.role-teacher    { background: #e3f2fd; color: #1565c0; }
.role-student    { background: var(--banana-leaf-light); color: var(--banana-leaf-dark); }
.role-parent     { background: #f3e5f5; color: #6a1b9a; }

/* Status Badge */
.status-active   { background: var(--banana-leaf-light); color: var(--banana-leaf-dark); }
.status-inactive { background: var(--gray-200); color: var(--gray-600); }

/* === PAGINATION ============================================= */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 16px 20px;
  justify-content: center;
}

.page-btn {
  width: 36px; height: 36px;
  border: 1.5px solid var(--gray-300);
  background: var(--white);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition-fast);
  color: var(--gray-700);
  font-family: 'Sarabun', sans-serif;
}

.page-btn:hover { border-color: var(--lotus-green); color: var(--lotus-green); }
.page-btn.active {
  background: var(--gradient);
  color: #fff;
  border-color: transparent;
}

/* === MODAL OVERLAY ========================================== */
.mu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
  animation: muFadeIn .2s ease;
}

@keyframes muFadeIn   { from { opacity: 0; } to { opacity: 1; } }
@keyframes muSlideUp  { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes muBounce   { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }

.mu-modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  animation: muSlideUp .25s ease;
}

.mu-modal-lg { max-width: 760px; }
.mu-modal-xl { max-width: 960px; }

.mu-modal-header {
  padding: 20px 24px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.mu-modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
}

.mu-modal-close {
  width: 32px; height: 32px;
  border: none;
  background: var(--gray-100);
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-600);
  flex-shrink: 0;
  transition: var(--transition-fast);
}

.mu-modal-close:hover { background: var(--gray-200); color: var(--gray-900); }

.mu-modal-body { padding: 16px 24px 20px; }

.mu-modal-footer {
  padding: 0 24px 20px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Icon Modals */
.mu-icon-modal { text-align: center; padding: 32px 24px; }

.mu-icon-circle {
  width: 72px; height: 72px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  margin: 0 auto 16px;
  animation: muBounce .4s ease .1s both;
}

.mu-icon-circle.success { background: #e8f5e9; color: #2e7d32; }
.mu-icon-circle.error   { background: #ffebee; color: #c62828; }
.mu-icon-circle.warning { background: #fff3e0; color: #e65100; }
.mu-icon-circle.confirm { background: var(--lotus-green-light); color: var(--lotus-green); }
.mu-icon-circle.delete  { background: #ffebee; color: #c62828; }

.mu-modal-message {
  font-size: 16px;
  color: var(--gray-700);
  margin-bottom: 8px;
}

.mu-modal-sub {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 20px;
}

/* === TOAST NOTIFICATIONS ==================================== */
.mu-toast-container {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.mu-toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 380px;
  pointer-events: all;
  animation: muSlideIn .3s ease;
  border-left: 4px solid;
  font-size: 14px;
  position: relative;
}

@keyframes muSlideIn  { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes muSlideOut { from { opacity: 1; transform: translateX(0); }     to { opacity: 0; transform: translateX(40px); } }

.mu-toast.removing { animation: muSlideOut .3s ease forwards; }

.mu-toast-icon {
  font-size: 20px;
  flex-shrink: 0;
  width: 24px;
  display: flex; align-items: center; justify-content: center;
}

.mu-toast-content { flex: 1; }
.mu-toast-title { font-weight: 600; color: var(--gray-900); line-height: 1.3; }
.mu-toast-sub { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

.mu-toast-close {
  width: 24px; height: 24px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--gray-400);
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  transition: var(--transition-fast);
  flex-shrink: 0;
}

.mu-toast-close:hover { background: var(--gray-100); color: var(--gray-700); }

.mu-toast.success { border-left-color: #2e7d32; }
.mu-toast.success .mu-toast-icon { color: #2e7d32; }

.mu-toast.error { border-left-color: var(--danger); }
.mu-toast.error .mu-toast-icon { color: var(--danger); }

.mu-toast.warning { border-left-color: var(--warning); }
.mu-toast.warning .mu-toast-icon { color: var(--warning); }

.mu-toast.info { border-left-color: var(--info); }
.mu-toast.info .mu-toast-icon { color: var(--info); }

/* === LOADING OVERLAY ======================================== */
.mu-loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.85);
  z-index: 9997;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  backdrop-filter: blur(2px);
}

.mu-spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--lotus-green);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.mu-loading-text {
  font-size: 15px;
  color: var(--lotus-green);
  font-weight: 500;
}

/* === PROGRESS BAR =========================================== */
.mu-progress-modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 360px;
  box-shadow: var(--shadow-lg);
  animation: muSlideUp .25s ease;
}

.mu-progress-label {
  font-size: 14px;
  color: var(--gray-700);
  margin-bottom: 12px;
  font-weight: 500;
}

.mu-progress-track {
  height: 8px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
}

.mu-progress-fill {
  height: 100%;
  background: var(--gradient);
  border-radius: 4px;
  transition: width .3s ease;
  width: 0%;
}

.mu-progress-pct {
  text-align: right;
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 6px;
}

/* === ALERTS ================================================= */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  border-left: 4px solid;
}

.alert i { font-size: 16px; flex-shrink: 0; margin-top: 1px; }

.alert-success { background: #e8f5e9; border-color: #2e7d32; color: #1b5e20; }
.alert-success i { color: #2e7d32; }

.alert-error   { background: #ffebee; border-color: var(--danger); color: #b71c1c; }
.alert-error i { color: var(--danger); }

.alert-warning { background: #fff8e1; border-color: var(--warning); color: #e65100; }
.alert-warning i { color: var(--warning); }

.alert-info    { background: #e3f2fd; border-color: var(--info); color: #0d47a1; }
.alert-info i { color: var(--info); }

/* === AVATAR ================================================= */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  color: #fff;
  background: var(--gradient);
  overflow: hidden;
  flex-shrink: 0;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-xs  { width: 28px; height: 28px; font-size: 11px; }
.avatar-sm  { width: 36px; height: 36px; font-size: 14px; }
.avatar-md  { width: 48px; height: 48px; font-size: 18px; }
.avatar-lg  { width: 64px; height: 64px; font-size: 24px; }
.avatar-xl  { width: 96px; height: 96px; font-size: 36px; }

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

.empty-state-icon {
  font-size: 64px;
  opacity: .3;
  margin-bottom: 16px;
}

.empty-state-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 8px;
}

.empty-state-text {
  font-size: 14px;
  color: var(--gray-500);
  max-width: 320px;
  margin: 0 auto 20px;
}

/* === TABS =================================================== */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 20px;
  gap: 0;
}

.tab-btn {
  padding: 10px 20px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: 'Sarabun', sans-serif;
  font-size: 14px;
  color: var(--gray-600);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition-fast);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab-btn:hover { color: var(--lotus-green); }
.tab-btn.active { color: var(--lotus-green); border-bottom-color: var(--lotus-green); font-weight: 600; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* === MISC UTILITIES ========================================= */
.text-green  { color: var(--lotus-green) !important; }
.text-muted  { color: var(--gray-500) !important; }
.text-danger { color: var(--danger) !important; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.fw-bold     { font-weight: 700 !important; }
.fw-semibold { font-weight: 600 !important; }

.d-flex      { display: flex; }
.align-center{ align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

.mb-0  { margin-bottom: 0 !important; }
.mb-8  { margin-bottom: 8px !important; }
.mb-16 { margin-bottom: 16px !important; }
.mb-24 { margin-bottom: 24px !important; }
.mt-16 { margin-top: 16px !important; }
.mt-24 { margin-top: 24px !important; }

.w-100 { width: 100%; }

/* Divider */
.divider {
  border: none;
  border-top: 1px solid var(--gray-200);
  margin: 16px 0;
}

/* Img preview */
.img-preview {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  background: var(--gray-50);
  display: block;
  margin-top: 8px;
}

/* Thumbnail */
.thumb {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--gray-200);
}

.thumb-sm { width: 36px; height: 36px; }
.thumb-md { width: 64px; height: 64px; }
.thumb-lg { width: 96px; height: 96px; }

/* File icon */
.file-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}

.file-pdf   { background: #ffebee; color: #c62828; }
.file-word  { background: #e3f2fd; color: #1565c0; }
.file-excel { background: #e8f5e9; color: #2e7d32; }
.file-img   { background: #fff3e0; color: #e65100; }
.file-other { background: var(--gray-100); color: var(--gray-600); }

/* Color dot */
.color-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  display: inline-block;
  border: 1.5px solid rgba(0,0,0,.15);
  vertical-align: middle;
}

/* === RESPONSIVE ============================================= */
@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .3s ease;
  }
  .sidebar.open {
    transform: translateX(0);
    width: var(--sidebar-width);
  }
  .main-content { margin-left: 0 !important; }
  .two-col { grid-template-columns: 1fr; }
  .three-col { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 576px) {
  .page-content { padding: 16px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .table-toolbar { flex-direction: column; align-items: stretch; }
  .search-box { min-width: unset; }
  .three-col { grid-template-columns: 1fr; }
  .mu-toast { min-width: 260px; }
}

/* === SORTABLEJS HELPERS ===================================== */
.sortable-ghost   { opacity: .35 !important; }
.sortable-chosen  { box-shadow: 0 6px 20px rgba(0,0,0,.18) !important; z-index: 50; }
.sortable-drag    { opacity: 1 !important; }

/* === PRINT ================================================== */
@media print {
  .sidebar, .topbar, .page-header-actions, .table-toolbar { display: none !important; }
  .main-content { margin-left: 0 !important; }
}
