/* ==========================================================================
   HisabKitab Super Admin - Enterprise Design System
   Dark sidebar + polished light content, Stripe-grade admin UI
   ========================================================================== */

:root {
  /* Backgrounds */
  --bg-page: #f4f6fb;
  --bg-surface: #ffffff;
  --bg-surface-soft: #f8fafc;
  --bg-elevated: #eef1f7;
  --bg-dark-tint: #1e293b;

  /* Borders */
  --card-border: #e6eaf2;
  --card-border-hover: #c7d2e0;

  /* Text */
  --text-main: #1e293b;
  --text-strong: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  /* Accents */
  --accent-primary: #2563eb;
  --accent-primary-strong: #1d4ed8;
  --accent-primary-gradient: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
  --accent-purple: #7c3aed;
  --accent-purple-light: #a855f7;
  --accent-purple-gradient: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
  --accent-green: #059669;
  --accent-green-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);

  /* Status */
  --status-green: #16a34a;
  --status-green-bg: #ecfdf5;
  --status-green-border: #a7f3d0;

  --status-red: #dc2626;
  --status-red-bg: #fef2f2;
  --status-red-border: #fecaca;

  --status-amber: #d97706;
  --status-amber-bg: #fffbeb;
  --status-amber-border: #fde68a;

  --status-blue: #2563eb;
  --status-blue-bg: #eff6ff;

  /* Sidebar */
  --sidebar-bg: #0d1321;
  --sidebar-bg-soft: #131b2e;
  --sidebar-text: #8fa0bf;
  --sidebar-text-active: #ffffff;
  --sidebar-border: rgba(255, 255, 255, 0.06);

  --font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.16);
  --shadow-accent: 0 8px 22px rgba(37, 99, 235, 0.28);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font-family);
  background: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}

/* ─── App shell: fixed sidebar + content ──────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 264px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 16px;
  transition: width 0.22s ease, padding 0.22s ease;
}

/* Collapsed (icon-only) sidebar state */
.sidebar.collapsed {
  width: 74px;
  padding: 20px 10px;
}

.sidebar.collapsed .brand-container {
  flex-direction: column;
  gap: 10px;
  padding: 4px 0 20px;
}

.sidebar.collapsed .brand-title,
.sidebar.collapsed .sidebar-admin-card .admin-meta,
.sidebar.collapsed .sidebar-footer .btn-outline span {
  display: none;
}

.sidebar.collapsed .nav-tab-btn {
  justify-content: center;
  padding: 13px;
}

.sidebar.collapsed .nav-tab-btn span {
  display: none;
}

.sidebar.collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
  transition: transform 0.22s ease;
}

.sidebar.collapsed .sidebar-admin-card {
  justify-content: center;
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 24px;
}

.sidebar-toggle {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--sidebar-border);
  border-radius: 8px;
  color: var(--sidebar-text);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.18s ease;
}

.sidebar-toggle svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.sidebar-toggle:hover {
  background: var(--sidebar-bg-soft);
  color: var(--sidebar-text-active);
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: var(--accent-primary-gradient);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  color: #ffffff;
  box-shadow: var(--shadow-accent);
  flex-shrink: 0;
  overflow: hidden;
}

.brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-title h1 {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--sidebar-text-active);
  line-height: 1.2;
}

.brand-title span {
  font-size: 11px;
  color: var(--sidebar-text);
  font-weight: 500;
}

/* Sidebar navigation */
.nav-tabs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  flex: 1;
}

.nav-tab-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
  width: 100%;
  position: relative;
}

.nav-tab-btn svg {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
  fill: currentColor;
}

.nav-tab-btn:hover {
  background: var(--sidebar-bg-soft);
  color: var(--sidebar-text-active);
}

.nav-tab-btn.active {
  background: var(--accent-primary-gradient);
  color: var(--sidebar-text-active);
  font-weight: 700;
  box-shadow: var(--shadow-accent);
}

.sidebar-footer {
  border-top: 1px solid var(--sidebar-border);
  padding-top: 14px;
  margin-top: 8px;
}

.sidebar-admin-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
}

.admin-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-primary-gradient);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  box-shadow: var(--shadow-accent);
  flex-shrink: 0;
}

.admin-meta { min-width: 0; }
.admin-meta .name {
  font-size: 13px;
  font-weight: 700;
  color: var(--sidebar-text-active);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-meta .email {
  font-size: 11px;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer .btn-outline {
  background: transparent;
  border-color: var(--sidebar-border);
  color: var(--sidebar-text);
}
.sidebar-footer .btn-outline:hover {
  border-color: var(--accent-purple-light);
  color: var(--accent-purple-light);
  background: transparent;
}

/* Main content column */
.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 90;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--card-border);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-title h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-strong);
  letter-spacing: -0.02em;
}

.topbar-title p {
  font-size: 12px;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sync-status {
  background: var(--bg-surface);
  border: 1px solid var(--card-border);
  padding: 8px 15px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}

.sync-dot {
  width: 8px;
  height: 8px;
  background: var(--status-green);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.16);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.16); }
  50% { box-shadow: 0 0 0 6px rgba(22, 163, 74, 0.06); }
}

/* Page content */
.app-container {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 32px 56px;
  flex: 1;
}

/* ─── Card elements ───────────────────────────────────────────────── */
.card-panel {
  background: var(--bg-surface);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 22px;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.card-panel:hover { box-shadow: var(--shadow-md); border-color: var(--card-border-hover); }

/* ─── Buttons ─────────────────────────────────────────────────────── */
.btn {
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  line-height: 1.4;
}

.btn-primary {
  background: var(--accent-primary-gradient);
  color: #ffffff;
  box-shadow: var(--shadow-accent);
}
.btn-primary:hover { opacity: 0.94; transform: translateY(-1px); }

.btn-purple {
  background: var(--accent-purple-gradient);
  color: #ffffff;
  box-shadow: 0 6px 14px rgba(124, 58, 237, 0.28);
}
.btn-purple:hover { opacity: 0.94; transform: translateY(-1px); }

.btn-green {
  background: var(--accent-green-gradient);
  color: #ffffff;
  box-shadow: 0 6px 14px rgba(5, 150, 105, 0.28);
}
.btn-green:hover { opacity: 0.94; transform: translateY(-1px); }

.btn-outline {
  background: var(--bg-surface);
  border: 1px solid var(--card-border);
  color: var(--text-main);
}
.btn-outline:hover { border-color: var(--accent-primary); color: var(--accent-primary); background: var(--status-blue-bg); }

.btn-danger {
  background: var(--status-red-bg);
  border: 1px solid var(--status-red-border);
  color: var(--status-red);
}
.btn-danger:hover { background: var(--status-red); color: #ffffff; border-color: var(--status-red); }

.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }

/* ─── Badges ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  text-transform: capitalize;
  white-space: nowrap;
}

.badge-active { background: var(--status-green-bg); color: var(--status-green); border: 1px solid var(--status-green-border); }
.badge-expired { background: var(--status-red-bg); color: var(--status-red); border: 1px solid var(--status-red-border); }
.badge-warning { background: var(--status-amber-bg); color: var(--status-amber); border: 1px solid var(--status-amber-border); }
.badge-blocked { background: var(--status-red-bg); color: var(--status-red); border: 1px solid var(--status-red-border); }

.badge-new {
  background: var(--accent-purple-gradient);
  color: #ffffff;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 100px;
  letter-spacing: 0.04em;
  font-weight: 800;
}

/* ─── Form controls ───────────────────────────────────────────────── */
.input-control {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  color: var(--text-main);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.input-control:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.input-control::placeholder { color: var(--text-faint); }

/* ─── Login screen ────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1100px 600px at 15% 10%, #1d4ed8 0%, transparent 45%),
    radial-gradient(900px 500px at 90% 90%, #7c3aed 0%, transparent 45%),
    linear-gradient(160deg, #0d1321 0%, #101a2e 55%, #0d1321 100%);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  text-align: center;
}

.login-brand {
  width: 66px;
  height: 66px;
  margin: 0 auto 18px;
  background: var(--accent-primary-gradient);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 800;
  color: #ffffff;
  box-shadow: var(--shadow-accent);
  overflow: hidden;
}

.login-brand img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.login-card h2 {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-strong);
  margin-bottom: 6px;
}

.login-card .login-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 26px;
}

.login-field {
  text-align: left;
  margin-bottom: 16px;
}

.login-field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 7px;
}

.login-card .btn-login {
  width: 100%;
  padding: 13px;
  font-size: 15px;
  margin-top: 6px;
}

.login-err {
  display: none;
  color: var(--status-red);
  background: var(--status-red-bg);
  border: 1px solid var(--status-red-border);
  font-size: 12px;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 14px;
  text-align: left;
}

.login-card .login-hint {
  margin-top: 20px;
  font-size: 11px;
  color: var(--text-faint);
  border-top: 1px dashed var(--card-border);
  padding-top: 14px;
}

[data-hidden-login="true"] #appView { display: none; }

/* ─── Modals ──────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 19, 33, 0.55);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.modal-backdrop.open { opacity: 1; pointer-events: auto; }

.modal-window {
  background: var(--bg-surface);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  width: 92%;
  max-width: 820px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-window.fullscreen-modal {
  width: 96vw;
  max-width: 1440px;
  height: 92vh;
  max-height: 92vh;
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface-soft);
}

.modal-header h3 { font-size: 17px; font-weight: 800; color: var(--text-strong); }

.modal-body { padding: 24px; overflow-y: auto; flex: 1; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: var(--bg-surface-soft);
}

/* ─── Toast ───────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 26px;
  right: 26px;
  background: var(--text-strong);
  border: none;
  color: #ffffff;
  padding: 14px 20px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.25s ease;
  z-index: 1000;
  pointer-events: none;
}

.toast-container.show { opacity: 1; transform: translateY(0); }

/* ─── Spinner ─────────────────────────────────────────────────────── */
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--card-border);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Scrollbar polish */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; background-clip: content-box; }

/* Responsive */
@media (max-width: 900px) {
  .sidebar { width: 76px; padding: 20px 10px; }
  .brand-title, .nav-tab-btn span:not(:first-child), .sidebar-admin-card .admin-meta { display: none; }
  .nav-tab-btn { justify-content: center; padding: 13px; }
  .app-container { padding: 20px; }
  .topbar { padding: 14px 20px; }

  /* Keep expanded state consistent on small screens (force collapsed look) */
  .sidebar.collapsed,
  .sidebar:not(.collapsed) {
    width: 76px;
  }

  .sidebar .sidebar-toggle {
    display: none;
  }

  .sidebar.collapsed .brand-container,
  .sidebar:not(.collapsed) .brand-container {
    flex-direction: column;
    gap: 10px;
    padding: 4px 0 20px;
  }

  .sidebar.collapsed .sidebar-toggle svg,
  .sidebar:not(.collapsed) .sidebar-toggle svg {
    transform: none;
  }
}