/* DATALAIZ — Design System v1.0 */
/* Brand: Sky Blue (#0ea5e9), Red (#ef4444), White (#ffffff) */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:ital,wght@0,300;0,400;0,500;0,600;1,400&display=swap');

/* ── CSS Variables ── */
:root {
  --blue: #0ea5e9;
  --blue-dark: #0284c7;
  --blue-light: #e0f2fe;
  --blue-mid: #38bdf8;
  --red: #ef4444;
  --red-dark: #dc2626;
  --red-light: #fee2e2;
  --white: #ffffff;
  --off-white: #f8fafc;
  --gray-50: #f0f9ff;
  --gray-100: #e0f2fe;
  --gray-200: #bae6fd;
  --gray-400: #64748b;
  --gray-600: #475569;
  --gray-900: #0f172a;
  --card-bg: #ffffff;
  --surface: #f8fafc;
  --border: rgba(14, 165, 233, 0.15);
  --shadow-sm: 0 1px 3px rgba(14, 165, 233, 0.1);
  --shadow: 0 4px 16px rgba(14, 165, 233, 0.15);
  --shadow-lg: 0 8px 32px rgba(14, 165, 233, 0.2);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --nav-h: 70px;
  --font-display: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--off-white);
  color: var(--gray-900);
  min-height: 100vh;
  padding-bottom: var(--nav-h);
  overflow-x: hidden;
}
a { color: var(--blue); text-decoration: none; }
img, svg { display: block; max-width: 100%; }
button { cursor: pointer; font-family: var(--font-body); border: none; outline: none; }

/* ── Typography ── */
.display-xl { font-family: var(--font-display); font-size: clamp(2rem, 8vw, 3.5rem); font-weight: 800; line-height: 1.1; }
.display-lg { font-family: var(--font-display); font-size: clamp(1.5rem, 6vw, 2.5rem); font-weight: 700; }
.display-md { font-family: var(--font-display); font-size: clamp(1.2rem, 4vw, 1.8rem); font-weight: 700; }
.heading { font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; }
.subheading { font-size: 0.875rem; color: var(--gray-400); font-weight: 400; }
.label { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gray-400); }

/* ── Layout ── */
.container { width: 100%; max-width: 480px; margin: 0 auto; padding: 0 16px; }
.page { min-height: calc(100vh - var(--nav-h)); padding: 0 0 24px; }
.section { padding: 20px 16px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

/* ── Cards ── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-body { padding: 16px; }
.card-lg .card-body { padding: 20px; }
.card-hover { transition: transform 0.2s, box-shadow 0.2s; }
.card-hover:active { transform: scale(0.98); box-shadow: var(--shadow); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: 50px;
  font-size: 0.9375rem;
  font-weight: 600;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  color: white;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.35);
}
.btn-primary:active { transform: scale(0.97); }
.btn-danger {
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: white;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
}
.btn-outline {
  background: transparent;
  color: var(--blue);
  border: 2px solid var(--blue);
}
.btn-ghost { background: var(--gray-100); color: var(--gray-600); }
.btn-sm { padding: 10px 16px; font-size: 0.8125rem; }
.btn-lg { padding: 18px 32px; font-size: 1rem; }
.btn-full { width: 100%; }
.btn-icon {
  width: 44px; height: 44px;
  padding: 0;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--blue-light);
  color: var(--blue);
  font-size: 1.1rem;
}

/* ── Header ── */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.35rem;
  color: var(--blue-dark);
}
.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  overflow: hidden;
}
.logo-icon::before {
  content: '';
  position: absolute;
  top: -4px; right: -4px;
  width: 14px; height: 14px;
  background: var(--red);
  border-radius: 50%;
}
.logo-icon svg { color: white; width: 18px; height: 18px; }
.logo span { color: var(--red); }

/* ── Bottom Navigation ── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  cursor: pointer;
  color: var(--gray-400);
  transition: color 0.2s;
  text-decoration: none;
}
.nav-item.active { color: var(--blue); }
.nav-item .nav-icon { font-size: 1.35rem; }
.nav-item .nav-label { font-size: 0.625rem; font-weight: 600; letter-spacing: 0.04em; }
.nav-item.active .nav-icon { transform: scale(1.15); }
.nav-item.center-btn .nav-icon {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  border-radius: 14px;
  font-size: 1.4rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.4);
  color: white;
  transform: translateY(-8px);
}
.nav-item.center-btn .nav-label { margin-top: -4px; color: var(--blue); font-weight: 700; }

/* ── Hero Section ── */
.hero-gradient {
  background: linear-gradient(160deg, var(--blue-dark) 0%, var(--blue) 60%, #38bdf8 100%);
  padding: 32px 16px 40px;
  position: relative;
  overflow: hidden;
  color: white;
}
.hero-gradient::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 200px; height: 200px;
  background: var(--red);
  border-radius: 50%;
  opacity: 0.12;
}
.hero-gradient::after {
  content: '';
  position: absolute;
  bottom: -60px; left: -20px;
  width: 160px; height: 160px;
  background: white;
  border-radius: 50%;
  opacity: 0.06;
}

/* ── Stats Grid ── */
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--blue-dark);
}
.stat-label { font-size: 0.75rem; color: var(--gray-400); font-weight: 500; }
.stat-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--blue-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  margin-bottom: 4px;
}

/* ── Wallet Card ── */
.wallet-hero {
  background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue) 100%);
  border-radius: var(--radius-lg);
  padding: 24px;
  color: white;
  position: relative;
  overflow: hidden;
}
.wallet-hero::after {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 120px; height: 120px;
  background: white;
  border-radius: 50%;
  opacity: 0.07;
}
.wallet-balance {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -1px;
}

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-label { font-size: 0.8125rem; font-weight: 600; color: var(--gray-600); }
.form-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  background: white;
  color: var(--gray-900);
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
}
.form-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}
.form-input::placeholder { color: #94a3b8; }
.form-textarea { min-height: 100px; resize: vertical; }

/* ── Upload Zone ── */
.upload-zone {
  border: 2px dashed var(--blue-mid);
  border-radius: var(--radius);
  padding: 32px 16px;
  text-align: center;
  background: var(--blue-light);
  cursor: pointer;
  transition: all 0.2s;
}
.upload-zone:active, .upload-zone.dragover {
  background: var(--gray-100);
  border-color: var(--blue-dark);
}
.upload-icon { font-size: 2.5rem; margin-bottom: 12px; }
.upload-text { font-weight: 600; color: var(--blue-dark); margin-bottom: 4px; }
.upload-hint { font-size: 0.8125rem; color: var(--gray-400); }

/* ── Chat Interface ── */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--nav-h) - 120px);
  overflow: hidden;
}
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.chat-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.9375rem;
  line-height: 1.5;
  animation: bubbleIn 0.25s ease;
}
.chat-bubble.user {
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 6px;
}
.chat-bubble.ai {
  background: white;
  color: var(--gray-900);
  border: 1px solid var(--border);
  align-self: flex-start;
  border-bottom-left-radius: 6px;
}
.chat-input-bar {
  padding: 12px 16px;
  background: white;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 24px;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
}
.chat-send {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  color: white;
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.35);
  flex-shrink: 0;
}
@keyframes bubbleIn { from { opacity: 0; transform: translateY(8px) scale(0.96); } to { opacity: 1; transform: none; } }

/* ── Plan Cards ── */
.plan-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  transition: all 0.2s;
  background: white;
}
.plan-card.featured {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.1);
}
.plan-badge {
  position: absolute;
  top: -12px; right: 16px;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: white;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 50px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.plan-price {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--blue-dark);
}
.plan-feature { display: flex; align-items: center; gap: 10px; font-size: 0.875rem; color: var(--gray-600); padding: 6px 0; }
.plan-feature .check { color: var(--blue); font-size: 1rem; }

/* ── Progress Bar ── */
.progress-bar { height: 6px; background: var(--gray-100); border-radius: 50px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--blue), var(--blue-mid)); border-radius: 50px; transition: width 0.5s ease; }
.progress-fill.danger { background: linear-gradient(90deg, var(--red-dark), var(--red)); }

/* ── Badges & Tags ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  border-radius: 50px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-blue { background: var(--blue-light); color: var(--blue-dark); }
.badge-red { background: var(--red-light); color: var(--red-dark); }
.badge-green { background: #dcfce7; color: #166534; }
.badge-gray { background: #f1f5f9; color: var(--gray-400); }

/* ── List Items ── */
.list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--blue-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.list-icon.red { background: var(--red-light); }
.list-meta { flex: 1; min-width: 0; }
.list-title { font-weight: 600; font-size: 0.9375rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-sub { font-size: 0.75rem; color: var(--gray-400); margin-top: 2px; }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--gray-100); border-radius: 12px; }
.tab {
  flex: 1;
  padding: 10px 8px;
  border-radius: 10px;
  font-size: 0.8125rem;
  font-weight: 600;
  text-align: center;
  color: var(--gray-400);
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
}
.tab.active { background: white; color: var(--blue-dark); box-shadow: var(--shadow-sm); }

/* ── Toasts ── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--gray-900);
  color: white;
  padding: 12px 24px;
  border-radius: 50px;
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 999;
  opacity: 0;
  transition: all 0.3s;
  white-space: nowrap;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-success { background: #166534; }
.toast.toast-error { background: var(--red-dark); }

/* ── Network Banner ── */
.network-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--red);
  color: white;
  text-align: center;
  padding: 10px 16px;
  font-size: 0.8125rem;
  font-weight: 600;
  z-index: 999;
  transform: translateY(-100%);
  transition: transform 0.3s;
}
.network-banner.show { transform: translateY(0); }
.network-banner.online { background: #166534; }

/* ── Offline Toast ── */
.offline-toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px);
  left: 50%; transform: translateX(-50%);
  background: var(--gray-900);
  color: white;
  padding: 10px 20px;
  border-radius: 50px;
  font-size: 0.8125rem;
  z-index: 500;
  animation: fadeInUp 0.3s ease;
}
@keyframes fadeInUp { from { opacity: 0; transform: translateX(-50%) translateY(12px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ── Loading Skeleton ── */
.skeleton { background: linear-gradient(90deg, #f0f9ff 25%, #e0f2fe 50%, #f0f9ff 75%); background-size: 200%; animation: shimmer 1.5s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Section Headers ── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.see-all { font-size: 0.8125rem; color: var(--blue); font-weight: 600; }

/* ── Onboarding ── */
.onboard-step { display: none; }
.onboard-step.active { display: flex; flex-direction: column; }
.option-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.option-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: white;
}
.option-card.selected { border-color: var(--blue); background: var(--blue-light); }
.option-card .icon { font-size: 1.75rem; margin-bottom: 8px; }
.option-card .title { font-size: 0.875rem; font-weight: 600; }

/* ── Page transitions ── */
.page-enter { animation: pageIn 0.3s ease; }
@keyframes pageIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 3px; }

/* ── Safe areas (notched phones) ── */
@supports (padding: env(safe-area-inset-bottom)) {
  .bottom-nav { padding-bottom: env(safe-area-inset-bottom); height: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
}

/* ── Utility ── */
.text-blue { color: var(--blue); }
.text-red { color: var(--red); }
.text-white { color: white; }
.text-gray { color: var(--gray-400); }
.text-bold { font-weight: 700; }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ── Real Logo Integration ── */
.topbar-logo { display: flex; align-items: center; }
.topbar-logo img {
  height: 34px;
  width: auto;
  object-fit: contain;
  display: block;
  /* Ensure logo is crisp on all screens */
  image-rendering: -webkit-optimize-contrast;
}

/* Splash logo (auth page) */
.splash-logo {
  width: 160px;
  height: 160px;
  object-fit: contain;
  filter: drop-shadow(0 8px 28px rgba(0,0,0,0.35));
  animation: floatIn 0.8s ease;
}
@keyframes floatIn {
  from { opacity: 0; transform: translateY(-16px) scale(0.92); }
  to   { opacity: 1; transform: none; }
}

/* PWA Splash Screen (shown during load on mobile) */
.splash-screen {
  position: fixed; inset: 0;
  background: #0f172a url('../icons/splash-bg.jpg') center center / cover no-repeat;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease;
}
.splash-screen::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(160deg, rgba(15,23,42,0.85) 0%, rgba(2,132,199,0.80) 60%, rgba(14,165,233,0.70) 100%);
  z-index: 0;
}
.splash-screen > * { position: relative; z-index: 1; }
.splash-screen img { width: 180px; height: 180px; object-fit: contain; }
.splash-screen.hidden { opacity: 0; pointer-events: none; }

/* ════════════════════════════════════════════════════════
   DESKTOP RESPONSIVE — v7
   Extends layout to fill wider screens gracefully
   ════════════════════════════════════════════════════════ */

@media (min-width: 768px) {
  /* Widen the container so it's not cramped */
  .container { max-width: 720px; padding: 0 24px; }

  /* App shell: center content with a max width */
  .app-shell, .page-content, .main-content {
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
  }

  /* Bottom nav: switch to left sidebar on desktop */
  .bottom-nav {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 220px;
    height: 100vh;
    flex-direction: column;
    justify-content: flex-start;
    padding: 80px 0 24px;
    border-top: none;
    border-right: 1px solid var(--border);
    background: white;
    z-index: 100;
    gap: 4px;
  }

  .bottom-nav .nav-item {
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 12px 20px;
    border-radius: 10px;
    margin: 0 8px;
    min-width: unset;
    width: auto;
  }

  .bottom-nav .nav-label {
    font-size: 0.875rem;
    font-weight: 600;
    display: block !important;
  }

  /* Offset main content so it doesn't hide behind the sidebar */
  body.has-nav { padding-left: 220px; }

  /* Topbar: push right of sidebar */
  .topbar {
    left: 220px;
    width: calc(100% - 220px);
  }

  /* Auth page: constrain card width on desktop */
  .auth-card {
    border-radius: 28px !important;
    min-height: unset !important;
    max-width: 480px;
    margin: 0 auto 40px;
    padding: 40px 40px !important;
  }

  /* Sections: more breathing room */
  .section { padding: 24px 0; }

  /* Card grids: use more columns */
  .option-grid { grid-template-columns: repeat(3, 1fr); }

  /* Cards: wider */
  .card { padding: 24px; }

  /* Form layout: two-column on desktop */
  .form-row-desktop {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }

  /* Analyze page textarea: taller */
  .analyze-input { min-height: 200px; }

  /* Admin panel: full width */
  .admin-wrap { max-width: 1200px; margin: 0 auto; }

  /* Tables: ensure they don't overflow */
  .tbl-wrap { overflow-x: auto; }
}

@media (min-width: 1024px) {
  .container { max-width: 960px; }
  .app-shell, .page-content, .main-content { max-width: 1100px; }
  .option-grid { grid-template-columns: repeat(4, 1fr); }
}
