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

:root {
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-light: #EEF2FF;
  --danger: #DC2626;
  --danger-hover: #B91C1C;
  --success: #16A34A;
  --warning: #F59E0B;
  --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;
  --white: #FFFFFF;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --shadow-xl: 0 20px 25px rgba(0,0,0,0.1), 0 10px 10px rgba(0,0,0,0.04);
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --transition: 150ms ease;
}

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

/* ─── Login Page ──────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #4F46E5 50%, #7c3aed 100%);
  padding: 20px;
}

.login-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 420px;
  padding: 40px;
  animation: slideUp 0.4s ease;
}

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

.login-card .logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-card .logo h1 {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.login-card .logo h1 span {
  color: var(--gray-400);
  font-weight: 400;
  font-size: 14px;
  display: block;
  margin-top: 4px;
  letter-spacing: 0;
}

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

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  color: var(--gray-800);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-group input::placeholder {
  color: var(--gray-400);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ─── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1;
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
  background: var(--gray-300);
  cursor: not-allowed;
}

.btn-danger {
  background: var(--danger);
  color: var(--white);
}

.btn-danger:hover {
  background: var(--danger-hover);
}

.btn-outline {
  background: var(--white);
  color: var(--gray-700);
  border: 1.5px solid var(--gray-200);
}

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

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-full {
  width: 100%;
  padding: 12px 20px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius);
}

/* ─── Alerts ──────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 20px;
  display: none;
}

.alert.show {
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-error {
  background: #FEF2F2;
  color: var(--danger);
  border: 1px solid #FECACA;
}

.alert-success {
  background: #F0FDF4;
  color: var(--success);
  border: 1px solid #BBF7D0;
}

/* ─── Dashboard Layout ────────────────────────────────── */
.dashboard {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.dashboard-body {
  display: flex;
  flex: 1;
  min-height: calc(100vh - 64px);
}

/* ─── Sidebar Navigation ─────────────────────────────── */
.sidebar {
  width: 250px;
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  flex-shrink: 0;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 8px;
  flex: 1;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-600);
  text-decoration: none;
  transition: all var(--transition);
  cursor: pointer;
  user-select: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.sidebar-item:hover:not(.disabled) {
  background: var(--gray-50);
  color: var(--gray-900);
}

.sidebar-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-item.disabled {
  color: var(--gray-400);
  cursor: default;
  pointer-events: none;
}

.sidebar-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
  line-height: 1;
}

.sidebar-label {
  flex: 1;
}

.sidebar-chevron {
  font-size: 10px;
  color: var(--gray-400);
  transition: transform 0.2s ease;
}

.sidebar-group.open > .sidebar-item .sidebar-chevron {
  transform: rotate(180deg);
}

.sidebar-submenu {
  display: none;
  flex-direction: column;
  gap: 1px;
  padding: 2px 0 2px 0;
}

.sidebar-group.open .sidebar-submenu {
  display: flex;
}

.sidebar-subitem {
  display: block;
  padding: 8px 14px 8px 48px;
  font-size: 13px;
  color: var(--gray-500);
  text-decoration: none;
  border-radius: var(--radius);
  transition: all var(--transition);
  font-weight: 500;
}

.sidebar-subitem:hover {
  background: var(--gray-50);
  color: var(--gray-700);
}

.sidebar-subitem.active {
  color: var(--primary);
  font-weight: 600;
  background: var(--primary-light);
}

.sidebar-divider {
  height: 1px;
  background: var(--gray-200);
  margin: 8px 8px;
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-400);
  padding: 12px 14px 4px;
}

.sidebar-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--gray-100);
  color: var(--gray-500);
  font-size: 11px;
  font-weight: 700;
}

.sidebar-item.active .sidebar-badge {
  background: rgba(79, 70, 229, 0.15);
  color: var(--primary);
}

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--gray-200);
  background: var(--white);
  border-radius: var(--radius);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--gray-600);
  transition: all var(--transition);
}

.sidebar-toggle:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

/* Navbar */
.navbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.navbar-brand {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: -0.5px;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.navbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.navbar-user-info {
  line-height: 1.3;
}

.navbar-user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
}

.navbar-user-role {
  font-size: 11px;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 32px 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

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

.page-header h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--gray-900);
}

.page-header p {
  font-size: 14px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* Stats Cards */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.stat-icon.purple { background: #EEF2FF; }
.stat-icon.green { background: #F0FDF4; }
.stat-icon.blue { background: #EFF6FF; }
.stat-icon.amber { background: #FFFBEB; }

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1;
}

.stat-label {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 2px;
}

/* ─── Table Card ──────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.search-input {
  padding: 8px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  width: 260px;
  outline: none;
  transition: border-color var(--transition);
}

.search-input:focus {
  border-color: var(--primary);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

table thead {
  background: var(--gray-50);
}

table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

table td {
  padding: 14px 16px;
  font-size: 14px;
  color: var(--gray-700);
  border-top: 1px solid var(--gray-100);
  white-space: nowrap;
}

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

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

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.badge-active {
  background: #DCFCE7;
  color: #166534;
}

.badge-inactive {
  background: #FEE2E2;
  color: #991B1B;
}

.badge-trial { background: #FEF3C7; color: #92400E; }
.badge-basic { background: #DBEAFE; color: #1E40AF; }
.badge-premium { background: #EDE9FE; color: #5B21B6; }

/* Enquiry Status Badges */
.badge-new { background: #DBEAFE; color: #1E40AF; }
.badge-contacted { background: #E0E7FF; color: #3730A3; }
.badge-followup { background: #FEF3C7; color: #92400E; }

/* Application Status Badges */
.badge-pending { background: #FEF3C7; color: #92400E; }
.badge-review { background: #E0E7FF; color: #3730A3; }
.badge-waitlisted { background: #FEE2E2; color: #991B1B; }

/* Role & status utility badges */
.badge-green { background: #DCFCE7; color: #166534; }
.badge-red { background: #FEE2E2; color: #991B1B; }
.badge-blue { background: #DBEAFE; color: #1E40AF; }
.badge-purple { background: #EDE9FE; color: #5B21B6; }
.badge-amber { background: #FEF3C7; color: #92400E; }

/* Branch code feedback */
.branch-code-feedback {
  font-size: 12px;
  margin-top: 4px;
  min-height: 18px;
  transition: color 0.2s;
}
.branch-code-feedback.checking { color: var(--gray-500); }
.branch-code-feedback.available { color: #059669; font-weight: 600; }
.branch-code-feedback.taken { color: #DC2626; font-weight: 600; }

/* Pagination */
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--gray-500);
}

.pagination {
  display: flex;
  gap: 4px;
}

.pagination button {
  padding: 6px 12px;
  border: 1px solid var(--gray-200);
  background: var(--white);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  color: var(--gray-600);
  font-family: inherit;
  transition: all var(--transition);
}

.pagination button:hover:not(:disabled) {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

.pagination button.active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ─── Modal ───────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

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

.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.2s ease;
}

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

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

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

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--gray-100);
  border-radius: 6px;
  cursor: pointer;
  font-size: 18px;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

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

.modal-body {
  padding: 24px;
}

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

/* ─── Empty State ─────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-400);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 15px;
  margin-bottom: 16px;
}

/* ─── Loading Spinner ─────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner.white {
  border-color: rgba(255,255,255,0.3);
  border-top-color: var(--white);
}

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

/* ─── Breadcrumb ─────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 8px;
}

.breadcrumb a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: var(--gray-300); }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-600);
  text-decoration: none;
  margin-bottom: 16px;
  transition: color var(--transition);
}

.back-link:hover { color: var(--primary); }

/* ─── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  .main-content { padding: 20px 16px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .card-header { flex-direction: column; align-items: flex-start; }
  .search-input { width: 100%; }
  .form-row { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr 1fr; }

  .sidebar {
    position: fixed;
    top: 64px;
    left: -260px;
    z-index: 99;
    transition: left 0.25s ease;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-toggle {
    display: flex;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    top: 64px;
    background: rgba(0,0,0,0.3);
    z-index: 98;
  }

  .sidebar-backdrop.show {
    display: block;
  }
}
