/* ============================================================================
 * GS ERP — Shared theme
 *
 * Adapted from the Tadgeeg UI kit. Designed to coexist with Bootstrap 5 RTL
 * (loaded on Arabic) by overriding *only* the bits that matter for the new
 * visual language: colour palette, typography, cards, buttons, inputs,
 * sidebar/topbar look. We use CSS logical properties (block-start / inline-end)
 * wherever we can, so the same rule reads correctly under `dir="rtl"`.
 * Direction-specific overrides are confined to a tight `[dir="rtl"]` block
 * at the bottom of this file.
 * ============================================================================
 */

/* Border-box reset. The auth shell (login / register / OTP / org-setup) does
 * NOT load Bootstrap, so without this an `.auth-input` with width:100% plus
 * 44px padding overflows its grid cell and overlaps the neighbouring field.
 * Harmless on dashboard pages — Bootstrap sets the same rule there anyway. */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --primary:        #003366;
  --primary-dark:   #002244;
  --primary-light:  #1a4d80;
  --accent:         #10B981;
  --accent-dark:    #059669;
  --accent-light:   #34d399;
  --bg:             #ffffff;
  --bg-soft:        #f8fafc;
  --bg-softer:      #f1f5f9;
  --text:           #1e293b;
  --text-muted:     #64748b;
  --text-light:     #94a3b8;
  --border:         #e2e8f0;
  --border-soft:    #f1f5f9;
  --success:        #10B981;
  --warning:        #f59e0b;
  --danger:         #ef4444;
  --info:           #3b82f6;

  --shadow-sm:  0 1px 2px 0 rgba(0, 51, 102, 0.05);
  --shadow-md:  0 4px 6px -1px rgba(0, 51, 102, 0.08),
                0 2px 4px -2px rgba(0, 51, 102, 0.05);
  --shadow-lg:  0 10px 15px -3px rgba(0, 51, 102, 0.10),
                0 4px 6px -4px rgba(0, 51, 102, 0.05);
  --shadow-xl:  0 25px 50px -12px rgba(0, 51, 102, 0.18);

  /* Bootstrap variable overrides so default components inherit our palette. */
  --bs-primary:        var(--primary);
  --bs-primary-rgb:    0, 51, 102;
  --bs-success:        var(--accent);
  --bs-body-color:     var(--text);
  --bs-body-bg:        var(--bg-soft);
  --bs-border-color:   var(--border);
  --bs-link-color:     var(--primary);
  --bs-link-hover-color: var(--primary-dark);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Tajawal', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background: var(--bg-soft);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6,
.title-cairo {
  font-family: 'Cairo', 'Tajawal', sans-serif;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.3px;
}

a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

/* ===========================
 * Buttons
 * =========================== */
.btn {
  font-family: inherit;
  font-weight: 700;
  border-radius: 10px;
  padding: 10px 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  transition: all 0.22s ease;
  border: 0;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}
.btn-primary:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
  color: #fff;
}
.btn-dark, .btn-secondary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 51, 102, 0.25);
}
.btn-dark:hover, .btn-secondary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  color: #fff;
}
.btn-outline-primary, .btn-outline-secondary {
  background: #fff;
  color: var(--primary);
  border: 1.5px solid var(--border);
}
.btn-outline-primary:hover, .btn-outline-secondary:hover {
  border-color: var(--primary);
  background: var(--bg-soft);
  color: var(--primary);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.25);
}
.btn-info {
  background: var(--info);
  color: #fff;
}
.btn-lg {
  padding: 16px 32px;
  font-size: 16px;
  border-radius: 12px;
}
.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 8px;
}
.btn-block { width: 100%; }

/* ===========================
 * Form inputs
 * =========================== */
.form-control, .form-select, input.form-input {
  background: var(--bg-soft);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text);
  transition: all 0.2s ease;
  width: 100%;
}
.form-control:focus, .form-select:focus, input.form-input:focus {
  outline: none;
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(0, 51, 102, 0.08);
}
.form-label, label {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
small, .text-muted { color: var(--text-muted) !important; }

/* ===========================
 * Cards
 * =========================== */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}
.card:hover {
  box-shadow: var(--shadow-md);
}
.card-header {
  background: #fff;
  border-bottom: 1px solid var(--border-soft);
  font-weight: 700;
  color: var(--text);
  padding: 14px 18px;
  border-radius: 16px 16px 0 0;
}
.card-body { padding: 18px; }

/* ===========================
 * Badges
 * =========================== */
.badge {
  font-weight: 700;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 8px;
  letter-spacing: 0.2px;
}
.badge-success, .bg-success {
  background: rgba(16, 185, 129, 0.12) !important;
  color: var(--accent-dark) !important;
}
.badge-warning, .bg-warning {
  background: rgba(245, 158, 11, 0.12) !important;
  color: var(--warning) !important;
}
.badge-danger, .bg-danger {
  background: rgba(239, 68, 68, 0.12) !important;
  color: var(--danger) !important;
}
.badge-info, .bg-info {
  background: rgba(59, 130, 246, 0.12) !important;
  color: var(--info) !important;
}
.badge-secondary, .bg-secondary {
  background: var(--bg-softer) !important;
  color: var(--text-muted) !important;
}

/* ===========================
 * Tables
 * =========================== */
.table {
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
}
.table thead th {
  background: var(--bg-softer);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border: 0;
  padding: 14px 16px;
}
.table td {
  padding: 14px 16px;
  border-color: var(--border-soft);
  vertical-align: middle;
  font-size: 14px;
}

/* ===========================
 * Logo block
 * =========================== */
.erp-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: 'Cairo', sans-serif;
  font-weight: 900;
  color: var(--primary);
  font-size: 22px;
  text-decoration: none;
}
.erp-logo-mark {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: 12px;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 900;
  box-shadow: 0 6px 16px rgba(0, 51, 102, 0.25);
}
.erp-logo-text { line-height: 1.1; }
.erp-logo-text small {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===========================
 * Auth pages (full-screen layout)
 * =========================== */
.auth-shell {
  min-height: 100vh;
  display: grid;
  /* Form side gets the larger share so two-column inputs (first/last name,
     password/confirm) don't crowd. Brand panel is decorative — it shrinks
     gracefully. */
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  background: #fff;
}
.auth-form-side {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px 56px;
}
.auth-form-container {
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  animation: erp-fade-in 0.55s ease both;
}
.auth-title {
  font-family: 'Cairo', sans-serif;
  font-size: 32px;
  font-weight: 900;
  margin-bottom: 8px;
}
.auth-desc {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 28px;
}

/* --- Onboarding wizard progress indicator --------------------------------- */
.wizard-steps {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0;
  margin: 0 0 30px;
  padding: 0;
}
.wizard-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
}
.wizard-step-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  background: var(--bg-soft);
  color: var(--text-light);
  border: 2px solid var(--border);
  transition: all 0.25s ease;
}
.wizard-step-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-light);
  white-space: nowrap;
}
.wizard-step.is-active .wizard-step-dot {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(0, 51, 102, 0.10);
}
.wizard-step.is-active .wizard-step-label { color: var(--primary); }
.wizard-step.is-done .wizard-step-dot {
  background: var(--accent, #1f9d57);
  border-color: var(--accent, #1f9d57);
  color: #fff;
}
.wizard-step.is-done .wizard-step-label { color: var(--text); }
.wizard-step-bar {
  flex: 1 1 auto;
  height: 2px;
  background: var(--border);
  margin: 0 8px;
  margin-bottom: 25px;   /* aligns the bar with the dot centre */
  border-radius: 2px;
  transition: background 0.25s ease;
}
.wizard-step-bar.is-done { background: var(--accent, #1f9d57); }

/* --- Auth form field groups ----------------------------------------------- */
.auth-field { margin-bottom: 18px; }
.auth-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.auth-section-title {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  margin: 4px 0 14px;
}
.auth-field-hint {
  display: block;
  font-size: 12px;
  color: var(--text-light);
  margin-top: 5px;
}
.auth-field-error {
  display: block;
  font-size: 12px;
  color: var(--danger);
  margin-top: 5px;
  font-weight: 600;
}
.auth-input.has-error { border-color: var(--danger); }
select.auth-input { padding-inline-start: 16px; cursor: pointer; }
@media (max-width: 560px) {
  .auth-row { grid-template-columns: 1fr; gap: 0; }
}
.auth-input {
  box-sizing: border-box;
  display: block;
  width: 100%;
  padding-block: 14px;
  padding-inline-start: 44px;
  padding-inline-end: 16px;
  background: var(--bg-soft);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  color: var(--text);
  transition: all 0.2s ease;
}
.auth-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(0, 51, 102, 0.08);
}
.auth-input-wrap { position: relative; }
.auth-input-icon {
  position: absolute;
  inset-inline-start: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
}
.auth-submit {
  width: 100%;
  padding: 16px;
  background: var(--primary);
  color: #fff;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  border: 0;
  box-shadow: 0 8px 20px rgba(0, 51, 102, 0.2);
  transition: all 0.25s ease;
  cursor: pointer;
}
.auth-submit:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(0, 51, 102, 0.28);
}

.auth-brand-side {
  position: relative;
  overflow: hidden;
  /* Padding tuned for the narrower brand pane (≈38% of viewport) — keeps the
     orb/text legible without spilling into the form side. */
  padding: 48px 40px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-brand-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.45;
  pointer-events: none;
}
.auth-brand-orb.orb-1 {
  width: 400px; height: 400px;
  background: var(--accent);
  top: -100px; inset-inline-end: -100px;
  opacity: 0.3;
}
.auth-brand-orb.orb-2 {
  width: 350px; height: 350px;
  background: var(--primary-light);
  bottom: -80px; inset-inline-start: -80px;
}
.auth-brand-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 40px 40px;
}
.auth-brand-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 460px;
}
.auth-brand-quote {
  font-family: 'Cairo', sans-serif;
  font-size: 30px;
  font-weight: 800;
  line-height: 1.4;
  margin-bottom: 40px;
}
.auth-brand-quote .highlight { color: var(--accent-light); }
.auth-brand-features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 40px;
}
.auth-brand-feature {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  padding: 18px;
  backdrop-filter: blur(10px);
}
.auth-brand-feature-value {
  font-family: 'Cairo', sans-serif;
  font-size: 28px;
  font-weight: 900;
  color: var(--accent-light);
  margin-bottom: 4px;
}
.auth-brand-feature-label {
  font-size: 12px;
  opacity: 0.85;
}

@keyframes erp-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===========================
 * Stat cards — Tadgeeg-faithful KPI tile
 * =========================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}
.stat-card {
    background: #fff;
    border: 1px solid var(--border-soft);
    border-radius: 18px;
    padding: 22px;
    position: relative;
    overflow: hidden;
    transition: transform .25s ease, box-shadow .25s ease;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.stat-card-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center; justify-content: center;
    margin-bottom: 16px;
    font-size: 18px;
}
.stat-card-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.stat-card-value {
    font-family: 'Cairo', 'Tajawal', sans-serif;
    font-size: 30px;
    font-weight: 900;
    letter-spacing: -1px;
    line-height: 1;
}
.stat-card-sub {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 8px;
}
.stat-card-trend {
    position: absolute;
    top: 22px;
    inset-inline-end: 22px;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 100px;
    background: var(--bg-soft);
    color: var(--text-muted);
}
.stat-card-trend.up   { background: rgba(16,185,129,0.12); color: var(--accent-dark); }
.stat-card-trend.down { background: rgba(239,68,68,0.12);  color: var(--danger); }

.stat-card.blue  .stat-card-icon  { background: rgba(59,130,246,0.12); color: var(--info); }
.stat-card.blue  .stat-card-value { color: var(--info); }
.stat-card.green .stat-card-icon  { background: rgba(16,185,129,0.12); color: var(--accent); }
.stat-card.green .stat-card-value { color: var(--accent-dark); }
.stat-card.red   .stat-card-icon  { background: rgba(239,68,68,0.12); color: var(--danger); }
.stat-card.red   .stat-card-value { color: var(--danger); }
.stat-card.amber .stat-card-icon  { background: rgba(245,158,11,0.12); color: var(--warning); }
.stat-card.amber .stat-card-value { color: var(--warning); }
.stat-card.primary .stat-card-icon  { background: rgba(0,51,102,0.10); color: var(--primary); }
.stat-card.primary .stat-card-value { color: var(--primary); }


/* ===========================
 * Dashboard chrome
 * =========================== */
.dashboard-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}
.kpi-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0; bottom: 0;
  width: 4px;
  background: var(--primary);
}
.kpi-card.is-success::before { background: var(--accent); }
.kpi-card.is-warning::before { background: var(--warning); }
.kpi-card.is-danger::before  { background: var(--danger); }
.kpi-card-label {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 8px;
}
.kpi-card-value {
  font-family: 'Cairo', sans-serif;
  font-size: 32px;
  font-weight: 900;
  color: var(--text);
  line-height: 1.1;
}
.kpi-card-delta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.kpi-card-delta.is-up    { color: var(--accent-dark); }
.kpi-card-delta.is-down  { color: var(--danger); }

/* ===========================
 * Sidebar / topbar polish
 * =========================== */
.app-topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
/* theme.css styles the topbar text white (legacy green topbar). This theme
 * uses a WHITE topbar, so re-colour brand / links / icons to dark — without
 * this the avatar, notification bell and language switcher are white-on-white
 * and effectively invisible. */
.app-topbar .navbar-brand { color: var(--primary) !important; }
.app-topbar .nav-link {
  color: var(--text) !important;
}
.app-topbar .nav-link i { color: var(--text-muted); }
.app-topbar .nav-link:hover {
  background: var(--bg-soft);
  color: var(--primary) !important;
}
.app-topbar .nav-link:hover i { color: var(--primary); }
.app-topbar .navbar-toggler { border-color: var(--border); }
.app-topbar .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(0,51,102,0.85)' stroke-linecap='round' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}
.app-sidebar {
  background: #fff;
  border-inline-end: 1px solid var(--border);
}
.sidebar-nav .nav-link {
  color: var(--text-muted);
  font-weight: 600;
  border-radius: 10px;
  padding: 10px 14px;
  margin: 2px 0;
}
.sidebar-nav .nav-link:hover {
  background: var(--bg-soft);
  color: var(--primary);
}
.sidebar-nav .nav-link.active {
  background: rgba(0, 51, 102, 0.08);
  color: var(--primary);
}

/* ===========================
 * Language switcher pill
 * =========================== */
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  font-size: 13px;
  font-weight: 700;
}
.lang-switch button,
.lang-switch a {
  padding: 6px 14px;
  border-radius: 999px;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
}
.lang-switch button.is-active,
.lang-switch a.is-active {
  background: var(--primary);
  color: #fff;
}

/* ===========================
 * RTL-specific overrides
 * Mostly: where logical properties don't get us all the way, flip key
 * margin/padding helpers and a few directional icons.
 * =========================== */
[dir="rtl"] .erp-logo-mark { box-shadow: -6px 6px 16px rgba(0, 51, 102, 0.25); }
[dir="rtl"] .auth-form-side { font-feature-settings: "kern" 1; }
[dir="rtl"] .badge { letter-spacing: 0; }
