/* ============================================================
   Waahan – Shared Stylesheet
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── CSS Variables ── */
:root {
  --bg-color: #0f172a;
  --surface-color: rgba(30, 41, 59, 0.7);
  --surface-border: rgba(255, 255, 255, 0.1);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent-color: #f59e0b;
  --accent-gradient: linear-gradient(135deg, #f59e0b, #d97706);
  --error-color: #ef4444;
  --success-color: #22c55e;
  --radius: 12px;
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --transition: 0.25s ease;
}

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

html { font-size: 16px; }

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-color); text-decoration: none; transition: opacity var(--transition); }
a:hover { opacity: 0.8; }

/* ── Glass Card ── */
.glass-card {
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 2rem;
}

/* ── Form Elements ── */
.form-group { margin-bottom: 1.25rem; }

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.9375rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.form-control::placeholder { color: var(--text-secondary); opacity: 0.7; }

select.form-control { cursor: pointer; }

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

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .form-group { flex: 1; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn:hover { opacity: 0.88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--accent-gradient);
  color: #0f172a;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--surface-border);
  color: var(--text-primary);
}

.btn-outline:hover { border-color: var(--accent-color); color: var(--accent-color); }

.btn-danger {
  background: var(--error-color);
  color: #fff;
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.8125rem;
}

.btn-full { width: 100%; }

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

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--surface-color);
  border-right: 1px solid var(--surface-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  z-index: 50;
  transition: transform var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid var(--surface-border);
}

.sidebar-brand .brand-icon {
  width: 36px;
  height: 36px;
  background: var(--accent-gradient);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: #0f172a;
  font-weight: 700;
}

.sidebar-brand .brand-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sidebar-brand .brand-role {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--accent-color);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-close {
  display: none;
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: 1px solid var(--surface-border);
  color: var(--text-primary);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background var(--transition);
}

.sidebar-close:hover { background: rgba(255,255,255,0.08); }

.sidebar-nav { flex: 1; padding: 1rem 0.75rem; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }

.nav-item.active {
  background: rgba(245, 158, 11, 0.12);
  color: var(--accent-color);
}

.nav-item .nav-icon { font-size: 1.1rem; width: 1.25rem; text-align: center; }

.nav-item.logout-btn { color: var(--error-color); margin-top: auto; }
.nav-item.logout-btn:hover { background: rgba(239, 68, 68, 0.1); }

/* ── Main Content ── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-height);
  background: var(--surface-color);
  border-bottom: 1px solid var(--surface-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-shrink: 0;
}

.topbar-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ── User Profile (topbar) ── */
.user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9375rem;
  color: #0f172a;
  flex-shrink: 0;
}

.user-info .user-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.user-info .user-email {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* ── Content Area ── */
.content-area {
  flex: 1;
  padding: 1.75rem 2rem;
  overflow-y: auto;
}

/* ── Tab Content ── */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  backdrop-filter: blur(12px);
}

.stat-card .stat-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.stat-card .stat-icon {
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
}

/* ── Table ── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  border: 1px solid var(--surface-border);
}

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

thead th {
  background: rgba(15, 23, 42, 0.6);
  padding: 0.875rem 1rem;
  text-align: left;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--surface-border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--surface-border);
  transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.03); }

tbody td {
  padding: 0.875rem 1rem;
  color: var(--text-primary);
  font-size: 0.9rem;
  vertical-align: middle;
}

/* ── Badge / Status ── */
.badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-active { background: rgba(34,197,94,0.15); color: var(--success-color); }
.badge-inactive { background: rgba(239,68,68,0.15); color: var(--error-color); }
.badge-pending { background: rgba(245,158,11,0.15); color: var(--accent-color); }
.badge-user { background: rgba(99,102,241,0.15); color: #818cf8; }
.badge-sp { background: rgba(245,158,11,0.15); color: var(--accent-color); }
.badge-admin { background: rgba(239,68,68,0.15); color: var(--error-color); }

/* ── Section Header ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.section-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Search Input ── */
.search-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.search-wrap .search-icon {
  position: absolute;
  left: 0.75rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  pointer-events: none;
}

.search-input {
  padding: 0.6rem 1rem 0.6rem 2.25rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  outline: none;
  min-width: 220px;
  transition: border-color var(--transition);
}

.search-input:focus { border-color: var(--accent-color); }
.search-input::placeholder { color: var(--text-secondary); }

/* ── Services Grid ── */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
}

.service-card {
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.service-card .service-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.service-card .service-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
  flex: 1;
}

.service-card .service-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ── Modal ── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 100;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  padding: 1rem;
}

.modal-backdrop.open { display: flex; }

.modal-card {
  background: #1e293b;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.modal-title { font-size: 1.125rem; font-weight: 600; }

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
  transition: color var(--transition);
}

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

/* ── Center Wrapper (login pages) ── */
.center-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: var(--bg-color);
  position: relative;
  overflow: hidden;
}

.center-wrapper::before {
  content: '';
  position: absolute;
  top: -30%;
  left: -10%;
  width: 60%;
  height: 70%;
  background: radial-gradient(ellipse, rgba(245,158,11,0.06) 0%, transparent 70%);
  pointer-events: none;
}

.center-wrapper::after {
  content: '';
  position: absolute;
  bottom: -20%;
  right: -10%;
  width: 50%;
  height: 60%;
  background: radial-gradient(ellipse, rgba(99,102,241,0.05) 0%, transparent 70%);
  pointer-events: none;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
}

.auth-logo {
  text-align: center;
  margin-bottom: 1.75rem;
}

.auth-logo .logo-icon {
  width: 60px;
  height: 60px;
  background: var(--accent-gradient);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
  box-shadow: 0 8px 24px rgba(245,158,11,0.25);
}

.auth-logo h1 {
  font-size: 1.625rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.auth-logo p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* ── Sidebar Overlay ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 40;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.sidebar-overlay.active { display: block; }

/* ── Menu Toggle ── */
.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 1.2rem;
  flex-shrink: 0;
  transition: background var(--transition);
}

.menu-toggle:hover { background: rgba(255,255,255,0.08); }

/* ── Alert Messages ── */
.alert {
  padding: 0.875rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 1rem;
}

.alert-error { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.3); color: var(--error-color); }
.alert-success { background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.3); color: var(--success-color); }

/* ── Info Cards (user home) ── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.info-card {
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.info-card .info-label { font-size: 0.75rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.4rem; }
.info-card .info-value { font-size: 1rem; font-weight: 600; color: var(--text-primary); }

/* ── Utility Classes ── */
.hidden { display: none !important; }
.flex { display: flex; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.gap-4 { gap: 1rem; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-accent { color: var(--accent-color); }
.text-secondary { color: var(--text-secondary); }
.text-center { text-align: center; }
.text-error { color: var(--error-color); }
.text-success { color: var(--success-color); }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.font-semibold { font-weight: 600; }
.w-full { width: 100%; }

/* ── Landing Page ── */
.landing-card {
  text-align: center;
  max-width: 480px;
  width: 100%;
}

.landing-card .portal-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  margin-top: 2rem;
}

.portal-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-radius: 10px;
  border: 1px solid var(--surface-border);
  background: rgba(15, 23, 42, 0.5);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  text-decoration: none;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}

.portal-btn:hover {
  border-color: var(--accent-color);
  background: rgba(245,158,11,0.06);
  color: var(--text-primary);
  opacity: 1;
  transform: translateY(-1px);
}

.portal-btn .portal-btn-icon { font-size: 1.25rem; }
.portal-btn .portal-btn-arrow { color: var(--text-secondary); }

/* ── Settings ── */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  border-bottom: 1px solid var(--surface-border);
}

.settings-row:last-of-type { border-bottom: none; }

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.1);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: transform var(--transition), background var(--transition);
}

.toggle-switch input:checked + .toggle-slider { background: rgba(245,158,11,0.3); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); background: var(--accent-color); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

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

/* ── Tablet / Large Mobile (≤ 1024px) ── */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Mobile (≤ 768px) ── */
@media (max-width: 768px) {
  /* Sidebar becomes off-canvas */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 50;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.active { display: block; }

  .sidebar-close { display: flex; }

  /* Show hamburger */
  .menu-toggle { display: flex; }

  /* Topbar */
  .topbar { padding: 0 1rem; }

  /* Content */
  .content-area { padding: 1.25rem 1rem; }

  /* Stats grid — 2 cols */
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  /* Auth card */
  .auth-card { max-width: 100%; }
  .glass-card { padding: 1.5rem; }

  /* Modal */
  .modal-card { padding: 1.5rem; max-width: 100%; }
}

/* ── Small Mobile (≤ 480px) ── */
@media (max-width: 480px) {
  /* Stats grid — 1 col */
  .stats-grid { grid-template-columns: 1fr; }

  /* Form rows stack */
  .form-row { flex-direction: column; }

  /* Modal becomes bottom sheet */
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal-card {
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: 90vh;
    padding: 1.5rem 1.25rem;
  }

  .landing-card .portal-buttons { gap: 0.75rem; }

  .topbar-title { font-size: 1rem; }

  .section-header { flex-direction: column; align-items: flex-start; }
}
