/* css/main.css — Shared design tokens, base styles, utilities */

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800&family=Inter:wght@400;500;600;700&display=swap');

/* ── DESIGN TOKENS ─────────────────────────────────────── */
:root {
  /* Brand */
  --primary:        #1a3a6b;
  --primary-light:  #2a52a0;
  --primary-dark:   #0f2347;
  --accent:         #e8b84b;
  --accent-dark:    #c99a30;

  /* Semantic */
  --success:        #1a7a4a;
  --success-light:  #f0fff6;
  --danger:         #c0392b;
  --danger-light:   #fff5f5;
  --warning:        #e67e22;
  --warning-light:  #fff8f0;
  --info:           #2980b9;

  /* Neutrals */
  --bg:             #f4f6f8;
  --card:           #ffffff;
  --border:         #dde3f0;
  --text:           #1a1a2e;
  --text-muted:     #5a6a8a;
  --sidebar-bg:     #0f2347;
  --sidebar-text:   #a8b8d8;
  --sidebar-active: #e8b84b;

  /* Chart colors */
  --chart-1: #1a3a6b;
  --chart-2: #e8b84b;
  --chart-3: #1a7a4a;
  --chart-4: #c0392b;
  --chart-5: #2980b9;
  --chart-6: #8e44ad;

  /* Spacing */
  --radius:   10px;
  --radius-lg: 16px;
  --shadow:   0 2px 12px rgba(26,58,107,0.08);
  --shadow-md:0 4px 24px rgba(26,58,107,0.12);
  --shadow-lg:0 8px 40px rgba(26,58,107,0.18);

  /* Transitions */
  --t: 0.2s ease;
  --t-slow: 0.4s ease;
}

/* ── RESET & BASE ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Tajawal', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

body.ltr,
body.ltr * { direction: ltr; }

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── TYPOGRAPHY ─────────────────────────────────────────── */
h1, h2, h3, h4, h5 { line-height: 1.3; font-weight: 700; }
.en { font-family: 'Inter', sans-serif; }

/* ── CARD ───────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 1.5rem;
}

/* ── BUTTONS ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.55em 1.2em;
  border-radius: var(--radius);
  border: none;
  font-size: 0.92rem;
  font-weight: 600;
  font-family: 'Tajawal', sans-serif;
  transition: background var(--t), transform var(--t), box-shadow var(--t);
  position: relative;
  overflow: hidden;
}

.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); box-shadow: var(--shadow); }

.btn-accent { background: var(--accent); color: var(--primary-dark); }
.btn-accent:hover { background: var(--accent-dark); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #156040; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a93226; }

.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-ghost:hover { background: var(--primary); color: #fff; }

.btn-sm { padding: 0.35em 0.8em; font-size: 0.82rem; }
.btn-lg { padding: 0.75em 1.8em; font-size: 1rem; }

/* Ripple effect */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.18);
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.3s;
}
.btn:active::after { opacity: 1; }

/* ── BADGE ──────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.2em 0.65em;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger  { background: var(--danger-light);  color: var(--danger);  }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-info    { background: #e8f4fd;              color: var(--info);    }
.badge-muted   { background: #eef0f5;              color: var(--text-muted); }

/* ── TABLE ──────────────────────────────────────────────── */
.table-wrap {
  overflow: auto;
  max-height: 62vh;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  background: var(--primary);
  color: #fff;
  padding: 0.75rem 1rem;
  text-align: center;
  font-weight: 600;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: inset 0 -1px 0 var(--primary);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--t);
}
tbody tr:hover { background: #f0f4ff; }

tbody td {
  padding: 0.7rem 1rem;
  text-align: center;
  vertical-align: middle;
}

/* ── FORM ELEMENTS ──────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }

.form-group label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  padding: 0.6rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--card);
  transition: border-color var(--t), box-shadow var(--t);
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,58,107,0.1);
}

/* ── MODAL ──────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,35,71,0.55);
  backdrop-filter: blur(3px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-slow);
}
.modal-backdrop.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  width: min(900px, 96vw);
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.9);
  transition: transform var(--t-slow);
}
.modal-backdrop.open .modal { transform: scale(1); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

/* ── TOAST ──────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 1.2rem;
  right: 1.2rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 0.75rem 1.2rem;
  min-width: 260px;
  border-right: 4px solid var(--primary);
  animation: toastIn 0.35s cubic-bezier(0.34,1.56,0.64,1);
  font-size: 0.9rem;
}
.toast.success { border-color: var(--success); }
.toast.error   { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }

@keyframes toastIn {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes toastOut {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(110%); opacity: 0; }
}
.toast.removing { animation: toastOut 0.3s ease forwards; }

/* ── SKELETON ───────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #e8ecf4 25%, #f4f6f8 50%, #e8ecf4 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
  height: 1em;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── PROGRESS BAR ───────────────────────────────────────── */
.progress-bar-wrap {
  background: var(--border);
  border-radius: 20px;
  height: 8px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 20px;
  transition: width 0.3s ease;
}

/* ── DRAG DROP ZONE ─────────────────────────────────────── */
.drop-zone {
  border: 2.5px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--t);
  color: var(--text-muted);
}
.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--primary);
  background: #f0f4ff;
  color: var(--primary);
}
.drop-zone input[type="file"] { display: none; }

/* ── FILTER BAR ─────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

/* ── KPI CARD ───────────────────────────────────────────── */
.kpi-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.4rem 1.6rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.kpi-icon {
  width: 54px; height: 54px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.kpi-info .kpi-label { font-size: 0.82rem; color: var(--text-muted); font-weight: 500; }
.kpi-info .kpi-value { font-size: 1.8rem; font-weight: 800; color: var(--text); line-height: 1.2; }

/* ── COUNT-UP ───────────────────────────────────────────── */
.count-up { display: inline-block; }

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .card { padding: 1rem; }
  .modal { padding: 1.2rem; }
  .kpi-card { padding: 1rem; }
  .kpi-value { font-size: 1.4rem !important; }
}

/* ── SCROLLBAR ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── UTILITY ────────────────────────────────────────────── */
.text-center   { text-align: center; }
.text-muted    { color: var(--text-muted); }
.text-success  { color: var(--success); }
.text-danger   { color: var(--danger); }
.text-warning  { color: var(--warning); }
.hidden        { display: none !important; }
.flex          { display: flex; }
.items-center  { align-items: center; }
.gap-1         { gap: 0.5rem; }
.gap-2         { gap: 1rem; }
.mt-1          { margin-top: 0.5rem; }
.mt-2          { margin-top: 1rem; }
.mt-3          { margin-top: 1.5rem; }
.mb-2          { margin-bottom: 1rem; }
.mb-3          { margin-bottom: 1.5rem; }
.w-full        { width: 100%; }
.grid          { display: grid; }
.grid-2        { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-3        { grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4        { grid-template-columns: repeat(4, 1fr); gap: 1rem; }

@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}
