/* ============================================================
   DESIGN SYSTEM — Enhancements (additive only, no overrides)
   Shoaa Al Maarefa Schools | Makkah

   Adds: enhanced focus, hover lifts, empty states,
         skeleton animation, loading overlays, mobile table→cards,
         smooth button transitions, badge micro-interactions.
   ============================================================ */

/* ─────────────────────────────────────────────────
   ENHANCED CSS VARIABLES
───────────────────────────────────────────────── */
:root {
  /* Semantic colour tokens */
  --color-info:         #3B82F6;
  --color-info-light:   #EFF6FF;
  --color-success:      #22C55E;
  --color-success-light:#DCFCE7;
  --color-warning:      #F59E0B;
  --color-warning-light:#FEF3C7;
  --color-error:        #EF4444;
  --color-error-light:  #FEE2E2;

  /* Elevation tokens */
  --elevation-1: 0 1px 3px rgba(0,0,0,.06);
  --elevation-2: 0 4px 12px rgba(0,0,0,.08);
  --elevation-3: 0 8px 24px rgba(0,0,0,.12);
  --elevation-4: 0 16px 48px rgba(0,0,0,.16);

  /* Animation */
  --ease-spring:     cubic-bezier(.34, 1.56, .64, 1);
  --ease-out:        cubic-bezier(.25, .46, .45, .94);
  --duration-fast:   150ms;
  --duration-normal: 250ms;
  --duration-slow:   400ms;

  /* Z-index scale */
  --z-dropdown:  100;
  --z-sticky:    200;
  --z-modal:     300;
  --z-toast:     400;
  --z-overlay:   500;
}

/* ─────────────────────────────────────────────────
   FOCUS STATES  (Accessibility)
───────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: 4px;
}
button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible) {
  outline: none;
}

/* ─────────────────────────────────────────────────
   BUTTON ENHANCEMENTS
───────────────────────────────────────────────── */
.btn {
  transition:
    background var(--duration-fast) var(--ease-out),
    color       var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    box-shadow  var(--duration-fast) var(--ease-out),
    transform   var(--duration-fast) var(--ease-out);
}
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--elevation-2);
}
.btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: var(--elevation-1);
}
.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  pointer-events: none;
}

/* ─────────────────────────────────────────────────
   CARD HOVER LIFT
───────────────────────────────────────────────── */
.comp-card,
.dash-stat-card,
.sk-card {
  transition: transform var(--duration-normal) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out);
  will-change: transform;
}
.comp-card:hover,
.dash-stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--elevation-3);
}

/* ─────────────────────────────────────────────────
   BADGE MICRO-INTERACTION
───────────────────────────────────────────────── */
.badge {
  transition: filter var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}
.badge:hover { filter: brightness(1.08); }

/* ─────────────────────────────────────────────────
   SKELETON LOADING  (shimmer animation)
───────────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}
.skeleton {
  background: linear-gradient(
    90deg,
    #f0f4f8 25%,
    #e2e8f0 37%,
    #f0f4f8 63%
  );
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: var(--radius-sm);
}

/* ─────────────────────────────────────────────────
   EMPTY STATE
───────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 24px;
  text-align: center;
  gap: 12px;
  animation: fadeInUp var(--duration-slow) var(--ease-out) both;
}
.empty-state-icon {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-lg);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 4px;
}
.empty-state-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.empty-state-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 280px;
  line-height: 1.6;
}

/* ─────────────────────────────────────────────────
   FORM IMPROVEMENTS
───────────────────────────────────────────────── */
.form-input,
.form-select,
.form-textarea {
  transition:
    border-color var(--duration-fast) var(--ease-out),
    box-shadow   var(--duration-fast) var(--ease-out);
}
.form-input:hover,
.form-select:hover,
.form-textarea:hover {
  border-color: var(--primary);
}

/* Valid state */
.form-input:valid:not(:placeholder-shown) {
  border-color: var(--color-success);
}

/* ─────────────────────────────────────────────────
   TABLE IMPROVEMENTS
───────────────────────────────────────────────── */
.data-table tbody tr {
  transition: background var(--duration-fast) var(--ease-out);
}
.data-table tbody tr:hover {
  background: var(--primary-light) !important;
}

/* ─────────────────────────────────────────────────
   SIDEBAR NAV ITEM TRANSITION
───────────────────────────────────────────────── */
.sidebar-nav-item {
  transition:
    background var(--duration-fast) var(--ease-out),
    color       var(--duration-fast) var(--ease-out),
    padding     var(--duration-fast) var(--ease-out);
}

/* ─────────────────────────────────────────────────
   MODAL ANIMATION
───────────────────────────────────────────────── */
@keyframes modalSlideIn {
  from { opacity: 0; transform: scale(.95) translateY(-8px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}
.modal {
  animation: modalSlideIn var(--duration-normal) var(--ease-spring) both;
}

/* ─────────────────────────────────────────────────
   TOAST ANIMATION
───────────────────────────────────────────────── */
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast {
  animation: toastSlideIn var(--duration-normal) var(--ease-spring) both;
}

/* ─────────────────────────────────────────────────
   SCROLL REVEAL ANIMATION
───────────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in-up {
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity   var(--duration-slow) var(--ease-out),
    transform var(--duration-slow) var(--ease-out);
}
.fade-in-up.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ─────────────────────────────────────────────────
   LOADING BUTTON STATE
───────────────────────────────────────────────── */
.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: .8;
}
.btn-loading::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
}
@keyframes spin {
  to { transform: translateY(-50%) rotate(360deg); }
}

/* ─────────────────────────────────────────────────
   MOBILE — TABLE → CARD TRANSFORMATION
   On screens ≤ 600px, data tables reflow as stacked cards.
───────────────────────────────────────────────── */
@media (max-width: 600px) {
  .responsive-table thead {
    display: none;                  /* hide column headers */
  }
  .responsive-table,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td {
    display: block;
    width: 100%;
  }
  .responsive-table tr {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--elevation-1);
    margin-bottom: 12px;
    padding: 12px 16px;
    border: 1px solid var(--border);
  }
  .responsive-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border: none;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
  }
  .responsive-table td:last-child { border-bottom: none; }
  .responsive-table td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--text-muted);
    font-size: 11px;
    flex-shrink: 0;
    margin-left: 8px;
  }
}

/* ─────────────────────────────────────────────────
   MOBILE — SIDEBAR IMPROVEMENTS
───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transition: transform var(--duration-normal) var(--ease-out);
  }
  /* Reduce stat cards to 2 columns */
  .dash-stats {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}
@media (max-width: 480px) {
  .dash-stats {
    grid-template-columns: 1fr !important;
  }
}

/* ─────────────────────────────────────────────────
   SCROLLBAR STYLING  (wider webkit)
───────────────────────────────────────────────── */
.sidebar::-webkit-scrollbar,
.modal::-webkit-scrollbar {
  width: 4px;
}

/* ─────────────────────────────────────────────────
   PRINT STYLES
───────────────────────────────────────────────── */
@media print {
  .sidebar,
  .topbar,
  .toast-container,
  .modal-backdrop,
  .btn-ripple { display: none !important; }
  .dash-main  { margin: 0 !important; padding: 0 !important; }
  body        { background: #fff; }
}
