/* ============================================================
   KarmaFarmer — Common Styles
   Shared theme variables, resets, sidebar, footer, and utilities.
   Imported by every page.
   ============================================================ */

/* --- CSS Custom Properties (Theme) --- */
:root {
  /* Colors */
  --bg-primary: #0a0a0a;
  --bg-secondary: #111111;
  --bg-card: #141414;
  --bg-card-hover: #1a1a1a;
  --bg-input: #0d0d0d;

  /* Accent (Red) */
  --accent: #ef4444;
  --accent-hover: #dc2626;
  --accent-glow: rgba(239, 68, 68, 0.15);
  --accent-soft: rgba(239, 68, 68, 0.08);

  /* Text */
  --text-primary: #f5f5f5;
  --text-secondary: #a3a3a3;
  --text-muted: #525252;

  /* Borders */
  --border: #1e1e1e;
  --border-hover: #2e2e2e;
  --border-accent: rgba(239, 68, 68, 0.2);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px rgba(239, 68, 68, 0.1);

  /* Ease */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* Fonts */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Sidebar */
  --sidebar-width: 240px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}

a:hover {
  color: var(--accent-hover);
}

img {
  max-width: 100%;
  display: block;
}

button {
  cursor: pointer;
  font-family: inherit;
}

/* --- Background Effects --- */
.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}

.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
}

.bg-glow-1 {
  width: 500px;
  height: 500px;
  background: var(--accent-glow);
  top: -100px;
  right: -100px;
}

.bg-glow-2 {
  width: 400px;
  height: 400px;
  background: rgba(239, 68, 68, 0.06);
  bottom: -80px;
  left: -80px;
}

/* ============================================================
   SIDEBAR LAYOUT — used on all authenticated pages
   ============================================================ */

/* Flex container: sidebar + main content */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
  overflow-y: auto;
}

/* Logo area at top of sidebar */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px;
  text-decoration: none;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}

.sidebar-logo:hover {
  color: var(--text-primary);
}

/* Navigation links in the sidebar */
.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.2s var(--ease);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.sidebar-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-link.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.sidebar-link svg, .sidebar-link i {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Bottom section of sidebar (credits, account, logout) */
.sidebar-bottom {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Credits badge in sidebar */
.sidebar-credits {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  border: 1px solid var(--border-accent);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 6px;
}

.sidebar-credits svg, .sidebar-credits i {
  width: 16px;
  height: 16px;
}

/* Mobile sidebar toggle button (hidden on desktop) */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 60;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px;
  color: var(--text-secondary);
  transition: all 0.2s var(--ease);
}

.sidebar-toggle:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.sidebar-toggle svg {
  width: 20px;
  height: 20px;
}

/* Mobile sidebar overlay (hidden on desktop) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 40;
}

/* --- Main Content area (next to sidebar) --- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ============================================================
   LOGO (shared between sidebar and public header)
   ============================================================ */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
}

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: var(--radius-md);
  color: white;
}

.logo-icon svg {
  width: 20px;
  height: 20px;
}

.logo-text {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo-accent {
  color: var(--accent);
}

/* ============================================================
   PUBLIC HEADER — landing, login, pricing (unauthenticated)
   ============================================================ */
.pub-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(10, 10, 10, 0.8);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}

.pub-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.pub-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  transition: all 0.2s var(--ease);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: white;
  box-shadow: var(--shadow-glow);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-outline:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 32px 24px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ============================================================
   NAV LINKS (used in public header)
   ============================================================ */
.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.2s var(--ease);
}

.nav-link:hover,
.nav-link.active {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
  color: var(--accent);
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.hidden { display: none !important; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.text-center { text-align: center; }
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mt-48 { margin-top: 48px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }

/* ============================================================
   SCROLL ANIMATIONS
   ============================================================ */
.fade-in {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

.fade-in.visible:nth-child(2) { transition-delay: 0.1s; }
.fade-in.visible:nth-child(3) { transition-delay: 0.2s; }
.fade-in.visible:nth-child(4) { transition-delay: 0.3s; }

/* ============================================================
   SPINNER + ANIMATIONS
   ============================================================ */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ============================================================
   TOAST / ERROR / SUCCESS MESSAGES
   ============================================================ */
.error-message {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-radius: var(--radius-lg);
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  font-size: 0.875rem;
  animation: fadeInUp 0.3s var(--ease);
}

.error-message svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--accent);
}

.success-message {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-radius: var(--radius-lg);
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.2);
  color: #86efac;
  font-size: 0.875rem;
  animation: fadeInUp 0.3s var(--ease);
}

.success-message svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: #22c55e;
}

/* ============================================================
   RESPONSIVE — Mobile sidebar
   ============================================================ */
@media (max-width: 768px) {
  /* Sidebar off-screen by default on mobile */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s var(--ease);
  }

  /* Show sidebar when open */
  .sidebar.open {
    transform: translateX(0);
  }

  /* Show toggle button on mobile */
  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Show overlay on mobile when sidebar is open */
  .sidebar-overlay.open {
    display: block;
  }

  /* Main content takes full width on mobile */
  .main-content {
    margin-left: 0;
    padding-top: 56px; /* space for toggle button */
  }

  .pub-nav .nav-link {
    display: none;
  }

  .container {
    padding: 0 16px;
  }
}
