/* ==========================================================================
   RAF Enterprise Management System — Design System
   Brand: Taupe Bronze #8F7961 · Gold #A68C6D · Charcoal #1E1E1E
   RTL, Arabic-first, Enterprise, Modern
   ========================================================================== */

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

:root {
  /* Brand */
  --brand-bronze: #8F7961;
  --brand-bronze-600: #7a6552;
  --brand-bronze-700: #614f40;
  --brand-gold: #A68C6D;
  --brand-gold-light: #C4AB89;

  /* Neutrals */
  --neutral-900: #1E1E1E;
  --neutral-800: #252525;
  --neutral-700: #3a3a3a;
  --neutral-600: #6b7280;
  --neutral-400: #a3a3a3;
  --neutral-300: #d4d4d4;
  --neutral-200: #e7e5e0;
  --neutral-100: #F0EDE6;
  --off-white: #F8F6F2;
  --pure-white: #FFFFFF;

  /* Status */
  --status-active: #10B981;
  --status-leave:  #F59E0B;
  --status-suspended: #EF4444;
  --status-terminated: #6B7280;

  /* Typography */
  --font-sans: 'IBM Plex Sans Arabic', system-ui, -apple-system, sans-serif;
  --fs-xs: .75rem;
  --fs-sm: .875rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.25rem;
  --fs-2xl: 1.5rem;
  --fs-3xl: 1.875rem;

  /* Layout */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(30,30,30,.05);
  --shadow: 0 4px 12px rgba(30,30,30,.06), 0 1px 3px rgba(30,30,30,.04);
  --shadow-lg: 0 12px 28px rgba(30,30,30,.10);

  --sidebar-w: 260px;
  --topbar-h: 68px;
  --transition: 180ms cubic-bezier(.4,0,.2,1);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--off-white);
  color: var(--neutral-900);
  direction: rtl;
  font-size: var(--fs-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; background: none; color: inherit; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--brand-gold); color: white; }

/* Custom scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--neutral-200); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--brand-bronze); }

/* =========================================================================
   Login Screen
   ========================================================================= */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--off-white);
}
.login-brand {
  background:
    radial-gradient(circle at 30% 20%, rgba(166,140,109,.15), transparent 60%),
    linear-gradient(135deg, #1E1E1E 0%, #2a241f 100%);
  color: var(--off-white);
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 48px;
  position: relative;
  overflow: hidden;
}
.login-brand::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(45deg, rgba(255,255,255,.02) 0 1px, transparent 1px 32px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,.02) 0 1px, transparent 1px 32px);
  pointer-events: none;
}
.login-logo { position: relative; z-index: 1; }
.login-logo .mark {
  width: 68px; height: 68px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--brand-gold) 0%, var(--brand-bronze) 100%);
  box-shadow: 0 10px 30px rgba(166,140,109,.4);
  font-size: 32px; color: white;
  font-weight: 700;
}
.login-hero { position: relative; z-index: 1; }
.login-hero h1 {
  font-size: clamp(2rem, 4vw, 3.5rem); line-height: 1.15; margin: 0 0 16px;
  background: linear-gradient(135deg, #fff 0%, #d4c9b8 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  font-weight: 700;
}
.login-hero p { color: rgba(255,255,255,.7); font-size: var(--fs-lg); max-width: 480px; }
.login-footer { position: relative; z-index: 1; color: rgba(255,255,255,.4); font-size: var(--fs-sm); }

.login-form-wrap { display: flex; align-items: center; justify-content: center; padding: 32px; }
.login-form { width: 100%; max-width: 420px; }
.login-form h2 { font-size: var(--fs-2xl); font-weight: 600; margin: 0 0 8px; }
.login-form .sub { color: var(--neutral-600); margin-bottom: 32px; }

.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 500; font-size: var(--fs-sm); margin-bottom: 8px; color: var(--neutral-700); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--neutral-200);
  border-radius: var(--radius);
  background: white;
  transition: border-color var(--transition), box-shadow var(--transition);
  color: var(--neutral-900);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--brand-bronze);
  box-shadow: 0 0 0 4px rgba(143,121,97,.12);
}
.field .hint { font-size: var(--fs-xs); color: var(--neutral-600); margin-top: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: var(--radius);
  font-weight: 500; font-size: var(--fs-sm);
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--brand-bronze) 0%, var(--brand-bronze-600) 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(143,121,97,.28);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(143,121,97,.35); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary { background: white; color: var(--neutral-900); border: 1.5px solid var(--neutral-200); }
.btn-secondary:hover { border-color: var(--brand-bronze); color: var(--brand-bronze); }
.btn-ghost { background: transparent; color: var(--neutral-600); }
.btn-ghost:hover { background: var(--neutral-100); color: var(--neutral-900); }
.btn-danger { background: #EF4444; color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: var(--fs-xs); }
.btn-lg { padding: 14px 24px; font-size: var(--fs-base); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* =========================================================================
   App Shell (Sidebar + Topbar + Content)
   ========================================================================= */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-w) 1fr; }

.sidebar {
  background: var(--neutral-900);
  color: rgba(255,255,255,.85);
  padding: 24px 0;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px 24px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  margin-bottom: 16px;
}
.sidebar .brand .mark {
  width: 42px; height: 42px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-gold), var(--brand-bronze));
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 20px;
}
.sidebar .brand .brand-text .title { font-weight: 600; font-size: var(--fs-lg); color: white; }
.sidebar .brand .brand-text .subtitle { font-size: var(--fs-xs); color: rgba(255,255,255,.5); }

.sidebar nav { padding: 0 12px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius);
  color: rgba(255,255,255,.65);
  margin-bottom: 4px;
  transition: all var(--transition);
  font-size: var(--fs-sm); font-weight: 500;
  cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: white; }
.nav-item.active {
  background: linear-gradient(135deg, var(--brand-bronze) 0%, var(--brand-bronze-600) 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(143,121,97,.25);
}
.nav-item i { width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px 24px; border-top: 1px solid rgba(255,255,255,.06);
  font-size: var(--fs-xs); color: rgba(255,255,255,.4);
}

.topbar {
  height: var(--topbar-h); background: white;
  border-bottom: 1px solid var(--neutral-200);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px;
  position: sticky; top: 0; z-index: 10;
}
.topbar .page-title { font-size: var(--fs-xl); font-weight: 600; color: var(--neutral-900); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px 6px 6px;
  background: var(--off-white); border-radius: 999px;
  cursor: pointer;
}
.user-chip .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-gold), var(--brand-bronze));
  color: white; display: flex; align-items: center; justify-content: center;
  font-weight: 600;
}
.user-chip .info .name { font-size: var(--fs-sm); font-weight: 500; }
.user-chip .info .role { font-size: var(--fs-xs); color: var(--neutral-600); }

.content { padding: 28px 32px; }

/* =========================================================================
   Common: Page header, KPI cards, tables, badges, modals
   ========================================================================= */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.page-header h1 { margin: 0; font-size: var(--fs-2xl); font-weight: 600; }
.page-header p { margin: 4px 0 0; color: var(--neutral-600); font-size: var(--fs-sm); }

.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.kpi-card {
  background: white; padding: 22px; border-radius: var(--radius-lg);
  border: 1px solid var(--neutral-200);
  transition: transform var(--transition), box-shadow var(--transition);
  position: relative; overflow: hidden;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi-card::before {
  content: ''; position: absolute; top: 0; right: 0; height: 3px; width: 60%;
  background: linear-gradient(90deg, var(--brand-gold), var(--brand-bronze));
  border-radius: 2px;
}
.kpi-card .label { font-size: var(--fs-sm); color: var(--neutral-600); margin-bottom: 8px; }
.kpi-card .value { font-size: var(--fs-3xl); font-weight: 700; color: var(--neutral-900); }
.kpi-card .icon {
  position: absolute; bottom: 12px; left: 12px;
  width: 40px; height: 40px; border-radius: 10px;
  background: rgba(143,121,97,.1); color: var(--brand-bronze);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.kpi-card.accent-green::before { background: linear-gradient(90deg, #34d399, var(--status-active)); }
.kpi-card.accent-amber::before { background: linear-gradient(90deg, #fbbf24, var(--status-leave)); }
.kpi-card.accent-red::before   { background: linear-gradient(90deg, #f87171, var(--status-suspended)); }

.card {
  background: white; border-radius: var(--radius-lg);
  border: 1px solid var(--neutral-200); padding: 22px;
  margin-bottom: 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-header h3 { margin: 0; font-size: var(--fs-lg); font-weight: 600; }

.toolbar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  margin-bottom: 16px;
}
.toolbar .search {
  flex: 1; min-width: 220px;
  padding: 10px 14px; border: 1.5px solid var(--neutral-200);
  border-radius: var(--radius); background: white;
}
.toolbar .search:focus { outline: none; border-color: var(--brand-bronze); }
.toolbar select { padding: 10px 14px; border: 1.5px solid var(--neutral-200); border-radius: var(--radius); background: white; }

.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--neutral-200); background: white; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.data thead th {
  text-align: right; padding: 12px 14px;
  background: var(--off-white); border-bottom: 1px solid var(--neutral-200);
  font-weight: 600; color: var(--neutral-700); white-space: nowrap;
}
table.data tbody td { padding: 12px 14px; border-bottom: 1px solid var(--neutral-100); }
table.data tbody tr:hover { background: var(--off-white); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data .row-actions { display: flex; gap: 6px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 500;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-active     { background: rgba(16,185,129,.12); color: #059669; }
.badge-on_leave   { background: rgba(245,158,11,.12); color: #b45309; }
.badge-suspended  { background: rgba(239,68,68,.12);  color: #b91c1c; }
.badge-terminated { background: rgba(107,114,128,.14); color: #4b5563; }

.badge-pending    { background: rgba(107,114,128,.14); color: #4b5563; }
.badge-in_progress{ background: rgba(59,130,246,.12); color: #1d4ed8; }
.badge-completed  { background: rgba(16,185,129,.12); color: #059669; }
.badge-approved   { background: rgba(16,185,129,.12); color: #059669; }
.badge-rejected   { background: rgba(239,68,68,.12);  color: #b91c1c; }
.badge-returned   { background: rgba(245,158,11,.12); color: #b45309; }

.priority-low     { color: var(--neutral-600); }
.priority-medium  { color: #3b82f6; }
.priority-high    { color: #f59e0b; }
.priority-urgent  { color: #ef4444; font-weight: 700; }

.days-badge {
  display: inline-block; padding: 3px 8px; border-radius: 6px;
  font-size: var(--fs-xs); font-weight: 500;
}
.days-ok { background: rgba(16,185,129,.1); color: #059669; }
.days-warn { background: rgba(245,158,11,.14); color: #b45309; }
.days-danger { background: rgba(239,68,68,.14); color: #b91c1c; }
.days-expired { background: var(--neutral-900); color: white; }

/* =========================================================================
   Modal / Drawer
   ========================================================================= */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(30,30,30,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; backdrop-filter: blur(4px);
  animation: fadeIn .18s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal {
  background: white; border-radius: var(--radius-lg);
  width: min(720px, 96vw); max-height: 92vh;
  overflow-y: auto;
  animation: slideUp .22s ease-out;
  box-shadow: var(--shadow-lg);
}
.modal.modal-lg { width: min(960px, 96vw); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--neutral-100);
}
.modal-header h3 { margin: 0; font-size: var(--fs-xl); font-weight: 600; }
.modal-close { color: var(--neutral-600); font-size: 20px; }
.modal-close:hover { color: var(--neutral-900); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--neutral-100);
  display: flex; gap: 10px; justify-content: flex-start;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

.tabs { display: flex; border-bottom: 1px solid var(--neutral-200); margin-bottom: 20px; gap: 4px; }
.tab {
  padding: 10px 16px; font-size: var(--fs-sm); font-weight: 500; color: var(--neutral-600);
  border-bottom: 2px solid transparent; cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}
.tab:hover { color: var(--brand-bronze); }
.tab.active { color: var(--brand-bronze); border-bottom-color: var(--brand-bronze); }

/* Toasts */
.toast-stack { position: fixed; top: 24px; left: 24px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; }
.toast {
  padding: 12px 18px; background: white;
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  border-right: 4px solid var(--brand-bronze);
  min-width: 260px; animation: slideUp .2s ease-out;
  font-size: var(--fs-sm);
}
.toast.success { border-right-color: var(--status-active); }
.toast.error   { border-right-color: var(--status-suspended); }
.toast.info    { border-right-color: #3b82f6; }

/* Workflow visualization */
.workflow {
  display: flex; align-items: stretch; gap: 12px; flex-wrap: wrap;
  padding: 8px 0;
}
.workflow-step {
  flex: 1; min-width: 180px;
  padding: 14px; border-radius: var(--radius);
  background: var(--off-white); border: 1.5px solid var(--neutral-200);
  position: relative;
}
.workflow-step.active { border-color: var(--brand-bronze); background: rgba(143,121,97,.06); }
.workflow-step.completed { border-color: var(--status-active); background: rgba(16,185,129,.06); }
.workflow-step.rejected { border-color: var(--status-suspended); }
.workflow-step .step-num {
  position: absolute; top: -10px; right: -10px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand-bronze); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-xs); font-weight: 700;
}
.workflow-step.completed .step-num { background: var(--status-active); }
.workflow-step.rejected .step-num { background: var(--status-suspended); }
.workflow-step .assignee { font-weight: 600; }
.workflow-step .action { font-size: var(--fs-xs); color: var(--neutral-600); margin-top: 2px; }

/* Permission matrix */
.perm-table { width: 100%; }
.perm-level {
  display: inline-flex; padding: 4px 12px; border-radius: 6px; font-size: var(--fs-xs);
  cursor: pointer; margin: 2px; border: 1.5px solid transparent;
  transition: all var(--transition); user-select: none;
}
.perm-level.selected { background: var(--brand-bronze); color: white; border-color: var(--brand-bronze); }
.perm-level:not(.selected):hover { border-color: var(--brand-bronze); }

/* Empty state */
.empty {
  text-align: center; padding: 60px 20px; color: var(--neutral-600);
}
.empty .icon { font-size: 48px; color: var(--neutral-300); margin-bottom: 12px; }
.empty h4 { margin: 0 0 6px; color: var(--neutral-700); font-weight: 500; }

/* Skeleton loader */
.skeleton { background: linear-gradient(90deg, var(--neutral-100) 25%, var(--neutral-200) 50%, var(--neutral-100) 75%);
            background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Responsive */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 0; right: 0; width: 260px; z-index: 20; transform: translateX(100%); transition: transform .24s ease; }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 20px 16px; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
}

.sidebar-toggle { display: none; }
@media (max-width: 900px) { .sidebar-toggle { display: inline-flex; } }

/* Utility */
.hidden { display: none !important; }
.text-muted { color: var(--neutral-600); }
.text-danger { color: var(--status-suspended); }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* File upload zone */
.dropzone {
  border: 2px dashed var(--neutral-300); border-radius: var(--radius);
  padding: 32px 20px; text-align: center; cursor: pointer;
  transition: border-color var(--transition), background-color var(--transition);
  background: var(--off-white);
}
.dropzone:hover, .dropzone.dragover { border-color: var(--brand-bronze); background: rgba(143,121,97,.05); }
.dropzone i { font-size: 32px; color: var(--brand-bronze); margin-bottom: 8px; display: block; }

/* Simple bar for charts */
.chart-bar { display: flex; align-items: flex-end; gap: 8px; height: 180px; padding: 12px 0; }
.chart-bar-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.chart-bar-item .bar {
  width: 100%; background: linear-gradient(180deg, var(--brand-gold), var(--brand-bronze));
  border-radius: 6px 6px 0 0; min-height: 4px; transition: height .5s ease;
}
.chart-bar-item .lbl { font-size: var(--fs-xs); color: var(--neutral-600); text-align: center; }
.chart-bar-item .val { font-size: var(--fs-xs); font-weight: 600; }

/* Docs list */
.doc-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; background: var(--off-white); border-radius: var(--radius);
  margin-bottom: 8px;
}
.doc-item .doc-info { display: flex; align-items: center; gap: 10px; }
.doc-item .doc-icon { width: 36px; height: 36px; border-radius: 8px; background: rgba(143,121,97,.12); color: var(--brand-bronze);
  display: flex; align-items: center; justify-content: center; font-size: 16px; }

.expiry-item {
  padding: 12px 14px; border: 1px solid var(--neutral-200); border-radius: var(--radius);
  margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between;
}
.expiry-item .lbl { color: var(--neutral-700); font-size: var(--fs-sm); }
