/* ============================================================
   FanusGo User App — Web Style System
   Version: 2.0
   ============================================================ */

/* ── Design Tokens ────────────────────────────────────── */
:root {
  --fg-primary: #26AECD;
  --fg-primary-light: rgba(38, 174, 205, 0.12);
  --fg-primary-dark: #1E8FA8;
  --fg-secondary: #FFFF00;
  --fg-accent: #FF6B35;
  --fg-success: #4CAF50;
  --fg-error: #E84D4F;
  --fg-warning: #FFB74D;

  --fg-text: #111;
  --fg-text-secondary: #5E6472;
  --fg-text-muted: #9B9B9B;

  --fg-bg: #fff;
  --fg-bg-surface: #F5F6F8;
  --fg-bg-card: #fff;

  --fg-border: rgba(186, 191, 196, 0.25);
  --fg-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  --fg-shadow-header: 0px 6px 12px -3px rgba(4, 97, 165, 0.1);

  --fg-radius-sm: 0.375rem;
  --fg-radius: 0.625rem;
  --fg-radius-lg: 1rem;
  --fg-radius-full: 50rem;

  --fg-font: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --fg-font-ar: 'Lalezar', 'Nunito', sans-serif;

  --fg-header-height: 5rem;
  --fg-safe-area-top: env(safe-area-inset-top, 0px);
  --fg-safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Dark Mode Tokens ─────────────────────────────────── */
.theme-dark {
  --fg-text: #F5F5F5;
  --fg-text-secondary: #BABFC4;
  --fg-text-muted: #777;

  --fg-bg: #111;
  --fg-bg-surface: #272727;
  --fg-bg-card: #141313;

  --fg-border: rgba(162, 167, 173, 0.25);
  --fg-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
  --fg-shadow-header: 0px 6px 12px -3px rgba(0, 0, 0, 0.3);
}

/* ── Reset ────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--fg-font);
  color: var(--fg-text);
  background-color: var(--fg-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-top: var(--fg-safe-area-top);
  padding-bottom: var(--fg-safe-area-bottom);
}

/* ── Preloader ────────────────────────────────────────── */
.preloader {
  position: fixed;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  background-color: var(--fg-bg);
  display: grid;
  place-items: center;
  z-index: 99999;
  transition: opacity 0.4s ease-out;
}

.preloader-container {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  align-items: center;
  padding-bottom: 3rem;
}

/* ── Splash Logo ──────────────────────────────────────── */
.splash-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 120px;
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(38, 174, 205, 0.08), rgba(38, 174, 205, 0.02));
  animation: splashPulse 2s ease-in-out infinite;
}

.splash-logo {
  width: 96px;
  height: 96px;
  object-fit: contain;
  animation: splashFloat 2.4s ease-in-out infinite;
}

.splash-brand {
  text-align: center;
  animation: fadeIn 0.8s ease-out 0.3s both;
}

.splash-name {
  font-family: var(--fg-font);
  font-weight: 800;
  font-size: 1.75rem;
  background: linear-gradient(135deg, var(--fg-primary), var(--fg-primary-dark));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.splash-tagline {
  font-family: var(--fg-font);
  font-size: 0.875rem;
  color: var(--fg-text-secondary);
  margin-top: 0.25rem;
  letter-spacing: 0.02em;
}

[dir="rtl"] .splash-name,
[dir="rtl"] .splash-tagline {
  font-family: var(--fg-font-ar);
}

@keyframes splashPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(38, 174, 205, 0.15); }
  50% { transform: scale(1.04); box-shadow: 0 0 0 12px rgba(38, 174, 205, 0); }
}

@keyframes splashFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* ── Loader Bar ──────────────────────────────────────── */
.preloader .loader {
  width: 160px;
  height: 0.25rem;
  display: inline-block;
  position: relative;
  background: var(--fg-border);
  overflow: hidden;
  border-radius: var(--fg-radius-full);
  margin-top: 0.5rem;
}

.preloader .loader::after {
  content: "";
  width: 40px;
  height: 4px;
  background: linear-gradient(90deg, var(--fg-primary), var(--fg-primary-dark));
  position: absolute;
  top: 0;
  left: 0;
  box-sizing: border-box;
  animation: animloader 1600ms ease-in-out infinite;
  border-radius: var(--fg-radius-full);
}

/* ── Header Skeleton ──────────────────────────────────── */
.header {
  position: fixed;
  inset-block-start: 0;
  inset-inline-start: 0;
  inline-size: 100%;
  block-size: var(--fg-header-height);
  background-color: var(--fg-bg-card);
  box-shadow: var(--fg-shadow-header);
  z-index: 9998;
  padding-top: var(--fg-safe-area-top);
}

.header-container {
  max-inline-size: 1200px;
  margin-inline: auto;
  padding: 1.28rem 1.6rem;
  border-radius: 0 0 var(--fg-radius) var(--fg-radius);
}

.header .logo {
  max-block-size: 2.315rem;
}

/* Hide header skeleton on mobile — Flutter handles navigation */
@media (max-width: 1024px) {
  .header {
    display: none;
  }
}

/* ── Skeleton Placeholders ────────────────────────────── */
.placeholder {
  block-size: 0.825rem;
  inline-size: 3rem;
  background: linear-gradient(90deg, var(--fg-bg-surface) 25%, rgba(0,0,0,0.04) 50%, var(--fg-bg-surface) 75%);
  background-size: 200% 100%;
  border-radius: var(--fg-radius-sm);
  animation: shimmer 1.8s ease-in-out infinite;
}

.placeholder-wide {
  inline-size: 12rem;
}

/* ── Touch Interaction Styles ─────────────────────────── */
.touch-target {
  min-height: 44px;
  min-width: 44px;
}

.no-select {
  user-select: none;
  -webkit-user-select: none;
}

/* Improve scrollbar appearance on desktop */
@media (min-width: 1024px) {
  ::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }
  ::-webkit-scrollbar-track {
    background: transparent;
  }
  ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: var(--fg-radius-full);
  }
  ::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
  }
  .theme-dark ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
  }
  .theme-dark ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
  }
}

/* ── Utility Classes ──────────────────────────────────── */
.d-flex {
  display: flex;
}
.align-items-center {
  align-items: center;
}
.justify-content-center {
  justify-content: center;
}
.justify-content-between {
  justify-content: space-between;
}
.flex-column {
  flex-direction: column;
}
.text-center {
  text-align: center;
}
.gap-3 {
  gap: 1rem;
}
.gap-4 {
  gap: 1.5rem;
}
.gap-5 {
  gap: 3rem;
}

/* ── Animations ───────────────────────────────────────── */
@keyframes animloader {
  0% {
    left: 0;
    transform: translateX(-100%);
  }
  50% {
    left: 50%;
    transform: translateX(-50%);
  }
  100% {
    left: 100%;
    transform: translateX(0%);
  }
}

@keyframes animloaderimg {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-1rem);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Responsive Breakpoints ───────────────────────────── */
/* Mobile: < 650px (base styles apply) */

/* Tablet: 650px - 1299px */
@media (min-width: 650px) {
  .preloader-container {
    gap: 2.5rem;
  }

  .preloader .loader {
    width: 200px;
  }
}

/* Desktop: >= 1300px */
@media (min-width: 1300px) {
  .preloader-container {
    gap: 3rem;
  }

  .preloader .loader {
    width: 240px;
  }
}

/* ── Print Styles ─────────────────────────────────────── */
@media print {
  .preloader,
  .header {
    display: none !important;
  }
}