/**
 * Atproo EDA AI — CSS Integration Bridge
 * 
 * MAQSAD: design-system.css (yangi onboarding/auth) va mavjud
 * (main.css, style.css, dashboard.css) fayllar orasidagi konfliktlarni hal qiladi.
 *
 * YUKLASH TARTIBI (index.html da):
 *  1. main.css          ← asosiy token'lar va komponentlar (o'zgartirmang)
 *  2. style.css         ← pages, scan, gamification (o'zgartirmang)
 *  3. dashboard.css     ← sidebar, topbar, bottom-nav (o'zgartirmang)
 *  4. admin.css         ← admin panel (o'zgartirmang)
 *  5. responsive.css    ← media queries (o'zgartirmang)
 *  6. integration.css   ← bu fayl (mavjud stillar ustiga)
 *  7. design-system.css ← yangi onboarding/auth stillar (eng oxirgi)
 *
 * Bu fayl ikkita ishni bajaradi:
 *  A) main.css + style.css token konfliktini tokenlarni moslashtirish orqali hal qiladi
 *  B) design-system.css ga kerak bo'lgan token'larni mavjud token'larga bog'laydi
 */

/* ═══════════════════════════════════════════════════════════
   A. TOKEN MOSLASHTIRISH
   main.css --teal/#18E7B5 ishlatadi, style.css --g1/#00e5a0 ishlatadi.
   Ikkalasini ham qabul qilib, design-system token'lariga bog'laymiz.
   ═══════════════════════════════════════════════════════════ */
:root {
  /* design-system.css o'z --bg, --bg2... ni belgilaydi (#09090f, #111118).
     main.css va style.css o'z versiyasini belgilaydi.
     Biz style.css versiyasini ustun qilamiz chunki u --g1 ishlatadi
     va HTML da ko'proq ishlatiladigan versiya. */

  /* Brand token'larni uyg'unlashtirish */
  --g1:  #00e5a0;   /* style.css asosiy brand — barcha joyda ishlaydi */
  --g2:  #00c8b8;
  --g3:  #4f8eff;
  --teal:  #00e5a0; /* main.css --teal ni ham bir xil qilamiz */
  --teal2: #00c8b8;
  --blue:  #4fa8ff;

  /* Background — style.css versiyasi (qoraqo'ng'ir, ilovada ishlatiladigan) */
  --bg:  #0F1117;
  --bg2: #161B27;
  --bg3: #1C2333;
  --bg4: #232B3E;
  --bg5: #202030;

  /* design-system.css kutadigan token'lar (mavjud token'larga yo'naltiriladi) */
  --surface:  rgba(255,255,255,0.04);   /* = --card */
  --surface2: rgba(255,255,255,0.07);   /* = --card2 */
  --border:   rgba(255,255,255,0.07);   /* = --bd */
  --border2:  rgba(255,255,255,0.12);   /* = --bd2 */

  /* design-system gradient shorthand'lari */
  --grad-brand: linear-gradient(135deg, #00e5a0 0%, #4f8eff 100%);

  /* Radius — style.css versiyasi */
  --r:  12px;
  --r2: 10px;
  --r3: 8px;
  --r-lg: 20px;
  --r-xl: 24px;
  --r-full: 9999px;

  /* Spacing (design-system.css uchun) */
  --sp-xs: 4px; --sp-sm: 8px; --sp: 12px;
  --sp-md: 16px; --sp-lg: 20px; --sp-xl: 24px;
  --sp-2xl: 32px; --sp-3xl: 48px;

  /* Typography (design-system.css uchun) */
  --fs-xs: 11px; --fs-sm: 13px; --fs-base: 15px; --fs-md: 17px;
  --fs-lg: 20px; --fs-xl: 24px; --fs-2xl: 30px; --fs-3xl: 38px; --fs-4xl: 48px;

  /* Motion (design-system.css uchun) */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 160ms; --dur: 240ms; --dur-slow: 400ms;

  /* Layout */
  --sidebar-w: 210px;    /* dashboard.css dagi #sb-desktop width bilan mos */
  --topbar-h: 60px;
  --bottomnav-h: 80px;
  --content-max: 520px;
}

/* ═══════════════════════════════════════════════════════════
   B. MAVJUD FAYLLAR BILAN MOSLIK
   ═══════════════════════════════════════════════════════════ */

/* dashboard.css .page.on ishlatadi, design-system .page.active ishlatadi —
   ikkalasini ham qo'llab-quvvatlaymiz */
.page.active { display: block; }
.page.on     { display: block; }

/* auth.css .auth-tab.on, main.css .auth-tab.active ishlatadi */
.auth-tab.on {
  background: var(--bg2);
  color: var(--t1);
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}

/* dashboard.css .nav-item.on, main.css .bn-item.active */
.nav-item.active { color: var(--g1); }
.nav-item.on .nav-ico { /* Already handled in dashboard.css */ }

/* ═══════════════════════════════════════════════════════════
   C. ONBOARDING SHELL — mavjud #app va #auth-screen bilan mos ishlash
   ═══════════════════════════════════════════════════════════ */

/* auth.css #app ni position:fixed qiladi.
   Onboarding ochiq bo'lganda #app ko'rinmaydi — JS hal qiladi.
   Bu yerda faqat z-index tartibini ta'minlaymiz. */
#onboarding-screen {
  position: fixed;
  inset: 0;
  z-index: 250;  /* auth-screen (z-index:200) dan yuqori, admin (z-index:300) dan past */
  background: var(--bg);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════
   D. AUTH SCREEN — auth.css + main.css ustiga yangilamalar
   ═══════════════════════════════════════════════════════════ */

/* auth.css .auth-box ni yangi premium dizayn bilan yaxshilash */
.auth-box {
  border-radius: 28px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  animation: authCardIn 0.45s var(--ease-spring) both;
}
@keyframes authCardIn {
  from { opacity: 0; transform: scale(0.95) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Logo animatsiyasi yaxshilash */
.auth-logo-icon {
  animation: logoFloat 3s ease-in-out infinite;
}
@keyframes logoFloat {
  0%,100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-6px) scale(1.02); }
}

/* auth.css .auth-btn ni yangi token bilan bog'lash */
.auth-btn {
  background: var(--grad-brand);
  box-shadow: 0 8px 28px rgba(0, 229, 160, 0.3);
  transition: transform 0.18s var(--ease-spring), box-shadow 0.18s;
}
.auth-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 36px rgba(0, 229, 160, 0.4);
}

/* main.css .fi (input field) yaxshilash */
.fi:focus {
  border-color: rgba(0, 229, 160, 0.5);
  box-shadow: 0 0 0 3px rgba(0, 229, 160, 0.1);
}

/* ═══════════════════════════════════════════════════════════
   E. MAVJUD KLASS NOMLARI UCHUN QISQA YO'NALTIRISHLAR
   (design-system.css yangi klass nomlari ishlatadi —
    mavjud HTML bilan moslik uchun)
   ═══════════════════════════════════════════════════════════ */

/* style.css .modal-bg ishlatadi, main.css .modal-overlay ishlatadi */
.modal-bg.on        { display: flex; }
.modal-overlay.on   { display: flex; }

/* style.css .btn-pri, main.css .btn-primary — ikkalasi ham gradient */
.btn-pri {
  background: var(--grad-brand);
  box-shadow: 0 6px 20px rgba(0, 229, 160, 0.25);
}
.btn-primary {
  background: var(--grad-brand);
  box-shadow: 0 6px 24px rgba(0, 229, 160, 0.25);
}

/* ═══════════════════════════════════════════════════════════
   F. PREMIUM MICRO-IMPROVEMENTS (mavjud UI ga qo'shiladi)
   ═══════════════════════════════════════════════════════════ */

/* Topbar blur effektini kuchaytirish */
.topbar {
  background: rgba(15, 17, 23, 0.88);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}

/* Sidebar items hover animatsiyasi */
.sdi {
  transition: all 0.15s var(--ease-smooth);
}
.sdi:hover {
  transform: translateX(2px);
}

/* Bottom nav aktiv holat pill */
.nav-item.on {
  position: relative;
}
.nav-item.on::before {
  content: '';
  position: absolute;
  top: 4px;
  width: 20px; height: 3px;
  background: var(--g1);
  border-radius: 0 0 3px 3px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/* Card hover lift */
.card {
  transition: transform 0.18s var(--ease-smooth),
              box-shadow 0.18s var(--ease-smooth),
              border-color 0.18s;
}
.card:hover {
  border-color: var(--bd2);
}

/* Skeleton loading (history list uchun) */
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}
.skel {
  background: linear-gradient(90deg, var(--bg3) 25%, var(--bg4) 50%, var(--bg3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r3);
}
.skel-row   { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.skel-thumb { width: 48px; height: 48px; border-radius: var(--r3); flex-shrink: 0; }
.skel-info  { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.skel-line  { height: 12px; }
.skel-w70   { width: 70%; }
.skel-w40   { width: 40%; }
.skel-badge { width: 36px; height: 20px; border-radius: 50px; }

/* Password strength bar */
.ps-bar {
  height: 3px;
  background: var(--bg4);
  border-radius: 50px;
  overflow: hidden;
  margin-bottom: 4px;
}
.ps-fill {
  height: 100%;
  border-radius: 50px;
  transition: width 0.3s var(--ease-smooth), background 0.3s;
}
.ps-label {
  font-size: 11px;
  font-weight: 600;
}

/* History detail modal macros */
.hd-header  { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.hd-thumb   { width: 64px; height: 64px; border-radius: 14px; background: var(--bg3);
               display: flex; align-items: center; justify-content: center;
               font-size: 32px; overflow: hidden; flex-shrink: 0; }
.hd-thumb img { width: 100%; height: 100%; object-fit: cover; }
.hd-name    { font-size: 18px; font-weight: 800; }
.hd-date    { font-size: 12px; color: var(--t3); margin-top: 4px; }
.hd-macros  { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin-bottom: 14px; }
.hd-macro   { text-align: center; background: var(--bg3); border-radius: var(--r3); padding: 10px; }
.hd-macro-val { font-size: 18px; font-weight: 900; color: var(--g1); }
.hd-macro-lbl { font-size: 10px; color: var(--t3); margin-top: 2px; }
.hd-advice  { font-size: 13px; color: var(--t2); line-height: 1.6; }
