/* =====================================================================
   AppVault — Global Theme, Animation & i18n System
   Dark mode · Light mode · RTL · Modern animations
   ===================================================================== */

/* ---- DARK THEME (Default) ---- */
html[data-theme="dark"],
html:not([data-theme]) {
  --primary:       #6366f1;
  --primary-dark:  #4f46e5;
  --primary-light: #818cf8;
  --accent:        #06b6d4;
  --accent-dark:   #0891b2;
  --accent-light:  #22d3ee;
  --green:         #10b981;
  --amber:         #f59e0b;
  --pink:          #ec4899;
  --blue:          #3b82f6;
  --red:           #ef4444;
  --bg:        #0f172a;
  --surface:   #1e293b;
  --surface-2: #273549;
  --surface-3: #1a2540;
  --border:    rgba(255,255,255,0.07);
  --border-md: rgba(255,255,255,0.11);
  --border-lg: rgba(255,255,255,0.17);
  --text:        #f1f5f9;
  --text-muted:  #94a3b8;
  --text-subtle: #64748b;
  --nav-bg: rgba(15,23,42,0.82);
  --input-bg: rgba(255,255,255,0.05);
  --card-shadow: rgba(0,0,0,0.4);
  --glow: rgba(99,102,241,0.4);
}

/* ---- LIGHT THEME ---- */
html[data-theme="light"] {
  --primary:       #4f46e5;
  --primary-dark:  #4338ca;
  --primary-light: #6366f1;
  --accent:        #0891b2;
  --accent-dark:   #0e7490;
  --accent-light:  #06b6d4;
  --green:         #059669;
  --amber:         #d97706;
  --pink:          #db2777;
  --blue:          #2563eb;
  --red:           #dc2626;
  --bg:        #f0f4ff;
  --surface:   #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e8edf7;
  --border:    rgba(0,0,0,0.07);
  --border-md: rgba(0,0,0,0.11);
  --border-lg: rgba(0,0,0,0.17);
  --text:        #0f172a;
  --text-muted:  #475569;
  --text-subtle: #94a3b8;
  --nav-bg: rgba(240,244,255,0.85);
  --input-bg: rgba(0,0,0,0.04);
  --card-shadow: rgba(0,0,0,0.1);
  --glow: rgba(99,102,241,0.2);
}

/* ---- Force body to use theme variables ---- */
html[data-theme="light"] body {
  background: var(--bg) !important;
  color: var(--text) !important;
}
html[data-theme="light"] ::-webkit-scrollbar-track { background: var(--bg) !important; }
html[data-theme="light"] ::-webkit-scrollbar-thumb { background: #cbd5e1 !important; }

/* ---- Light mode surface overrides ---- */
html[data-theme="light"] .sidebar,
html[data-theme="light"] .auth-left { background: linear-gradient(145deg,#1e293b,#0f172a) !important; }
html[data-theme="light"] .topbar   { background: rgba(255,255,255,0.92) !important; border-bottom-color: rgba(0,0,0,0.08) !important; }
html[data-theme="light"] nav.scrolled { background: rgba(240,244,255,0.92) !important; }
html[data-theme="light"] .trust-bar { background: rgba(255,255,255,0.6) !important; }
html[data-theme="light"] .hero-bg { opacity: 0.4; }

/* =====================================================================
   THEME TRANSITION (smooth toggling)
   ===================================================================== */
*, *::before, *::after {
  transition-property: background-color, border-color, color, box-shadow, fill, stroke;
  transition-duration: 0.28s;
  transition-timing-function: ease;
}
/* Override for animations we don't want slowed down */
.orb, .phone-wrap, .fbadge, .fbadge-1, .fbadge-2, .fbadge-3,
.ring-deco, .label-dot, [class*="orbFlow"], [class*="fbf"] {
  transition: none !important;
}

/* =====================================================================
   THEME TOGGLE BUTTON
   ===================================================================== */
.theme-toggle {
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 1.5px solid var(--border-md);
  background: var(--input-bg);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
  flex-shrink: 0;
}
.theme-toggle:hover {
  background: rgba(99,102,241,0.12) !important;
  border-color: rgba(99,102,241,0.35) !important;
  color: var(--primary) !important;
  transform: rotate(15deg) scale(1.08) !important;
}
.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  position: absolute;
  transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.34,1.56,0.64,1) !important;
}
html[data-theme="dark"] .icon-sun,
html:not([data-theme]) .icon-sun  { opacity: 0; transform: translateY(-20px) rotate(90deg); }
html[data-theme="dark"] .icon-moon,
html:not([data-theme]) .icon-moon { opacity: 1; transform: translateY(0) rotate(0deg); }
html[data-theme="light"] .icon-sun  { opacity: 1; transform: translateY(0) rotate(0deg); }
html[data-theme="light"] .icon-moon { opacity: 0; transform: translateY(20px) rotate(-90deg); }

/* =====================================================================
   LANGUAGE SWITCHER
   ===================================================================== */
.lang-switcher { position: relative; }

.lang-current {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 13px;
  border-radius: 12px;
  border: 1.5px solid var(--border-md);
  background: var(--input-bg);
  color: var(--text-muted);
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 13px; font-weight: 600;
  white-space: nowrap;
}
.lang-current:hover {
  background: rgba(99,102,241,0.08) !important;
  border-color: rgba(99,102,241,0.3) !important;
  color: var(--text) !important;
}
.lang-current svg:last-child {
  transition: transform 0.25s ease !important;
}
.lang-switcher.open .lang-current svg:last-child { transform: rotate(180deg); }

.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 172px;
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: 14px;
  padding: 6px;
  box-shadow: 0 20px 56px var(--card-shadow), 0 4px 16px rgba(0,0,0,0.1);
  opacity: 0; pointer-events: none;
  transform: translateY(-10px) scale(0.95);
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.34,1.56,0.64,1) !important;
  z-index: 9999;
}
.lang-switcher.open .lang-menu {
  opacity: 1; pointer-events: all;
  transform: translateY(0) scale(1);
}
.lang-opt {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 12px;
  border-radius: 9px;
  border: none; background: none;
  color: var(--text-muted);
  font-size: 13.5px; font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  text-align: left;
}
.lang-opt:hover {
  background: rgba(99,102,241,0.1) !important;
  color: var(--text) !important;
}
.lang-opt.active {
  background: rgba(99,102,241,0.13) !important;
  color: var(--primary-light) !important;
  font-weight: 700;
}

/* =====================================================================
   APP CONTROLS GROUP
   ===================================================================== */
.app-controls {
  display: flex; align-items: center; gap: 8px;
}

/* =====================================================================
   RTL SUPPORT (Arabic / Moroccan Darija)
   ===================================================================== */
[dir="rtl"] body                    { font-family: 'Inter', 'Cairo', 'Tajawal', sans-serif; }
[dir="rtl"] .lang-menu              { right: auto; left: 0; }
[dir="rtl"] .lang-opt               { text-align: right; flex-direction: row-reverse; }
[dir="rtl"] .nav-inner              { flex-direction: row-reverse; }
[dir="rtl"] .nav-links              { flex-direction: row-reverse; }
[dir="rtl"] .nav-actions            { flex-direction: row-reverse; }
[dir="rtl"] .hero-content           { direction: rtl; }
[dir="rtl"] .hero-btns              { flex-direction: row-reverse; }
[dir="rtl"] .hero-stats             { flex-direction: row-reverse; }
[dir="rtl"] .section-head           { direction: rtl; }
[dir="rtl"] .card-foot              { flex-direction: row-reverse; }
[dir="rtl"] .sidebar {
  left: auto; right: 0;
  border-right: none;
  border-left: 1px solid var(--border);
}
[dir="rtl"] .main                   { margin-left: 0; margin-right: var(--sidebar-w, 256px); }
[dir="rtl"] .nav-badge              { margin-left: 0; margin-right: auto; }
[dir="rtl"] .nav-item               { flex-direction: row-reverse; text-align: right; }
[dir="rtl"] .topbar-left            { flex-direction: row-reverse; }
[dir="rtl"] .topbar-right           { flex-direction: row-reverse; }
[dir="rtl"] .auth-shell             { flex-direction: row-reverse; }
[dir="rtl"] .al-body                { text-align: right; }
[dir="rtl"] .al-feat                { align-items: flex-end; }
[dir="rtl"] .al-fi                  { flex-direction: row-reverse; }
[dir="rtl"] .auth-card              { direction: rtl; text-align: right; }
[dir="rtl"] .auth-tabs              { flex-direction: row-reverse; }
[dir="rtl"] .form-extras            { flex-direction: row-reverse; }
[dir="rtl"] .check-row              { flex-direction: row-reverse; }
[dir="rtl"] .feat-card              { direction: rtl; }
[dir="rtl"] .footer-grid            { direction: rtl; }
[dir="rtl"] .footer-bottom          { flex-direction: row-reverse; }
[dir="rtl"] .testi-author           { flex-direction: row-reverse; }
[dir="rtl"] .overview-row .mini-stat{ flex-direction: row-reverse; }
[dir="rtl"] .subscription-card      { direction: rtl; }
[dir="rtl"] .sub-perks              { flex-direction: row-reverse; }
[dir="rtl"] .activity-item          { flex-direction: row-reverse; }
[dir="rtl"] .ql-item                { flex-direction: row-reverse; }
[dir="rtl"] .ql-arrow               { margin-left: 0; margin-right: auto; }
[dir="rtl"] .topbar-search input    { direction: rtl; }
[dir="rtl"] .product-grid           { direction: rtl; }
[dir="rtl"] .pi-meta                { flex-direction: row-reverse; }
[dir="rtl"] .breadcrumb             { flex-direction: row-reverse; }
[dir="rtl"] .card-actions           { direction: rtl; }
[dir="rtl"] .stepper                { flex-direction: row-reverse; }
[dir="rtl"] .form-nav               { flex-direction: row-reverse; }
[dir="rtl"] .stat-grid              { direction: rtl; }
[dir="rtl"] .sc-top                 { flex-direction: row-reverse; }

/* Keep logo icons visually on the left even when document direction is RTL */
[dir="rtl"] .nav-logo,
[dir="rtl"] .al-logo,
[dir="rtl"] .sidebar-logo,
[dir="rtl"] .footer-logo,
[dir="rtl"] .auth-brand {
  flex-direction: row !important;
}
[dir="rtl"] .nav-logo-icon,
[dir="rtl"] .al-logo-sq,
[dir="rtl"] .logo-icon,
[dir="rtl"] .auth-brand-icon {
  order: 0 !important;
}
[dir="rtl"] .nav-logo span,
[dir="rtl"] .al-logo span,
[dir="rtl"] .logo-name,
[dir="rtl"] .auth-brand-name,
[dir="rtl"] .footer-logo span {
  order: 1 !important;
}

/* =====================================================================
   KEYFRAME ANIMATIONS
   ===================================================================== */
@keyframes fadeInUp   { from{opacity:0;transform:translateY(30px)} to{opacity:1;transform:translateY(0)} }
@keyframes fadeIn     { from{opacity:0} to{opacity:1} }
@keyframes slideInL   { from{opacity:0;transform:translateX(-30px)} to{opacity:1;transform:translateX(0)} }
@keyframes slideInR   { from{opacity:0;transform:translateX(30px)} to{opacity:1;transform:translateX(0)} }
@keyframes scaleIn    { from{opacity:0;transform:scale(0.88)} to{opacity:1;transform:scale(1)} }
@keyframes floatY     { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-12px)} }
@keyframes floatAlt   { 0%,100%{transform:translateY(0) rotate(0deg)} 50%{transform:translateY(-8px) rotate(3deg)} }
@keyframes glowPulse  { 0%,100%{box-shadow:0 0 20px var(--glow)} 50%{box-shadow:0 0 40px var(--glow),0 0 70px var(--glow)} }
@keyframes gradientShift { 0%{background-position:0% 50%} 50%{background-position:100% 50%} 100%{background-position:0% 50%} }
@keyframes shimmerBg  { 0%{background-position:-200% 0} 100%{background-position:200% 0} }
@keyframes borderGlow { 0%,100%{border-color:rgba(99,102,241,.3)} 50%{border-color:rgba(99,102,241,.7)} }
@keyframes countUp    { from{opacity:0;transform:translateY(16px)} to{opacity:1;transform:translateY(0)} }
@keyframes pulseDot   { 0%,100%{transform:scale(1);opacity:1} 50%{transform:scale(0.75);opacity:.6} }
@keyframes spin       { from{transform:rotate(0deg)} to{transform:rotate(360deg)} }
@keyframes slideDown  { from{opacity:0;transform:translateY(-12px)} to{opacity:1;transform:translateY(0)} }

/* =====================================================================
   SCROLL REVEAL (IntersectionObserver driven)
   ===================================================================== */
.reveal-on-scroll {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.65s cubic-bezier(0.22,1,0.36,1),
              transform 0.65s cubic-bezier(0.22,1,0.36,1) !important;
}
.reveal-on-scroll.visible {
  opacity: 1 !important;
  transform: translateY(0) !important;
}
.reveal-on-scroll.from-left  { transform: translateX(-28px); }
.reveal-on-scroll.from-right { transform: translateX(28px); }
.reveal-on-scroll.scale-up   { transform: scale(0.9); }
.reveal-on-scroll.from-left.visible,
.reveal-on-scroll.from-right.visible { transform: translateX(0) !important; }
.reveal-on-scroll.scale-up.visible   { transform: scale(1) !important; }

/* Stagger delays */
.d-1  { transition-delay: 0.08s !important; }
.d-2  { transition-delay: 0.16s !important; }
.d-3  { transition-delay: 0.24s !important; }
.d-4  { transition-delay: 0.32s !important; }
.d-5  { transition-delay: 0.40s !important; }
.d-6  { transition-delay: 0.48s !important; }
.d-7  { transition-delay: 0.56s !important; }

/* =====================================================================
   GRADIENT TEXT
   ===================================================================== */
.g-text {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--accent-light) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
html[data-theme="light"] .g-text {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.g-text-warm {
  background: linear-gradient(135deg, #f59e0b 0%, #ec4899 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* =====================================================================
   GLASSMORPHISM
   ===================================================================== */
.glass {
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
}
html[data-theme="light"] .glass {
  background: rgba(255,255,255,0.75);
  border: 1px solid rgba(255,255,255,0.95);
  box-shadow: 0 8px 32px rgba(0,0,0,0.05);
}

/* =====================================================================
   SKELETON LOADER
   ===================================================================== */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmerBg 1.5s infinite;
  border-radius: 8px;
}

/* =====================================================================
   TOAST NOTIFICATION
   ===================================================================== */
.toast-stack {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 99999;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
[dir="rtl"] .toast-stack { right: auto; left: 24px; }
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border-md);
  box-shadow: 0 12px 48px var(--card-shadow);
  color: var(--text); font-size: 14px; font-weight: 500;
  pointer-events: all;
  animation: fadeInUp 0.32s ease;
  min-width: 240px; max-width: 360px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--primary); }
[dir="rtl"] .toast.success { border-left: none; border-right: 3px solid var(--green); }
[dir="rtl"] .toast.error   { border-left: none; border-right: 3px solid var(--red); }
[dir="rtl"] .toast.info    { border-left: none; border-right: 3px solid var(--primary); }
.toast-icon { font-size: 18px; flex-shrink: 0; }

/* =====================================================================
   ANIMATED GRADIENT BORDER
   ===================================================================== */
.grad-border {
  position: relative;
}
.grad-border::before {
  content: '';
  position: absolute; inset: -1px;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--primary), var(--accent), var(--pink));
  background-size: 200% 200%;
  animation: gradientShift 4s ease infinite;
  z-index: -1;
}

/* =====================================================================
   FLOATING ANIMATION UTILITIES
   ===================================================================== */
.anim-float    { animation: floatY 5s ease-in-out infinite; }
.anim-float-d2 { animation: floatY 5s ease-in-out infinite 0.8s; }
.anim-float-d3 { animation: floatY 5s ease-in-out infinite 1.6s; }
.anim-glow     { animation: glowPulse 3s ease-in-out infinite; }
.anim-spin     { animation: spin 20s linear infinite; }

/* =====================================================================
   ENHANCED CARD HOVER STATES (cross-page)
   ===================================================================== */
html[data-theme="light"] .app-card,
html[data-theme="light"] .feat-card,
html[data-theme="light"] .testi-card,
html[data-theme="light"] .stat-card,
html[data-theme="light"] .chart-panel,
html[data-theme="light"] .panel,
html[data-theme="light"] .mini-stat,
html[data-theme="light"] .subscription-card,
html[data-theme="light"] .product-info-card,
html[data-theme="light"] .form-card {
  box-shadow: 0 2px 16px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
}
html[data-theme="light"] .app-card:hover,
html[data-theme="light"] .feat-card:hover,
html[data-theme="light"] .testi-card:hover,
html[data-theme="light"] .stat-card:hover {
  box-shadow: 0 12px 40px rgba(99,102,241,0.15), 0 4px 12px rgba(0,0,0,0.06) !important;
}

/* =====================================================================
   LIGHT MODE — SPECIFIC COMPONENT FIXES
   ===================================================================== */
html[data-theme="light"] .hero-mesh {
  background-image:
    linear-gradient(rgba(99,102,241,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,102,241,.07) 1px, transparent 1px);
}
html[data-theme="light"] .phone-frame {
  border-color: rgba(0,0,0,0.1);
  box-shadow: 0 30px 80px rgba(0,0,0,0.18), 0 0 50px rgba(99,102,241,0.1);
}
html[data-theme="light"] .fbadge {
  background: rgba(255,255,255,0.95);
  border-color: rgba(0,0,0,0.1);
  box-shadow: 0 8px 28px rgba(0,0,0,0.12);
}
html[data-theme="light"] .nav-logo,
html[data-theme="light"] .nav-links a,
html[data-theme="light"] .nav-signin { color: var(--text) !important; }
html[data-theme="light"] .cta-card {
  background: linear-gradient(135deg, rgba(99,102,241,0.08) 0%, rgba(6,182,212,0.05) 100%);
  border-color: rgba(99,102,241,0.15);
}
html[data-theme="light"] .steps-vis { background: var(--surface); }
html[data-theme="light"] .trust-item { color: var(--text-subtle) !important; }
html[data-theme="light"] .sidebar-logo .logo-name,
html[data-theme="light"] .user-name,
html[data-theme="light"] .nav-item { color: rgba(255,255,255,0.8) !important; }
html[data-theme="light"] .nav-item:hover { color: #fff !important; }
html[data-theme="light"] .nav-item.active { color: var(--primary-light) !important; }
html[data-theme="light"] .sb-name { color: rgba(255,255,255,0.85) !important; }
html[data-theme="light"] .sb-role,
html[data-theme="light"] .nav-section-lbl,
html[data-theme="light"] .user-plan,
html[data-theme="light"] .nav-lbl,
html[data-theme="light"] .sb-section { color: rgba(255,255,255,0.4) !important; }
html[data-theme="light"] .topbar-title { color: var(--text) !important; }
html[data-theme="light"] .topbar-sub   { color: var(--text-muted) !important; }

/* =====================================================================
   LIGHT MODE — ABOUT & CONTACT PAGE FIXES
   ===================================================================== */
/* Stats bar dark background → light neutral */
html[data-theme="light"] .stats-bar {
  background: linear-gradient(135deg, rgba(99,102,241,0.04), rgba(6,182,212,0.03)) !important;
  border-color: rgba(0,0,0,0.07) !important;
}
/* Hero section mesh darker tint removed */
html[data-theme="light"] .hero-grid-mesh,
html[data-theme="light"] .hero-grid {
  background-image:
    linear-gradient(rgba(99,102,241,0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,102,241,0.09) 1px, transparent 1px);
}
/* Values section subtle bg */
html[data-theme="light"] .values-section {
  background: linear-gradient(180deg, transparent, rgba(99,102,241,0.02) 50%, transparent);
}
/* Card shadows for new components */
html[data-theme="light"] .val-card,
html[data-theme="light"] .info-card,
html[data-theme="light"] .faq-item,
html[data-theme="light"] .team-card,
html[data-theme="light"] .mission-card {
  box-shadow: 0 2px 16px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
}
html[data-theme="light"] .val-card:hover,
html[data-theme="light"] .info-card:hover,
html[data-theme="light"] .faq-item:hover {
  box-shadow: 0 12px 40px rgba(99,102,241,0.15), 0 4px 12px rgba(0,0,0,0.06) !important;
}
/* CTA card light mode */
html[data-theme="light"] .about-cta .cta-card {
  background: linear-gradient(135deg, rgba(99,102,241,0.07) 0%, rgba(6,182,212,0.04) 100%) !important;
}
/* Mission floating badges light mode */
html[data-theme="light"] .mission-float {
  box-shadow: 0 8px 28px rgba(0,0,0,0.12);
}
/* Form inputs light mode */
html[data-theme="light"] .form-row input,
html[data-theme="light"] .form-row select,
html[data-theme="light"] .form-row textarea {
  background: #fff !important;
  border-color: rgba(0,0,0,0.12) !important;
}

/* =====================================================================
   PAGE ENTRY ANIMATIONS
   ===================================================================== */
.page-enter { animation: fadeIn 0.5s ease forwards; }
.nav-enter  { animation: slideDown 0.4s ease forwards; }
.hero-enter { animation: fadeInUp 0.7s ease 0.1s both; }

/* =====================================================================
   ENHANCED SCROLL BAR (universal)
   ===================================================================== */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); }
