/* ============================================================
   Safa Marwa UI — shared design system
   Palette: violet-600 #7c3aed · indigo-600 #4f46e5 ·
   emerald-600 #059669 · amber-500 #f59e0b · rose-600 #e11d48 ·
   sky-600 #0284c9 · slate neutrals · content bg slate-50
   ============================================================ */
:root {
  --sm-violet: #7c3aed;
  --sm-violet-dark: #6d28d9;
  --sm-violet-soft: #ede9fe;
  --sm-indigo: #4f46e5;
  --sm-emerald: #059669;
  --sm-amber: #f59e0b;
  --sm-rose: #e11d48;
  --sm-sky: #0284c9;
  --sm-ink: #0f172a;
  --sm-body: #f8fafc; /* slate-50 */
  --sm-border: #e2e8f0; /* slate-200 */
  --sm-muted: #64748b; /* slate-500 */
  --sm-radius: 0.75rem;
  --sm-shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.06);
  --sm-shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.10);
  --sm-shadow-lg: 0 12px 32px -8px rgba(15, 23, 42, 0.16);
  --sm-ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--sm-radius);
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1.25rem;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.15s var(--sm-ease), box-shadow 0.15s var(--sm-ease),
    background-color 0.15s var(--sm-ease), border-color 0.15s var(--sm-ease),
    color 0.15s var(--sm-ease);
  user-select: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--sm-violet); outline-offset: 2px; }
.btn:disabled, .btn.disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--sm-violet) 0%, var(--sm-indigo) 100%);
  color: #fff;
  box-shadow: 0 6px 16px -4px rgba(124, 58, 237, 0.45);
}
.btn-primary:hover { box-shadow: 0 10px 22px -4px rgba(124, 58, 237, 0.55); }

.btn-secondary {
  background: #fff;
  color: #334155;
  border-color: var(--sm-border);
  box-shadow: var(--sm-shadow-sm);
}
.btn-secondary:hover { border-color: #cbd5e1; background: #f8fafc; }

.btn-danger {
  background: var(--sm-rose);
  color: #fff;
  box-shadow: 0 6px 16px -4px rgba(225, 29, 72, 0.4);
}
.btn-danger:hover { background: #be123c; }

.btn-ghost {
  background: transparent;
  color: #475569;
  border-color: transparent;
}
.btn-ghost:hover { background: #f1f5f9; color: var(--sm-ink); }

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.75rem; border-radius: 0.625rem; }
.btn-icon { padding: 0.625rem; aspect-ratio: 1 / 1; border-radius: 0.625rem; }

/* ---------- Badges ----------
   Status mapping: pending→amber · approved/confirmed/completed→emerald ·
   paid→blue · partial→sky · cancelled/overdue→rose · refunded→purple ·
   draft→slate */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-amber  { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.badge-emerald{ background: #d1fae5; color: #047857; border-color: #a7f3d0; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }
.badge-sky    { background: #e0f2fe; color: #0369a1; border-color: #bae6fd; }
.badge-rose   { background: #ffe4e6; color: #be123c; border-color: #fecdd3; }
.badge-purple { background: var(--sm-violet-soft); color: var(--sm-violet-dark); border-color: #ddd6fe; }
.badge-slate  { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }

/* ---------- Cards ---------- */
.card {
  background: #fff;
  border: 1px solid var(--sm-border);
  border-radius: 1rem;
  box-shadow: var(--sm-shadow-sm);
  transition: box-shadow 0.2s var(--sm-ease), transform 0.2s var(--sm-ease);
}
.card-hover:hover { transform: translateY(-3px); box-shadow: var(--sm-shadow-lg); }
.card-pad { padding: 1.25rem; }

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  border-radius: 1rem;
  border: 1px solid var(--sm-border);
  background: #fff;
  box-shadow: var(--sm-shadow-sm);
}
table.ui-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
table.ui-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: #f8fafc;
  color: #475569;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--sm-border);
  white-space: nowrap;
}
table.ui-table tbody td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  vertical-align: middle;
}
table.ui-table tbody tr:last-child td { border-bottom: none; }
table.ui-table tbody tr { transition: background-color 0.12s var(--sm-ease); }
table.ui-table tbody tr:hover { background: #f8fafc; }

/* ---------- Forms ---------- */
.label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.375rem;
}
.input, .select, textarea.input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid #cbd5e1;
  border-radius: var(--sm-radius);
  background: #fff;
  color: var(--sm-ink);
  font-size: 0.875rem;
  transition: border-color 0.15s var(--sm-ease), box-shadow 0.15s var(--sm-ease);
}
.input::placeholder { color: #94a3b8; }
.input:focus, .select:focus, textarea.input:focus {
  outline: none;
  border-color: var(--sm-violet);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}
.input-error {
  border-color: var(--sm-rose) !important;
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.12) !important;
}
.form-hint { font-size: 0.75rem; color: var(--sm-muted); margin-top: 0.25rem; }
.form-error { font-size: 0.75rem; color: var(--sm-rose); font-weight: 600; margin-top: 0.25rem; }

/* ---------- Page head ---------- */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 1.25rem;
}
.page-head h1, .page-head .page-title {
  font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; color: var(--sm-ink);
}
.page-head .page-sub { font-size: 0.875rem; color: var(--sm-muted); margin-top: 0.125rem; }
.page-head .page-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ---------- Stat cards ---------- */
.stat-card {
  background: #fff;
  border: 1px solid var(--sm-border);
  border-radius: 1rem;
  padding: 1.25rem;
  box-shadow: var(--sm-shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s var(--sm-ease), box-shadow 0.2s var(--sm-ease);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--sm-shadow-md); }
.stat-card .stat-icon {
  width: 2.75rem; height: 2.75rem; border-radius: 0.875rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; margin-bottom: 0.75rem;
}
.stat-card .stat-value { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; color: var(--sm-ink); }
.stat-card .stat-label { font-size: 0.78rem; font-weight: 600; color: var(--sm-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  background: #fff;
  border: 1px dashed #cbd5e1;
  border-radius: 1rem;
  color: var(--sm-muted);
}
.empty-state .empty-icon {
  width: 4rem; height: 4rem; border-radius: 1.25rem;
  background: #f1f5f9; color: #94a3b8;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.75rem; margin-bottom: 1rem;
}
.empty-state h3 { font-size: 1.05rem; font-weight: 700; color: #334155; margin-bottom: 0.25rem; }
.empty-state p { font-size: 0.875rem; }
/* Standalone empty-state icon (same look as .empty-state .empty-icon, usable outside .empty-state) */
.empty-state-icon {
  width: 4rem; height: 4rem; border-radius: 1.25rem;
  background: #f1f5f9; color: #94a3b8;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.75rem; margin-bottom: 1rem;
}
/* Pagination wrapper: centers Laravel pagination, scrolls on small screens */
.sm-pagination { display: flex; justify-content: center; align-items: center; }
.sm-pagination nav { display: flex; max-width: 100%; overflow-x: auto; }
.sm-pagination ul.pagination { display: flex; gap: 0.25rem; align-items: center; }

/* ---------- Skeleton shimmer ---------- */
.skeleton {
  position: relative;
  overflow: hidden;
  background: #e2e8f0;
  border-radius: 0.5rem;
  min-height: 1rem;
}
.skeleton::after {
  content: "";
  position: absolute; inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.7), transparent);
  animation: sm-shimmer 1.6s infinite;
}

/* ---------- Modal helpers ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-panel {
  background: #fff;
  border-radius: 1.25rem;
  box-shadow: 0 25px 60px -12px rgba(15, 23, 42, 0.35);
  width: 100%; max-width: 36rem;
  max-height: 90vh; overflow-y: auto;
  animation: sm-scale-in 0.22s var(--sm-ease);
}

/* ---------- SweetAlert2 theme (used by global wrapper) ---------- */
.swal-popup {
  border-radius: 1.25rem !important;
  border: 1px solid var(--sm-border) !important;
  box-shadow: 0 25px 60px -12px rgba(15, 23, 42, 0.35) !important;
  font-family: 'Outfit', sans-serif !important;
}
.swal-title { font-weight: 800 !important; letter-spacing: -0.02em; color: var(--sm-ink) !important; }
.swal-body { color: var(--sm-muted) !important; font-weight: 500; }
.swal-toast {
  border-radius: 1rem !important;
  border: 1px solid var(--sm-border) !important;
  box-shadow: var(--sm-shadow-lg) !important;
  font-family: 'Outfit', sans-serif !important;
}
div:where(.swal2-container) .swal2-html-container.swal-toast-msg { margin: 0.25rem 0 0; font-size: 0.85rem; color: #475569; }

/* ---------- Toast stack (flash messages) ---------- */
.sm-toast-stack {
  position: fixed; top: 1rem; right: 1rem; z-index: 2000;
  display: flex; flex-direction: column; gap: 0.625rem;
  max-width: min(24rem, calc(100vw - 2rem));
}
.sm-toast {
  display: flex; align-items: flex-start; gap: 0.75rem;
  background: #fff; border: 1px solid var(--sm-border);
  border-left: 4px solid var(--sm-violet);
  border-radius: 0.875rem; padding: 0.875rem 1rem;
  box-shadow: var(--sm-shadow-lg);
  animation: sm-fade-up 0.25s var(--sm-ease);
}
.sm-toast.sm-toast-success { border-left-color: var(--sm-emerald); }
.sm-toast.sm-toast-error { border-left-color: var(--sm-rose); }
.sm-toast.sm-toast-info { border-left-color: var(--sm-sky); }
.sm-toast .sm-toast-icon {
  width: 2rem; height: 2rem; border-radius: 0.625rem; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 0.95rem;
}
.sm-toast-success .sm-toast-icon { background: #d1fae5; color: #047857; }
.sm-toast-error .sm-toast-icon { background: #ffe4e6; color: #be123c; }
.sm-toast-info .sm-toast-icon { background: #e0f2fe; color: #0369a1; }
.sm-toast .sm-toast-title { font-weight: 700; font-size: 0.875rem; color: var(--sm-ink); }
.sm-toast .sm-toast-msg { font-size: 0.8rem; color: var(--sm-muted); margin-top: 0.125rem; line-height: 1.4; }
.sm-toast.sm-toast-leave { opacity: 0; transform: translateX(12px); transition: opacity 0.25s, transform 0.25s; }

/* ---------- Keyframe animations ---------- */
@keyframes sm-fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes sm-scale-in {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes sm-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes sm-shimmer {
  100% { transform: translateX(100%); }
}
@keyframes sm-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.animate-fade-up {
  animation: sm-fade-up 0.25s var(--sm-ease) both;
  animation-delay: var(--d, 0s);
}
.animate-scale-in {
  animation: sm-scale-in 0.2s var(--sm-ease) both;
  animation-delay: var(--d, 0s);
}
.animate-fade-in {
  animation: sm-fade-in 0.2s ease both;
  animation-delay: var(--d, 0s);
}
.animate-float { animation: sm-float 5s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
