/* ════════════════════════════════════════════════════════════
   OTTIMA — components.css
   مكوّنات مشتركة: أزرار، نماذج، جداول، نوافذ منبثقة، تنبيهات
   جزء من main.css الأصلي، اتقسّم لملفات أصغر للصيانة الأسهل.
   ════════════════════════════════════════════════════════════ */

/* ══════════ STAT CARDS ══════════ */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px,1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden; transition: transform .15s, box-shadow .15s;
  animation: statIn .45s cubic-bezier(.22,1,.36,1) both;
}
@keyframes statIn { from { opacity:0; transform: translateY(12px) scale(.97); } to { opacity:1; transform:none; } }
.stats-grid .stat-card:nth-child(1) { animation-delay: .02s; }
.stats-grid .stat-card:nth-child(2) { animation-delay: .07s; }
.stats-grid .stat-card:nth-child(3) { animation-delay: .12s; }
.stats-grid .stat-card:nth-child(4) { animation-delay: .17s; }
.stats-grid .stat-card:nth-child(5) { animation-delay: .22s; }
.stats-grid .stat-card:nth-child(6) { animation-delay: .27s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .bar { position: absolute; bottom: 0; inset-inline: 0; height: 3px; background: var(--gold); }
.stat-card.gold .bar { background: var(--gold); }
.stat-card.success .bar { background: var(--success); }
.stat-card.warning .bar { background: var(--warning); }
.stat-card.danger .bar { background: var(--danger); }
.stat-card.info .bar { background: var(--info); }
.stat-label { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.stat-value { font-size: 26px; font-weight: 800; margin-top: 6px; line-height: 1; }
.stat-value.gold { color: var(--gold); }
.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }
.stat-value.danger { color: var(--danger); }
.stat-value.info { color: var(--info); }
.stat-sub { font-size: 11px; color: var(--muted); margin-top: 5px; }
.stat-row { display:flex; justify-content: space-between; align-items: flex-start; }

/* ══════════ BUTTONS ══════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--rs); font-size: 13.5px; font-weight: 600;
  border: 1px solid transparent; transition: .15s; white-space: nowrap;
  background: var(--hover); color: var(--text); border-color: var(--border);
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-sm svg { width: 14px; height: 14px; }
.btn:hover { border-color: var(--muted); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn-primary { background: var(--gold); color: #1C1A17; border-color: var(--gold); }
.btn-primary:hover { background: var(--gold-l); }
.btn-outline { background: transparent; color: var(--gold); border-color: var(--gold-b); }
.btn-outline:hover { background: var(--gold-s); border-color: var(--gold); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-success { background: var(--success-bg); color: var(--success); border-color: var(--success); }
.btn-success:hover { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning); }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ══════════ FORMS ══════════ */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--sub); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border);
  border-radius: var(--rs); background: var(--input); color: var(--text);
  font-size: 14px; outline: none; transition: .15s;
}
.form-control:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,168,76,.12); }
.form-control::placeholder { color: var(--muted); }
textarea.form-control { resize: vertical; min-height: 80px; font-family: inherit; }
select.form-control { cursor: pointer; }
.form-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ══════════ BADGES ══════════ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 700;
}
.badge-gold { background: var(--gold-s); color: var(--gold-d); border: 1px solid var(--gold-b); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: var(--hover); color: var(--muted); border: 1px solid var(--border); }

/* ══════════ TABLE ══════════ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  padding: 10px 14px; text-align: right; font-size: 11.5px; font-weight: 700;
  color: var(--muted); background: var(--hover); border-bottom: 2px solid var(--border); white-space: nowrap;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .15s; animation: rowIn .35s cubic-bezier(.22,1,.36,1) both; }
@keyframes rowIn { from { opacity:0; transform: translateX(6px); } to { opacity:1; transform:none; } }
tbody tr:nth-child(1) { animation-delay: .01s; } tbody tr:nth-child(2) { animation-delay: .04s; }
tbody tr:nth-child(3) { animation-delay: .07s; } tbody tr:nth-child(4) { animation-delay: .10s; }
tbody tr:nth-child(5) { animation-delay: .13s; } tbody tr:nth-child(6) { animation-delay: .16s; }
tbody tr:nth-child(7) { animation-delay: .19s; } tbody tr:nth-child(8) { animation-delay: .22s; }
tbody tr:nth-child(n+9) { animation: none; }
tbody tr:hover { background: var(--hover); }

/* ══════════ MODAL ══════════ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-backdrop.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--card); border-radius: var(--rl); width: 100%; max-width: 540px;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); border: 1px solid var(--border);
  transform: translateY(20px) scale(.98); transition: transform .2s;
}
.modal-backdrop.open .modal { transform: none; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 15px; font-weight: 700; }
.modal-close { width: 30px; height: 30px; border-radius: 50%; border: none; background: var(--hover); font-size: 16px; color: var(--sub); display: flex; align-items: center; justify-content: center; }
.modal-close svg { width: 16px; height: 16px; flex-shrink: 0; }
.modal-close:hover { background: var(--danger-bg); color: var(--danger); }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ══════════ TOAST ══════════ */
#toast-container { position: fixed; bottom: calc(24px + env(safe-area-inset-bottom)); left: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r);
  padding: 12px 16px; box-shadow: var(--shadow-md); font-size: 13.5px;
  display: flex; align-items: center; gap: 10px; min-width: 260px;
  animation: toastIn .25s ease;
}
.toast-success { border-right: 3px solid var(--success); }
.toast-danger { border-right: 3px solid var(--danger); }
.toast-warning { border-right: 3px solid var(--warning); }
.toast-info { border-right: 3px solid var(--gold); }
@keyframes toastIn { from { opacity:0; transform: translateY(12px); } to { opacity:1; transform:none; } }

/* ══════════ PROGRESS ══════════ */
.progress { height: 6px; background: var(--hover); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--gold-d), var(--gold-l)); border-radius: 3px; transition: width .4s; }
.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger { background: var(--danger); }

/* ══════════ EMPTY STATE ══════════ */
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-icon { font-size: 44px; margin-bottom: 12px; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--sub); }

/* ══════════ SKELETON ══════════ */
.skeleton { background: var(--hover); border-radius: 4px; position: relative; overflow: hidden; }
.skeleton::after { content:''; position:absolute; inset:0; background: linear-gradient(90deg,transparent,rgba(201,168,76,.1),transparent); background-size:200%; animation: sksh 1.6s ease infinite; }
@keyframes sksh { 0% { background-position:-200%; } 100% { background-position:200%; } }

/* ══════════ SPINNER ══════════ */
.spinner { width: 32px; height: 32px; border: 3px solid var(--gold-s); border-top-color: var(--gold); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-screen { position: fixed; inset:0; background: var(--bg); display:flex; flex-direction:column; align-items:center; justify-content:center; gap:14px; z-index: 999; }

