/* ============================================================
   app.css — Shared styles for PWA
   وحدة تنفيذ الأحكام
============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800;900&display=swap');
@import url('https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@3.19.0/dist/tabler-icons.min.css');

/* ── Variables ── */
:root {
  --brand:        #1a56db;
  --brand-dark:   #1040a8;
  --brand-soft:   #dbeafe;
  --brand-glow:   rgba(26,86,219,.12);
  --green:        #059669;
  --green-soft:   #d1fae5;
  --red:          #dc2626;
  --red-soft:     #fee2e2;
  --amber:        #d97706;
  --amber-soft:   #fef3c7;
  --purple:       #7c3aed;
  --purple-soft:  #ede9fe;
  --white:        #ffffff;
  --surface:      #f8fafc;
  --surface-2:    #f1f5f9;
  --border:       #e2e8f0;
  --border-2:     #cbd5e1;
  --text:         #0f172a;
  --text-2:       #334155;
  --text-3:       #64748b;
  --text-4:       #94a3b8;
  --font:         'Cairo', sans-serif;
  --radius-sm:    8px;
  --radius-md:    12px;
  --radius-lg:    18px;
  --radius-xl:    24px;
  --shadow-sm:    0 1px 4px rgba(15,23,42,.06);
  --shadow-md:    0 4px 16px rgba(15,23,42,.08);
  --shadow-lg:    0 8px 32px rgba(15,23,42,.1);
  --ease:         cubic-bezier(.4,0,.2,1);
  --spring:       cubic-bezier(.34,1.56,.64,1);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  direction: rtl;
  background: var(--surface);
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
input, textarea, button, select { font-family: var(--font); }
button { cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ── Animations ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(32px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .5; }
}

/* ── Spinner ── */
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: none; flex-shrink: 0;
}
.spinner.dark {
  border-color: rgba(26,86,219,.2);
  border-top-color: var(--brand);
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 12px 24px;
  border-radius: var(--radius-xl);
  font-size: 14px; font-weight: 700;
  color: #fff; z-index: 9999;
  min-width: 220px; text-align: center;
  transition: transform .35s var(--spring);
  pointer-events: none; white-space: nowrap;
  box-shadow: var(--shadow-lg);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }
.toast.info    { background: var(--brand); }

/* ── Message Box ── */
.msg-box {
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 13px; font-weight: 600;
  display: none; align-items: center;
  gap: 9px; line-height: 1.4;
}
.msg-box.show    { display: flex; }
.msg-box.error   { background: var(--red-soft);   color: var(--red);   border: 1.5px solid #fecaca; }
.msg-box.loading { background: var(--brand-soft);  color: var(--brand); border: 1.5px solid #bfdbfe; }
.msg-box.success { background: var(--green-soft);  color: var(--green); border: 1.5px solid #bbf7d0; }
.msg-box i { font-size: 16px; flex-shrink: 0; }

/* ── Buttons ── */
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 54px; width: 100%;
  background: var(--brand); color: #fff; border: none;
  border-radius: var(--radius-lg);
  font-family: var(--font); font-size: 16px; font-weight: 800;
  cursor: pointer;
  transition: background .15s, transform .12s, box-shadow .15s;
}
.btn-primary:hover:not(:disabled) {
  background: var(--brand-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(26,86,219,.3);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); box-shadow: none; }
.btn-primary:disabled { background: var(--text-4); cursor: not-allowed; transform: none; }
.btn-primary i { font-size: 18px; }

.btn-secondary {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 16px;
  background: rgba(255,255,255,.15);
  color: #fff; border: 1px solid rgba(255,255,255,.25);
  border-radius: var(--radius-md);
  font-family: var(--font); font-size: 13px; font-weight: 700;
  cursor: pointer; transition: background .15s;
}
.btn-secondary:hover { background: rgba(255,255,255,.25); }
.btn-secondary i { font-size: 15px; }

/* ── Input ── */
.input-group { display: flex; flex-direction: column; gap: 7px; }
.input-label {
  font-size: 13px; font-weight: 700; color: var(--text-2);
  display: flex; align-items: center; gap: 6px;
}
.input-label i { font-size: 15px; color: var(--brand); }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap input,
.input-wrap textarea {
  width: 100%; height: 52px;
  padding: 0 48px 0 48px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 15px; font-weight: 500;
  color: var(--text);
  background: var(--white);
  outline: none; direction: rtl; text-align: right;
  -webkit-appearance: none;
  transition: border-color .18s, box-shadow .18s;
}
.input-wrap input::placeholder { color: var(--text-4); font-weight: 400; }
.input-wrap input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
}
.input-wrap input.has-error { border-color: var(--red); }
.input-icon {
  position: absolute; right: 14px;
  font-size: 19px; color: var(--text-4);
  pointer-events: none; transition: color .18s;
}
.input-wrap:focus-within .input-icon { color: var(--brand); }
.input-action {
  position: absolute; left: 10px;
  background: none; border: none; cursor: pointer;
  padding: 7px; color: var(--text-4); font-size: 19px;
  display: flex; align-items: center; border-radius: 8px;
  transition: color .15s;
}
.input-action:hover { color: var(--brand); }

/* ── Cards ── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.card-head {
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.card-head i { font-size: 17px; color: var(--brand); }
.card-title { font-size: 12px; font-weight: 800; color: var(--brand); text-transform: uppercase; letter-spacing: .06em; }

/* ── Status Badges ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 99px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.badge-none   { background: var(--surface-2); color: var(--text-3); }
.badge-sadad  { background: var(--green-soft); color: #065f46; }
.badge-hrab   { background: var(--red-soft);   color: #991b1b; }
.badge-wa3d   { background: var(--amber-soft); color: #92400e; }
.badge-tajil  { background: var(--purple-soft);color: #5b21b6; }
.badge-brand  { background: var(--brand-soft); color: #1e40af; }

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

/* ── KPI Cards ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.kpi-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 8px;
  text-align: center;
  position: relative; overflow: hidden;
}
.kpi-card::before {
  content: ''; position: absolute;
  top: 0; right: 0; left: 0; height: 3px;
  background: var(--brand);
}
.kpi-card.green::before { background: var(--green); }
.kpi-card.red::before   { background: var(--red); }
.kpi-card.amber::before { background: var(--amber); }
.kpi-card.purple::before{ background: var(--purple); }
.kpi-num { font-size: 20px; font-weight: 900; color: var(--brand); line-height: 1; }
.kpi-card.green .kpi-num { color: var(--green); }
.kpi-card.red   .kpi-num { color: var(--red); }
.kpi-card.amber .kpi-num { color: var(--amber); }
.kpi-card.purple .kpi-num{ color: var(--purple); }
.kpi-label { font-size: 9.5px; color: var(--text-4); font-weight: 600; margin-top: 3px; line-height: 1.2; }

/* ── Responsive ── */
@media (max-width: 480px) {
  .kpi-num { font-size: 17px; }
  .kpi-label { font-size: 8.5px; }
}
@media (min-width: 768px) {
  .kpi-grid { gap: 12px; }
  .kpi-card { padding: 14px 12px; }
  .kpi-num  { font-size: 24px; }
  .kpi-label{ font-size: 11px; }
}
