/* ===== Base & Reset ===== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
    overscroll-behavior: none;
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    background: #f5f6fa;
}
body {
    font-family: 'Inter', 'Tajawal', sans-serif;
    -webkit-font-smoothing: antialiased;
    background: #f5f6fa;
}



/* Arabic font when RTL */
.rtl, [dir="rtl"] {
  font-family: 'Tajawal', 'Inter', sans-serif;
}

/* ===== Scrollbar (iOS-like) ===== */
::-webkit-scrollbar { width: 0; height: 0; }
* { scrollbar-width: none; }

/* ===== Animated Gradient Background ===== */
.app-gradient-bg {
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 25%, #e0e7ff 50%, #dbeafe 75%, #f0f9ff 100%);
  background-size: 400% 400%;
  animation: gradientShift 15s ease infinite;
}
@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ===== Login Animated BG ===== */
.login-bg {
  background: linear-gradient(-45deg, #4f46e5, #7c3aed, #6366f1, #8b5cf6);
  background-size: 400% 400%;
  animation: loginGradient 12s ease infinite;
  position: relative;
  overflow: hidden;
}
.login-bg::before {
  content: '';
  position: absolute;
  width: 200%; height: 200%;
  top: -50%; left: -50%;
  background: radial-gradient(circle, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 30px 30px;
  animation: patternDrift 20s linear infinite;
}
.login-bg::after {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(245,158,11,0.15), transparent 70%);
  top: -100px; right: -100px;
  border-radius: 50%;
  animation: orbFloat 8s ease-in-out infinite;
}
@keyframes loginGradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes patternDrift {
  from { transform: translate(0, 0); }
  to { transform: translate(30px, 30px); }
}
@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-30px, 30px) scale(1.1); }
}

/* ===== Glass Effect ===== */
.glass {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.5);
}
.glass-dark {
  background: rgba(79, 70, 229, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* ===== Tab Bar ===== */
.tab-btn { color: #94a3b8; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.tab-btn.active { color: #4f46e5; }
.tab-btn.active i { stroke-width: 2.5; }
.tab-btn.active .tab-dot { opacity: 1; transform: scale(1); }
.tab-dot {
  width: 4px; height: 4px; border-radius: 50%; background: #4f46e5;
  opacity: 0; transform: scale(0); transition: all 0.3s ease;
  margin-top: 2px;
}

/* ===== Page Transitions ===== */
.view-enter { animation: viewEnter 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
@keyframes viewEnter {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.view-exit { animation: viewExit 0.15s ease-in forwards; }
@keyframes viewExit {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-8px); }
}

/* ===== Slide Up ===== */
.slide-up { animation: slideUp 0.35s cubic-bezier(0.32, 0.72, 0, 1) forwards; }
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* ===== Fade In ===== */
.fade-in { animation: fadeIn 0.3s ease forwards; }
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== Card Hover ===== */
.card-hover {
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease;
}
.card-hover:active { transform: scale(0.97); }
.card-hover:hover {
  box-shadow: 0 8px 30px rgba(79, 70, 229, 0.08);
}

/* ===== Modern Card ===== */
.modern-card {
  background: white;
  border-radius: 20px;
  border: 1px solid rgba(0, 0, 0, 0.04);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(79, 70, 229, 0.04);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.modern-card:active { transform: scale(0.98); }

/* ===== Toast ===== */
.toast-enter { animation: toastIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.toast-exit { animation: toastOut 0.3s ease forwards; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-20px) scale(0.9); }
}

/* ===== Bottom Sheet ===== */
.bottom-sheet-open { overflow: hidden; }

/* ===== Pull to Refresh ===== */
.ptr-indicator {
  display: flex; align-items: center; justify-content: center;
  height: 0; overflow: hidden; transition: height 0.2s ease;
}
.ptr-indicator.ptr-active { height: 50px; }
.ptr-indicator.ptr-refreshing { height: 50px; }
.ptr-spinner { animation: ptrSpin 0.8s linear infinite; }
@keyframes ptrSpin { to { transform: rotate(360deg); } }

/* ===== Input Focus ===== */
input:focus, textarea:focus, select:focus { outline: none; }

/* ===== Modern Input ===== */
.modern-input {
  width: 100%;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 14px;
  background: white;
  transition: all 0.25s ease;
  color: #1e293b;
}
.modern-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
  background: white;
}
.modern-input::placeholder { color: #94a3b8; }
.modern-select {
  width: 100%;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 14px;
  background: white;
  transition: all 0.25s ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.modern-select:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

/* ===== Chart Bars ===== */
.bar-chart-bar {
  transition: height 0.6s cubic-bezier(0.32, 0.72, 0, 1);
  border-radius: 8px 8px 4px 4px;
}

/* ===== Stat Card ===== */
.stat-card {
  background: white; border-radius: 20px; padding: 18px;
  border: 1px solid rgba(0, 0, 0, 0.04);
  box-shadow: 0 1px 3px rgba(0,0,0,0.03), 0 4px 14px rgba(79, 70, 229, 0.04);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--stat-color, #6366f1), var(--stat-color-light, #818cf8));
  opacity: 0;
  transition: opacity 0.3s ease;
}
.stat-card:hover::before { opacity: 1; }
.stat-card:active { transform: scale(0.97); }

/* ===== Badge ===== */
.badge { 
  display: inline-flex; align-items: center; padding: 3px 10px; 
  border-radius: 20px; font-size: 11px; font-weight: 600; 
  letter-spacing: 0.01em;
}

/* ===== Status Colors ===== */
.status-active { background: linear-gradient(135deg, #dcfce7, #bbf7d0); color: #166534; }
.status-pending { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e; }
.status-closed { background: linear-gradient(135deg, #f1f5f9, #e2e8f0); color: #475569; }
.status-archived { background: linear-gradient(135deg, #e5e7eb, #d1d5db); color: #374151; }
.status-completed { background: linear-gradient(135deg, #dbeafe, #bfdbfe); color: #1e40af; }
.status-cancelled { background: linear-gradient(135deg, #fee2e2, #fecaca); color: #991b1b; }

/* ===== Game Option ===== */
.game-option {
  border: 2px solid #e2e8f0; border-radius: 16px; padding: 14px 18px;
  cursor: pointer; transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1); user-select: none;
  background: white;
}
.game-option:active { transform: scale(0.97); }
.game-option.selected { 
  border-color: #6366f1; 
  background: linear-gradient(135deg, #eef2ff, #e0e7ff);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}
.game-option.correct { 
  border-color: #22c55e; 
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.1);
}
.game-option.incorrect { 
  border-color: #ef4444; 
  background: linear-gradient(135deg, #fef2f2, #fee2e2);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
}

/* ===== Avatar ===== */
.avatar {
  width: 46px; height: 46px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; color: white; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.avatar-lg { 
  width: 72px; height: 72px; border-radius: 20px; font-size: 26px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

/* ===== FAB ===== */
/*.fab {
  position: fixed; bottom: 90px; z-index: 40;
  width: 58px; height: 58px; border-radius: 18px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: white; border: none;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4), 0 2px 6px rgba(99, 102, 241, 0.2);
  cursor: pointer; transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}*/

.fab {
    position: fixed;
    bottom: calc(90px + env(safe-area-inset-bottom, 0));
    bottom: calc(90px + constant(safe-area-inset-bottom, 0));
    right: 20px;
    z-index: 40;
    width: 58px;
    height: 58px;
    border-radius: 18px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4), 0 2px 6px rgba(99, 102, 241, 0.2);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}


.fab:active { 
  transform: scale(0.88); 
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}
.fab:hover {
  box-shadow: 0 8px 28px rgba(99, 102, 241, 0.5), 0 2px 8px rgba(99, 102, 241, 0.3);
}
[dir="ltr"] .fab, .fab { right: 20px; }
[dir="rtl"] .fab { right: 20px; }

/* ===== Filter Pill ===== */
.filter-pill {
  padding: 8px 16px;
  border-radius: 24px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  border: 1.5px solid transparent;
}
.filter-pill.active {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}
.filter-pill:not(.active) {
  background: white;
  color: #64748b;
  border-color: #e2e8f0;
}
.filter-pill:not(.active):active {
  background: #f8fafc;
  border-color: #cbd5e1;
}

/* ===== RTL Overrides ===== */
[dir="rtl"] .text-left { text-align: right; }
[dir="rtl"] .text-right { text-align: left; }
[dir="rtl"] .mr-auto { margin-right: 0; margin-left: auto; }
[dir="rtl"] .ml-auto { margin-left: 0; margin-right: auto; }
[dir="rtl"] .pl-11 { padding-left: 0 !important; padding-right: 2.75rem !important; }
[dir="rtl"] .login-icon { left: auto !important; right: 1rem !important; }
[dir="rtl"] .pl-4 { padding-left: 0; padding-right: 1rem; }
[dir="rtl"] .pr-4 { padding-right: 0; padding-left: 1rem; }
[dir="rtl"] .border-l { border-left: 0; border-right-width: 1px; }
[dir="rtl"] .border-r { border-right: 0; border-left-width: 1px; }
[dir="rtl"] .fa-chevron-right { transform: rotate(180deg); }
[dir="rtl"] .rotate-180 { transform: rotate(0deg); }

/* RTL for input icons */
[dir="rtl"] .relative i:first-child {
  left: auto !important; right: 1rem !important;
}
[dir="rtl"] .relative i.absolute {
  left: auto !important; right: 0.75rem !important;
}
[dir="rtl"] input .pl-10, [dir="rtl"] input.pl-10 {
  padding-left: 0 !important;
  padding-right: 2.5rem !important;
}

/* RTL for modern select dropdown arrow */
[dir="rtl"] .modern-select {
  background-position: left 12px center;
}

/* ===== Safe Areas ===== */
.safe-top { padding-top: env(safe-area-inset-top); }
.safe-bottom { padding-bottom: env(safe-area-inset-bottom); }

/* ===== Skeleton ===== */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeleton 1.5s infinite;
  border-radius: 12px;
}
@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== Pulse Dot ===== */
.pulse-dot {
  width: 8px; height: 8px; border-radius: 50%;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(99, 102, 241, 0); }
  100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

/* ===== Tab Underline ===== */
.tab-underline {
  position: relative; padding-bottom: 8px;
  transition: all 0.25s ease;
}
.tab-underline::after {
  content: ''; position: absolute; bottom: 0; left: 10%; right: 10%;
  height: 3px; background: linear-gradient(90deg, #6366f1, #8b5cf6);
  border-radius: 3px;
  transform: scaleX(0); transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.tab-underline.active::after { transform: scaleX(1); }

/* ===== Case Detail Tabs ===== */
.case-tab {
  display: flex; align-items: center; gap: 4px;
  padding: 7px 12px; border-radius: 12px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  color: #64748b; background: transparent;
  border: 1.5px solid transparent;
}
.case-tab:active { transform: scale(0.95); }
.case-tab.active {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: white;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
  border-color: transparent;
}
.case-tab i { stroke-width: 2; }

/* ===== No Scrollbar ===== */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* ===== More Menu ===== */
.more-option {
  display: flex; align-items: center; gap: 16px; padding: 16px 20px;
  cursor: pointer; transition: all 0.2s ease;
  border-bottom: 1px solid #f1f5f9;
}
.more-option:active { background: rgba(99, 102, 241, 0.04); }
.more-option:last-child { border-bottom: none; }

/* ===== Gradient Text ===== */
.gradient-text {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== Header Gradient ===== */
.header-gradient {
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 50%, #7c3aed 100%);
}

/* ===== Modern Button ===== */
.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: white;
  border: none;
  padding: 14px 24px;
  border-radius: 16px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.25);
}
.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

.btn-secondary {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  border: none;
  padding: 14px 24px;
  border-radius: 16px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.25);
}
.btn-secondary:active {
  transform: scale(0.97);
}

/* ===== Icon Container Modern ===== */
.icon-box {
  width: 44px; height: 44px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

/* ===== Stagger Animation ===== */
.stagger-item {
  opacity: 0;
  transform: translateY(10px);
  animation: staggerIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes staggerIn {
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Smooth Scroll ===== */
.scroll-smooth { scroll-behavior: smooth; }

/* ===== Number Counter Animation ===== */
.count-up {
  animation: countUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes countUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Hearing status badges */
.status-in-process {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    color: #1e40af;
}

.status-postponed {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e;
}
/* completed and cancelled already exist */

/* ===== Safe Area Insets ===== */
:root {
    --sat: env(safe-area-inset-top);
    --sab: env(safe-area-inset-bottom);
    --sal: env(safe-area-inset-left);
    --sar: env(safe-area-inset-right);
}

/* App shell should use dynamic viewport height */
#app-shell {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    height: -webkit-fill-available;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: inherit;
}

/* Bottom navigation padding for safe area */
nav.shrink-0 {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    padding-bottom: env(safe-area-inset-bottom, 0);
    /* Fallback for older iOS */
    padding-bottom: constant(safe-area-inset-bottom, 0);
}

/* If you have a bottom sheet or fab, adjust their position */
.fab {
    bottom: calc(100px + var(--sab));
}

/* Ensure content area respects safe area */
#app-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: env(safe-area-inset-bottom, 0);
    padding-bottom: constant(safe-area-inset-bottom, 0);
}

nav .flex {
    padding-bottom: 0;
}

/* Status bar spacer (if you have one) */
.safe-top {
    padding-top: var(--sat);
}

/* Safe bottom for modals (bottom sheet) */
#bottom-sheet {
    padding-bottom: env(safe-area-inset-bottom, 0);
    padding-bottom: constant(safe-area-inset-bottom, 0);
}

/* Glass navigation background */
nav.glass {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.3);
}

header.header-gradient {
    padding-top: env(safe-area-inset-top, 0);
    padding-top: constant(safe-area-inset-top, 0);
}