/* ─── Reset & Base ─────────────────────────────────────── */

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

:root {
  --brand-50: #f0f4ff;
  --brand-100: #dbe4ff;
  --brand-200: #c3d4ff;
  --brand-500: #5c7cfa;
  --brand-600: #4c6ef5;
  --brand-700: #4263eb;
  --brand-800: #3b5bdb;

  --zinc-50: #fafafa;
  --zinc-100: #f4f4f5;
  --zinc-200: #e4e4e7;
  --zinc-300: #d4d4d8;
  --zinc-400: #a1a1aa;
  --zinc-500: #71717a;
  --zinc-600: #52525b;
  --zinc-700: #3f3f46;
  --zinc-800: #27272a;
  --zinc-900: #18181b;
  --zinc-950: #09090b;

  --bg: #fafafa;
  --bg-card: #ffffff;
  --bg-secondary: #f4f4f5;
  --text-primary: #18181b;
  --text-secondary: #52525b;
  --text-tertiary: #a1a1aa;
  --border: #e4e4e7;
  --border-light: rgba(228, 228, 231, 0.6);
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]),
  :root:not([data-theme="light"]) body {
    --brand-50: #1a1f3d;
    --brand-100: #252b50;
    --brand-200: #3a4270;

    --bg: #09090b;
    --bg-card: #18181b;
    --bg-secondary: #27272a;
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-tertiary: #71717a;
    --border: #3f3f46;
    --border-light: rgba(63, 63, 70, 0.6);
    --navbar-bg: rgba(9, 9, 11, 0.8);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
  }
}

[data-theme="dark"],
[data-theme="dark"] body {
  --brand-50: #1a1f3d;
  --brand-100: #252b50;
  --brand-200: #3a4270;

  --bg: #09090b;
  --bg-card: #18181b;
  --bg-secondary: #27272a;
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-tertiary: #71717a;
  --border: #3f3f46;
  --border-light: rgba(63, 63, 70, 0.6);
  --navbar-bg: rgba(9, 9, 11, 0.8);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
}

html {
  direction: rtl;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", sans-serif;
  -webkit-font-smoothing: antialiased;
  color-scheme: light dark;
}

body {
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ─── Utilities ────────────────────────────────────────── */

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden { display: none !important; }

/* ─── Navbar ───────────────────────────────────────────── */

.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--navbar-bg, rgba(250, 250, 250, 0.8));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-light);
}


.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.navbar-brand {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.navbar-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 6px;
}

.auth-logo,
.landing-logo,
.navbar-logo {
  transition: background 0.3s, padding 0.3s;
}

@media (prefers-color-scheme: dark) {
  .auth-logo,
  .landing-logo {
    background: rgba(255, 255, 255, 0.92);
    border-radius: 20px;
    padding: 10px;
  }
  .navbar-logo {
    background: rgba(255, 255, 255, 0.92);
    border-radius: 6px;
    padding: 3px;
  }
}

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

.navbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* ─── Buttons ──────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1.4;
}

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

.btn-primary {
  background: var(--brand-600);
  color: #fff;
}
.btn-primary:hover { background: var(--brand-700); }

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
}
.btn-secondary:hover { background: var(--border); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 12px;
}
.btn-ghost:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.btn-lg { padding: 14px 24px; font-size: 0.9375rem; }
.btn-block { width: 100%; }

/* ─── Form Elements ────────────────────────────────────── */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.form-input {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input::placeholder { color: var(--text-tertiary); }

.form-input:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(92, 124, 250, 0.15);
}

.form-error {
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: #fef2f2;
  color: #dc2626;
  font-size: 0.8125rem;
}


/* ─── Auth Pages ───────────────────────────────────────── */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-header .brand {
  font-size: 1.5rem;
  font-weight: 700;
  display: inline-block;
  margin-bottom: 16px;
}

.auth-logo {
  width: 80px;
  height: 80px;
  object-fit: contain;
  display: block;
  margin: 0 auto 16px;
}

.auth-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.auth-footer a {
  color: var(--brand-600);
  font-weight: 500;
}
.auth-footer a:hover { color: var(--brand-700); }

/* ─── Landing Page ─────────────────────────────────────── */

.landing-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: calc(100vh - 64px - 80px);
  padding: 48px 24px;
}

.landing-logo {
  width: 160px;
  height: 160px;
  object-fit: contain;
  margin-bottom: 8px;
}

.landing-icon {
  width: 80px;
  height: 80px;
  background: var(--brand-600);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}

.landing-icon svg {
  width: 40px;
  height: 40px;
  color: #fff;
  stroke: #fff;
  fill: none;
}

.landing-hero h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}

.landing-hero p {
  font-size: 1.125rem;
  color: var(--text-secondary);
  max-width: 400px;
  line-height: 1.8;
  margin-bottom: 32px;
}

.landing-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.landing-footer {
  text-align: center;
  padding: 32px;
  color: var(--text-tertiary);
  font-size: 0.875rem;
}

/* ─── Dashboard ────────────────────────────────────────── */

.dashboard-header {
  padding: 32px 0 0;
}

.dashboard-header .greeting {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.dashboard-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-top: 4px;
}

.dashboard-header .subtitle {
  font-size: 0.875rem;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* ─── Module Grid ──────────────────────────────────────── */

.module-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 32px 0 48px;
}

@media (max-width: 600px) {
  .module-grid { grid-template-columns: 1fr; }
}

/* ─── Module Card ──────────────────────────────────────── */

.module-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  transition: all 0.2s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.module-card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.module-card.disabled {
  opacity: 0.6;
  cursor: default;
}
.module-card.disabled:hover {
  transform: none;
  box-shadow: none;
}

.module-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.module-card-icon svg {
  width: 24px;
  height: 24px;
  stroke-width: 1.8;
}

.module-card h3 {
  font-size: 1rem;
  font-weight: 600;
}

.module-card p {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.module-card .badge {
  position: absolute;
  left: 16px;
  top: 16px;
  font-size: 0.6875rem;
  font-weight: 500;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  padding: 2px 10px;
  border-radius: 100px;
}

/* ─── Module Page (placeholder) ────────────────────────── */

.module-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 60vh;
  gap: 24px;
  padding: 48px 24px;
}

.module-page-icon {
  width: 96px;
  height: 96px;
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
}

.module-page-icon svg {
  width: 44px;
  height: 44px;
  stroke-width: 1.5;
}

.module-page h1 {
  font-size: 2rem;
  font-weight: 700;
}

.module-page .status-badge {
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--bg-secondary);
  color: var(--text-tertiary);
  padding: 6px 16px;
  border-radius: 100px;
}

/* ─── Profile ──────────────────────────────────────────── */

.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 32px;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 16px;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-50);
}


.profile-avatar svg {
  width: 28px;
  height: 28px;
  color: var(--brand-600);
  stroke: var(--brand-600);
}

.profile-name {
  font-size: 1.125rem;
  font-weight: 600;
}

.profile-email {
  font-size: 0.875rem;
  color: var(--text-secondary);
  direction: ltr;
  text-align: right;
}

.profile-meta {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border-light);
}

.profile-meta-label {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.profile-meta-value {
  font-size: 0.875rem;
  font-weight: 500;
  margin-top: 4px;
}

/* ─── Spinner ──────────────────────────────────────────── */

.spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--brand-600);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

/* ─── Skeleton ─────────────────────────────────────────── */

.skeleton {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

/* ─── Custom Confirm Dialog ──────────────────────────────── */

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  animation: confirmFadeIn .2s ease forwards;
  padding: 16px;
}

@keyframes confirmFadeIn {
  to { opacity: 1; }
}

.confirm-box {
  background: var(--bg-card, #fff);
  border-radius: 20px;
  width: 100%;
  max-width: 340px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 24px 60px rgba(0,0,0,0.15);
  transform: scale(0.9) translateY(10px);
  animation: confirmScaleIn .25s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes confirmScaleIn {
  to { transform: scale(1) translateY(0); }
}

.confirm-body {
  padding: 28px 28px 20px;
  text-align: center;
}

.confirm-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.confirm-icon.danger {
  background: #fef2f2;
  color: #dc2626;
}

.confirm-icon.warning {
  background: #fffbeb;
  color: #d97706;
}

.confirm-title {
  font-size: 1.0625rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.confirm-message {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  padding: 0 24px 24px;
}

.confirm-actions button {
  flex: 1;
  padding: 12px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all .15s;
}

.confirm-actions button:first-child {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.confirm-actions button:first-child:hover {
  background: var(--border);
}

.confirm-actions button:last-child:not(:first-child) {
  border-right: 1px solid var(--border);
}

.confirm-actions button.confirm-danger {
  background: #dc2626;
  color: #fff;
}

.confirm-actions button.confirm-danger:hover {
  background: #b91c1c;
}

.confirm-actions button.confirm-primary {
  background: var(--brand-600, #4c6ef5);
  color: #fff;
}

.confirm-actions button.confirm-primary:hover {
  background: var(--brand-700, #4263eb);
}
