/* ReelCraftAI — Custom styles supplementing Tailwind */

:root {
  --accent: #6c63ff;
  --accent-glow: rgba(108, 99, 255, 0.3);
  --surface: #0f1117;
  --surface-card: #161b27;
  --surface-border: #1e2535;
  --sidebar-width: 256px;
  --topbar-height: 56px;
}

/* ─── Base ─────────────────────────────────────── */
body {
  overflow-x: hidden; /* Prevent horizontal scroll glitches on mobile */
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--surface-border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #2e3a50; }

/* ─── Touch optimization — min 44px for all interactive elements ── */
button, a, select, input[type="submit"], input[type="button"] {
  min-height: 44px;
}
/* Compact icon-only buttons keep their height naturally through line-height/padding */
.btn-icon-sm {
  min-height: 32px;
}

/* ─── Drop zone active state ─────────────────────── */
.drop-active {
  border-color: var(--accent) !important;
  background-color: rgba(108, 99, 255, 0.08) !important;
  box-shadow: 0 0 0 4px rgba(108, 99, 255, 0.12);
}

/* ─── Model card selected state ──────────────────── */
.model-card.selected {
  border-color: var(--accent);
  background-color: rgba(108, 99, 255, 0.08);
  box-shadow: 0 0 0 2px rgba(108, 99, 255, 0.25);
}

/* ─── Skeleton shimmer for loading cards ─────────── */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: linear-gradient(90deg, #161b27 25%, #1e2535 50%, #161b27 75%);
  background-size: 800px 100%;
  animation: shimmer 1.6s infinite;
}

/* ─── Video card fade-in ──────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.job-card { animation: fadeUp 0.35s ease forwards; }

/* ─── Spinning loader icon ───────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.8s linear infinite; }

/* ─── Auth tab active ─────────────────────────────── */
.tab-active {
  background-color: var(--accent) !important;
  color: white !important;
}

/* ══════════════════════════════════════════════════
   MOBILE SIDEBAR / HAMBURGER DRAWER
   ══════════════════════════════════════════════════ */

/* Sidebar overlay (mobile) */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(2px);
}
#sidebar-overlay.active {
  display: block;
}

/* Sidebar base: always full-height, positioned fixed on mobile */
#app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: var(--sidebar-width);
  z-index: 50;
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}

#app-sidebar.open {
  transform: translateX(0);
}

/* Mobile top bar — sticky with credits widget */
#mobile-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-height);
  background: var(--surface-card);
  border-bottom: 1px solid var(--surface-border);
  padding: 0 16px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Hamburger button */
#hamburger-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--surface-border);
  background: transparent;
  color: #8892a8;
  cursor: pointer;
  min-height: 40px; /* override touch target rule for this compact button */
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
}
#hamburger-btn:hover {
  background: var(--surface-border);
  color: #fff;
}

/* Mobile credits pill in topbar */
#mobile-credits-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(108, 99, 255, 0.12);
  border: 1px solid rgba(108, 99, 255, 0.25);
  border-radius: 99px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #8b83ff;
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS — MOBILE FIRST
   ══════════════════════════════════════════════════ */

/* ── Desktop (> 1024px) — sidebar always visible, full flex-row layout ── */
@media (min-width: 1025px) {
  /* Sidebar: part of normal flow, never a fixed overlay */
  #app-sidebar {
    position: sticky !important;
    top: 0;
    transform: translateX(0) !important;
    flex-shrink: 0;
    width: var(--sidebar-width);
    height: 100vh;
    overflow-y: auto;
  }

  #mobile-topbar {
    display: none !important;
  }

  #sidebar-overlay {
    display: none !important;
  }

  #hamburger-btn {
    display: none !important;
  }

  /* Workspace: horizontal flex row — sidebar left, content right */
  #workspace-dashboard {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch;
    min-height: 100vh;
  }

  /* Main content fills the rest of the row */
  #workspace-dashboard > main {
    flex: 1;
    min-width: 0;   /* prevent flex blowout */
    overflow-y: auto;
    height: 100vh;
  }
}

/* ── Tablet (481px – 1024px) ────────────────────── */
@media (max-width: 1024px) {
  /* Show mobile topbar */
  #mobile-topbar {
    display: flex;
  }

  /* Main content needs top padding since topbar is sticky */
  #main-workspace,
  #billing-panel {
    padding-top: 0;
  }

  /* Workspace: column layout, sidebar is drawer */
  #workspace-dashboard {
    flex-direction: column;
  }

  /* Grid stacking: billing plans */
  #billing-plans-grid {
    grid-template-columns: 1fr !important;
  }

  /* Grid stacking: top-up packs → 2 columns on tablet */
  #billing-packs-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Generation form: single column on tablet */
  .generation-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ── Mobile (< 480px) ────────────────────────────── */
@media (max-width: 480px) {
  /* Everything stacks to 1 column */
  #billing-packs-grid {
    grid-template-columns: 1fr !important;
  }

  #billing-plans-grid {
    grid-template-columns: 1fr !important;
  }

  /* Jobs grid: single column */
  #jobs-grid {
    grid-template-columns: 1fr !important;
  }

  /* Reduce horizontal padding on small screens */
  .section-pad {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  /* Auth card padding */
  #auth-card > div {
    padding: 24px 20px;
    margin: 16px;
  }

  /* Wallet widget: stack vertically */
  .wallet-inner {
    flex-direction: column !important;
    align-items: flex-start !important;
  }

  /* Model picker: 1 column on very small screens */
  #model-picker {
    grid-template-columns: 1fr !important;
  }
}

/* ── Shared tablet+mobile overrides ─────────────── */
@media (max-width: 1024px) {
  /* Header inside main panels: adjust for drawer presence */
  #billing-panel header,
  #main-workspace header {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Section padding adjustments */
  #main-workspace section,
  #billing-panel > div > div {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Billing panel internal content */
  #billing-panel .flex-1.p-6 {
    padding: 16px;
  }
}
