/* ============================================================
   Global Design System — AlumniConnect
   ============================================================ */

/* ── Custom Properties ──────────────────────────────────────── */
:root {
  /* Brand */
  --primary:        #6366f1;
  --primary-dark:   #4f46e5;
  --primary-light:  #e0e7ff;
  --secondary:      #10b981;
  --secondary-dark: #059669;
  --accent:         #f59e0b;
  --danger:         #ef4444;
  --warning:        #f59e0b;
  --info:           #3b82f6;
  --success:        #10b981;

  /* Neutrals */
  --gray-50:  #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

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

  /* Surface */
  --bg-body:      #f1f5f9;
  --bg-card:      #ffffff;
  --bg-sidebar:   #1e1b4b;
  --bg-sidebar-hover: rgba(255,255,255,0.08);

  /* Text */
  --text-primary:   #1e293b;
  --text-secondary: #64748b;
  --text-muted:     #94a3b8;
  --text-inverse:   #ffffff;

  /* Borders */
  --border:       #e2e8f0;
  --border-focus: #6366f1;

  /* Shadows */
  --shadow-xs:  0 1px 2px rgba(0,0,0,.05);
  --shadow-sm:  0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:  0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --shadow-xl:  0 20px 25px rgba(0,0,0,.1), 0 10px 10px rgba(0,0,0,.04);

  /* Radii */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  /* Transitions */
  --transition: 0.2s ease;
  --transition-slow: 0.35s ease;

  /* Z-index layers */
  --z-dropdown: 100;
  --z-sticky:   200;
  --z-navbar:   300;
  --z-sidebar:  400;
  --z-modal:    500;
  --z-toast:    600;
  --z-tooltip:  700;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a  { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }

/* ── Typography ─────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
}
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

p { color: var(--text-secondary); }

/* ── App Layout ─────────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left var(--transition-slow);
  display: flex;
  flex-direction: column;
}

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

.page-content {
  flex: 1;
  padding: 24px;
  padding-top: calc(var(--navbar-height) + 24px);
}

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

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

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  min-height: var(--navbar-height);
  text-decoration: none;
}

.sidebar-brand-logo {
  width: 40px;
  height: 40px;
  background: transparent;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: white;
  flex-shrink: 0;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-brand-name {
  font-size: 1rem;
  font-weight: 700;
  color: white;
  white-space: nowrap;
}

.sidebar-brand-sub {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.5);
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.sidebar-section {
  margin-bottom: 4px;
}

.sidebar-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  padding: 12px 20px 6px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition);
}

.sidebar.collapsed .sidebar-section-label { opacity: 0; }
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .nav-label { opacity: 0; width: 0; }

.nav-item {
  position: relative;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.65);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  white-space: nowrap;
  border-radius: 0;
  text-decoration: none;
}

.nav-link:hover {
  background: var(--bg-sidebar-hover);
  color: white;
}

.nav-link.active {
  background: rgba(99,102,241,0.25);
  color: white;
  border-right: 3px solid var(--primary);
}

.nav-link .nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.nav-label {
  transition: opacity var(--transition), width var(--transition);
  overflow: hidden;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius);
  transition: background var(--transition);
  cursor: pointer;
  text-decoration: none;
}

.sidebar-user:hover { background: var(--bg-sidebar-hover); }

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  object-fit: cover;
  flex-shrink: 0;
}

.sidebar-user-info { overflow: hidden; }

.sidebar-user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.4);
  white-space: nowrap;
}

/* ── Navbar ──────────────────────────────────────────────────── */
.navbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--navbar-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: var(--z-navbar);
  transition: left var(--transition-slow);
  box-shadow: var(--shadow-xs);
}

.navbar.sidebar-collapsed { left: var(--sidebar-collapsed); }

.navbar-toggle {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition);
  font-size: 1rem;
}

.navbar-toggle:hover {
  background: var(--gray-100);
  color: var(--text-primary);
}

.navbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
}

.breadcrumb-item { color: var(--text-muted); }
.breadcrumb-item.active { color: var(--text-primary); font-weight: 600; }
.breadcrumb-sep { color: var(--gray-300); }

.navbar-spacer { flex: 1; }

.navbar-search {
  position: relative;
  display: flex;
  align-items: center;
}

.navbar-search input {
  background: var(--gray-100);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  padding: 8px 16px 8px 40px;
  font-size: 0.875rem;
  width: 240px;
  transition: all var(--transition);
  outline: none;
  color: var(--text-primary);
}

.navbar-search input:focus {
  background: white;
  border-color: var(--primary);
  width: 300px;
  box-shadow: 0 0 0 3px var(--primary-light);
}

.navbar-search .search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  font-size: 0.875rem;
  pointer-events: none;
}

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

.navbar-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 1rem;
  transition: all var(--transition);
}

.navbar-btn:hover {
  background: var(--gray-100);
  color: var(--text-primary);
}

.navbar-btn .btn-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 16px;
  height: 16px;
  background: var(--danger);
  border-radius: var(--radius-full);
  font-size: 0.6rem;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

.navbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  object-fit: cover;
  cursor: pointer;
  border: 2px solid var(--border);
  transition: border-color var(--transition);
}

.navbar-avatar:hover { border-color: var(--primary); }

/* ── Dropdown ────────────────────────────────────────────────── */
.dropdown { position: relative; }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-dropdown);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all var(--transition);
}

.dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 0.875rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition);
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover { background: var(--gray-50); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: #fef2f2; }

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

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

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.card-body { padding: 20px; }

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

/* ── Stat Cards ──────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}

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

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.success { background: #d1fae5; color: var(--success); }
.stat-icon.warning { background: #fef3c7; color: var(--warning); }
.stat-icon.danger  { background: #fee2e2; color: var(--danger); }
.stat-icon.info    { background: #dbeafe; color: var(--info); }
.stat-icon.violet  { background: #ede9fe; color: #7c3aed; }
.stat-icon.pink    { background: #fce7f3; color: #db2777; }

.stat-info { flex: 1; min-width: 0; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; color: var(--text-primary); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }
.stat-change {
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: white;
  box-shadow: 0 4px 12px rgba(99,102,241,0.35);
}

.btn-secondary {
  background: var(--secondary);
  color: white;
  border-color: var(--secondary);
}
.btn-secondary:hover { background: var(--secondary-dark); border-color: var(--secondary-dark); color: white; }

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.btn-danger:hover { background: #dc2626; color: white; }

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-outline:hover { background: var(--gray-50); color: var(--text-primary); border-color: var(--gray-300); }

.btn-outline-primary {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline-primary:hover { background: var(--primary-light); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--gray-100); color: var(--text-primary); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 12px 24px; font-size: 1rem; border-radius: var(--radius-md); }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: var(--radius-sm); }
.btn-loading::after {
  content: '';
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 4px;
}

/* ── Forms ───────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-label .required {
  color: var(--danger);
  margin-left: 3px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.875rem;
  color: var(--text-primary);
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
  outline: none;
  font-family: inherit;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.form-control.is-invalid { border-color: var(--danger); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(239,68,68,0.1); }

.form-control::placeholder { color: var(--text-muted); }

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

.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 5px;
}

.form-error {
  font-size: 0.78rem;
  color: var(--danger);
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.input-group {
  position: relative;
  display: flex;
}

.input-group .form-control { flex: 1; }

.input-prefix, .input-suffix {
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--gray-100);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  font-size: 0.875rem;
}

.input-prefix { border-right: none; border-radius: var(--radius) 0 0 var(--radius); }
.input-suffix { border-left: none; border-radius: 0 var(--radius) var(--radius) 0; }
.input-prefix + .form-control { border-radius: 0 var(--radius) var(--radius) 0; }

.input-icon {
  position: relative;
}

.input-icon .form-control { padding-left: 40px; }
.input-icon .icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  background: var(--gray-50);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 14px 16px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

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

.table-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  object-fit: cover;
}

/* ── Letter avatar fallback (.av) ────────────────────────────── */
/* Shown instead of <img> when a user has no profile picture.    */
/* Color is deterministic from the user's name (PHP + JS parity) */
.av {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  -webkit-user-select: none;
  user-select: none;
  flex-shrink: 0;
  overflow: hidden;
  line-height: 1;
  letter-spacing: 0;
  vertical-align: middle;
  font-size: .875rem;
}

/* Per-CSS-class font-size overrides (sized by the CSS class, not inline) */
.table-avatar.av        { font-size: .875rem;  }  /* 34 px */
.navbar-avatar.av,
.sidebar-user-avatar.av { font-size: .875rem;  }  /* 36 px */

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

.badge-primary   { background: var(--primary-light); color: var(--primary); }
.badge-success   { background: #d1fae5; color: #065f46; }
.badge-warning   { background: #fef3c7; color: #92400e; }
.badge-danger    { background: #fee2e2; color: #991b1b; }
.badge-secondary { background: var(--gray-100); color: var(--gray-600); }
.badge-info      { background: #dbeafe; color: #1e40af; }

/* ── Modals ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition);
}

.modal-overlay.show .modal { transform: scale(1) translateY(0); }

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

.modal-title { font-size: 1rem; font-weight: 700; }

.modal-close {
  width: 30px; height: 30px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--gray-100);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition);
}

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

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

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

/* ── Confirm Dialog Modal ────────────────────────────────────── */
.confirm-modal {
  max-width: 320px;
  position: relative;
}

.confirm-modal .modal-body {
  text-align: center;
  padding: 22px 20px 10px;
}

.confirm-modal-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  margin: 0 auto 12px;
}

.confirm-modal-icon.danger  { background: #fee2e2; color: #ef4444; }
.confirm-modal-icon.warning { background: #fef3c7; color: #f59e0b; }
.confirm-modal-icon.info    { background: #dbeafe; color: #3b82f6; }
.confirm-modal-icon.success { background: #d1fae5; color: #10b981; }
.confirm-modal-icon.logout  { background: #fef3c7; color: #f59e0b; }

.confirm-modal-title {
  font-size: .9rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.confirm-modal-message {
  font-size: .8rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.confirm-modal .modal-footer {
  justify-content: center;
  padding: 12px 20px 18px;
  gap: 10px;
  border-top: none;
}

.confirm-modal .modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

/* ── Confirm Danger Alert (used inside delete modals) ───────── */
.confirm-danger {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .82rem;
  color: #991b1b;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.confirm-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .82rem;
  color: #92400e;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

/* ── Toast Notifications ─────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
  min-width: 300px;
  max-width: 420px;
  pointer-events: all;
  animation: toastIn 0.35s ease forwards;
}

.toast.removing { animation: toastOut 0.3s ease forwards; }

.toast-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.toast.success .toast-icon { background: #d1fae5; color: var(--success); }
.toast.error   .toast-icon { background: #fee2e2; color: var(--danger); }
.toast.warning .toast-icon { background: #fef3c7; color: var(--warning); }
.toast.info    .toast-icon { background: #dbeafe; color: var(--info); }

.toast-body { flex: 1; }
.toast-title { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); }
.toast-message { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

.toast-close {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  margin-top: 2px;
  flex-shrink: 0;
}

/* ── Page Header ─────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-header-left {}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 2px;
}

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

.page-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: white;
  color: var(--text-secondary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.page-btn:hover { background: var(--gray-50); border-color: var(--gray-300); color: var(--text-primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: white; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Empty State ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
}

.empty-icon {
  width: 80px; height: 80px;
  background: var(--gray-100);
  border-radius: var(--radius-xl);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  color: var(--text-muted);
  margin: 0 auto 20px;
}

.empty-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-text {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* ── Avatar ──────────────────────────────────────────────────── */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  object-fit: cover;
  flex-shrink: 0;
  font-weight: 700;
  color: white;
  background: var(--primary);
}

.avatar-xs  { width: 24px; height: 24px; font-size: 0.6rem; }
.avatar-sm  { width: 32px; height: 32px; font-size: 0.75rem; }
.avatar-md  { width: 40px; height: 40px; font-size: 0.875rem; }
.avatar-lg  { width: 56px; height: 56px; font-size: 1.1rem; }
.avatar-xl  { width: 80px; height: 80px; font-size: 1.5rem; }
.avatar-2xl { width: 112px; height: 112px; font-size: 2rem; }

/* ── Online indicator ────────────────────────────────────────── */
.online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px; height: 10px;
  background: var(--success);
  border-radius: var(--radius-full);
  border: 2px solid white;
}

/* ── Loading spinner ─────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-sm { width: 14px; height: 14px; }
.spinner-lg { width: 32px; height: 32px; }

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  z-index: 10;
}

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.875rem;
  margin-bottom: 16px;
}

.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-danger  { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

/* ── Grid utilities ──────────────────────────────────────────── */
.grid    { display: grid; }
.flex    { display: flex; }
.hidden  { display: none !important; }
.visible { display: block !important; }
.gap-4   { gap: 4px; }
.gap-8   { gap: 8px; }
.gap-12  { gap: 12px; }
.gap-16  { gap: 16px; }
.gap-20  { gap: 20px; }
.gap-24  { gap: 24px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.w-full  { width: 100%; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-sm   { font-size: 0.875rem; }
.text-xs   { font-size: 0.78rem; }
.text-muted { color: var(--text-muted); }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Animations ──────────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

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

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(100%); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .navbar { left: 0; }
  .navbar.sidebar-collapsed { left: 0; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Two-column content grids collapse at tablet */
@media (max-width: 768px) {
  .mob-1col { grid-template-columns: 1fr !important; }
  .mob-1col > * { min-width: 0; }
}

@media (max-width: 640px) {
  .page-content { padding: 14px; padding-top: calc(var(--navbar-height) + 14px); }

  /* Stat grid — 2 compact cards per row instead of 1 giant one */
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
  .stat-card  { padding: 12px 13px; gap: 10px; }
  .stat-icon  { width: 38px; height: 38px; font-size: .85rem; }
  .stat-value { font-size: 1.3rem; }
  .stat-label { font-size: .72rem; margin-top: 2px; }

  /* Cards — tighter padding on small screens */
  .card-header { padding: 11px 14px; }
  .card-body   { padding: 13px 14px; }
  .card-footer { padding: 10px 14px; }

  /* Modal */
  .modal        { margin: 8px; max-width: calc(100vw - 16px); }
  .modal-header { padding: 12px 16px; }
  .modal-body   { padding: 14px 16px; }
  .modal-footer { padding: 12px 16px; }

  /* Page header — stack title + action buttons */
  .page-header       { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-header-right { width: 100%; flex-wrap: wrap; }

  /* Navbar */
  .navbar-search { display: none; }
}

/* Welcome banner — compact on mobile */
@media (max-width: 640px) {
  .dash-welcome { padding: 16px 18px !important; border-radius: 12px !important; }
  .dash-welcome h2 { font-size: 1.05rem !important; }
  .dash-welcome p  { font-size: .8rem !important; }
  .dash-welcome .btn { padding: 6px 13px; font-size: .8rem; }
}

@media (max-width: 400px) {
  /* Very small phones — shrink stat values a touch more */
  .stat-value { font-size: 1.15rem; }
  .stat-icon  { width: 34px; height: 34px; font-size: .78rem; }
  .stat-card  { padding: 10px 11px; gap: 8px; }
}
