/* ==========================================================================
   CheapLogging Design System
   Modern, developer-focused aesthetic with distinct landing/app themes
   ========================================================================== */

/* Font imports */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ==========================================================================
   CSS Variables - Design Tokens
   ========================================================================== */

:root {
  /* Landing Page Theme (Dark) */
  --landing-bg: #0a0a0a;
  --landing-surface: #1a1a1a;
  --landing-surface-elevated: #252525;
  --landing-text: #f5f5f5;
  --landing-text-muted: #a0a0a0;
  --landing-accent-cyan: #00ffff;
  --landing-accent-lime: #d4ff00;
  --landing-accent-cyan-dim: #00cccc;
  --landing-border: #333;

  /* App Theme (Dark - Default) */
  --app-bg: #0a0a0a;
  --app-surface: #1a1a1a;
  --app-surface-elevated: #252525;
  --app-border: #333;
  --app-border-strong: #444;
  --app-text: #f5f5f5;
  --app-text-muted: #a0a0a0;
  --app-primary: #3b82f6;
  --app-primary-hover: #60a5fa;
  --app-danger: #ef4444;
  --app-danger-hover: #f87171;
  --app-success: #22c55e;
  --app-success-bg: #166534;
  --app-success-border: #22c55e;
  --app-success-text: #86efac;

  /* Terminal Colors */
  --terminal-bg: #1e1e1e;
  --terminal-text: #d4d4d4;
  --terminal-border: #333;
  --terminal-error: #f87171;
  --terminal-warn: #fbbf24;
  --terminal-info: #60a5fa;
  --terminal-debug: #9ca3af;
}

/* Light Mode Override */
body.light-mode {
  --app-bg: #ffffff;
  --app-surface: #f9fafb;
  --app-surface-elevated: #ffffff;
  --app-border: #e5e7eb;
  --app-border-strong: #d1d5db;
  --app-text: #111827;
  --app-text-muted: #6b7280;
  --app-primary: #2563eb;
  --app-primary-hover: #1d4ed8;
  --app-success-bg: #dcfce7;
  --app-success-border: #16a34a;
  --app-success-text: #065f46;

  /* Terminal Light Mode */
  --terminal-bg: #f8f9fa;
  --terminal-text: #1f2937;
  --terminal-border: #e5e7eb;
  --terminal-error: #dc2626;
  --terminal-warn: #d97706;
  --terminal-info: #2563eb;
  --terminal-debug: #6b7280;
}

:root {

  /* Typography Scale */
  --font-display: 'JetBrains Mono', 'SF Mono', Monaco, monospace;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Monaco, 'Courier New', monospace;

  --text-xs: 0.75rem;      /* 12px */
  --text-sm: 0.875rem;     /* 14px */
  --text-base: 1rem;       /* 16px */
  --text-lg: 1.125rem;     /* 18px */
  --text-xl: 1.25rem;      /* 20px */
  --text-2xl: 1.5rem;      /* 24px */
  --text-3xl: 1.875rem;    /* 30px */
  --text-4xl: 2.25rem;     /* 36px */
  --text-5xl: 3rem;        /* 48px */
  --text-6xl: 3.75rem;     /* 60px */

  /* Spacing Scale (4px base) */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */
  --space-20: 5rem;     /* 80px */
  --space-24: 6rem;     /* 96px */

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Animation */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.45, 0, 0.55, 1);
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 350ms;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
}

/* ==========================================================================
   Reset & Base Styles
   ========================================================================== */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  line-height: 1.6;
  color: var(--app-text);
  background: var(--app-bg);
}

/* Landing page body override */
body.landing {
  background: var(--landing-bg);
  color: var(--landing-text);
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: var(--space-4);
}

h1 { font-size: var(--text-5xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

p {
  margin-bottom: var(--space-4);
}

a {
  color: inherit;
  text-decoration: none;
  transition: opacity var(--duration-fast) var(--ease-out);
}

a:hover {
  opacity: 0.8;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* ==========================================================================
   Layout Primitives
   ========================================================================== */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-8);
}

.container-sm {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 var(--space-8);
}

.container-xs {
  max-width: 500px;
  margin: 0 auto;
  padding: 0 var(--space-8);
}

/* ==========================================================================
   Navigation - Landing Page
   ========================================================================== */

.landing-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: var(--space-6) 0;
  background: rgba(10, 10, 10, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--landing-border);
}

.landing-nav .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.landing-nav-brand {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--landing-text);
  letter-spacing: -0.02em;
}

.landing-nav-links {
  display: flex;
  gap: var(--space-8);
  align-items: center;
}

.landing-nav-links a {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--landing-text-muted);
  transition: color var(--duration-fast) var(--ease-out);
}

.landing-nav-links a:hover {
  color: var(--landing-accent-cyan);
  opacity: 1;
}

.landing-nav-links .btn {
  margin-left: var(--space-4);
}

/* ==========================================================================
   Navigation - App
   ========================================================================== */

.app-nav {
  background: var(--app-surface-elevated);
  border-bottom: 1px solid var(--app-border);
  padding: var(--space-4) 0;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

body:not(.light-mode) .app-nav {
  background: rgba(10, 10, 10, 0.95);
}

body.light-mode .app-nav {
  background: rgba(255, 255, 255, 0.95);
}

.app-nav .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.app-nav-brand {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--app-text);
}

.app-nav-links {
  display: flex;
  gap: var(--space-6);
  align-items: center;
}

.app-nav-links a {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--app-text-muted);
  transition: color var(--duration-fast) var(--ease-out);
}

.app-nav-links a:hover {
  color: var(--app-text);
  opacity: 1;
}

/* Profile Dropdown */
.profile-dropdown {
  position: relative;
}

.profile-button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--app-surface);
  border: 2px solid var(--app-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: var(--text-lg);
  transition: all var(--duration-fast) var(--ease-out);
  color: var(--app-text);
}

.profile-button:hover {
  border-color: var(--app-primary);
  background: var(--app-primary);
  color: white;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: var(--app-surface-elevated);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all var(--duration-fast) var(--ease-out);
  z-index: 1000;
}

.dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--app-text);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
}

.dropdown-item:first-child {
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.dropdown-item:last-child {
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.dropdown-item:hover {
  background: var(--app-surface);
}

.dropdown-divider {
  height: 1px;
  background: var(--app-border);
  margin: var(--space-2) 0;
}

.dropdown-item-icon {
  font-size: var(--text-base);
}

/* ==========================================================================
   Hero Section - Landing Page
   ========================================================================== */

.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-24) 0 var(--space-16);
  position: relative;
  overflow: hidden;
}

/* Animated grid background */
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--landing-border) 1px, transparent 1px),
    linear-gradient(90deg, var(--landing-border) 1px, transparent 1px);
  background-size: 50px 50px;
  opacity: 0.3;
  animation: grid-move 20s linear infinite;
}

@keyframes grid-move {
  0% { transform: translate(0, 0); }
  100% { transform: translate(50px, 50px); }
}

/* Grain texture overlay */
.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="4" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23noise)" opacity="0.05"/></svg>');
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 900px;
  animation: hero-fade-in 0.8s var(--ease-out);
}

@keyframes hero-fade-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-title {
  font-family: var(--font-display);
  font-size: var(--text-6xl);
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: var(--space-6);
  background: linear-gradient(135deg, var(--landing-text) 0%, var(--landing-accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.03em;
}

.hero-subtitle {
  font-size: var(--text-xl);
  color: var(--landing-text-muted);
  margin-bottom: var(--space-12);
  line-height: 1.6;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}

.hero-cta {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
  margin-bottom: var(--space-16);
  flex-wrap: wrap;
}

/* Code demo section in hero */
.hero-code {
  margin-top: var(--space-12);
  animation: hero-code-fade-in 1s var(--ease-out) 0.3s backwards;
}

@keyframes hero-code-fade-in {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.code-window {
  background: var(--landing-surface-elevated);
  border: 1px solid var(--landing-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  max-width: 700px;
  margin: 0 auto;
}

.code-window-header {
  background: var(--landing-surface);
  border-bottom: 1px solid var(--landing-border);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.code-window-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--landing-border);
}

.code-window-body {
  padding: var(--space-6);
}

.code-window pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.7;
  color: var(--landing-text);
  overflow-x: auto;
}

.code-window .code-comment {
  color: var(--landing-text-muted);
}

.code-window .code-keyword {
  color: var(--landing-accent-cyan);
}

.code-window .code-string {
  color: var(--landing-accent-lime);
}

/* ==========================================================================
   Features Grid - Landing Page
   ========================================================================== */

.features-section {
  padding: var(--space-24) 0;
  background: var(--landing-surface);
  position: relative;
}

.features-header {
  text-align: center;
  margin-bottom: var(--space-16);
}

.features-header h2 {
  font-family: var(--font-display);
  font-size: var(--text-4xl);
  margin-bottom: var(--space-4);
}

.features-header p {
  color: var(--landing-text-muted);
  font-size: var(--text-lg);
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-8);
  margin-bottom: var(--space-16);
}

.feature-card {
  background: var(--landing-bg);
  border: 1px solid var(--landing-border);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  transition: all var(--duration-normal) var(--ease-out);
  opacity: 0;
  transform: translateY(30px);
}

.feature-card.visible {
  opacity: 1;
  transform: translateY(0);
  animation: feature-fade-in var(--duration-slow) var(--ease-out);
}

@keyframes feature-fade-in {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.feature-card:hover {
  transform: translateY(-8px);
  border-color: var(--landing-accent-cyan);
  box-shadow: 0 20px 40px rgba(0, 255, 255, 0.1);
}

.feature-icon {
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-6);
  font-size: var(--text-4xl);
}

.feature-card h3 {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-3);
}

.feature-card p {
  color: var(--landing-text-muted);
  font-size: var(--text-base);
  line-height: 1.7;
  margin-bottom: 0;
}

/* ==========================================================================
   Pricing Section - Landing Page
   ========================================================================== */

.pricing-section {
  padding: var(--space-24) 0;
  text-align: center;
}

.pricing-comparison {
  display: inline-flex;
  align-items: center;
  gap: var(--space-8);
  padding: var(--space-8);
  background: var(--landing-surface);
  border: 1px solid var(--landing-border);
  border-radius: var(--radius-lg);
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  margin-bottom: var(--space-8);
}

.pricing-old {
  color: var(--landing-text-muted);
  text-decoration: line-through;
}

.pricing-new {
  color: var(--landing-accent-lime);
  font-weight: 700;
}

.pricing-details {
  color: var(--landing-text-muted);
  max-width: 600px;
  margin: 0 auto;
  font-size: var(--text-base);
  line-height: 1.7;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  padding: var(--space-12) 0;
  text-align: center;
  border-top: 1px solid var(--landing-border);
  margin-top: var(--space-24);
}

.landing .footer {
  background: var(--landing-bg);
  color: var(--landing-text-muted);
}

.footer-links {
  display: flex;
  gap: var(--space-6);
  justify-content: center;
  margin-bottom: var(--space-4);
}

.footer p {
  margin: 0;
  font-size: var(--text-sm);
}

.footer nav {
  margin-top: var(--space-4);
  font-size: var(--text-sm);
}

.footer nav a {
  color: var(--landing-accent-cyan);
  transition: color var(--duration-fast) var(--ease-out);
}

.footer nav a:hover {
  color: var(--landing-accent-lime);
  opacity: 1;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 500;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
}

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

/* Button variants */
.btn-primary {
  background: var(--app-primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  background: var(--app-primary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  opacity: 1;
}

.btn-secondary {
  background: var(--app-surface);
  color: var(--app-text);
  border: 1px solid var(--app-border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--app-border);
  opacity: 1;
}

.btn-danger {
  background: var(--app-danger);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: var(--app-danger-hover);
  opacity: 1;
}

.btn-ghost {
  background: transparent;
  color: var(--app-text-muted);
  border: 1px solid transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--app-surface);
  border-color: var(--app-border);
  opacity: 1;
}

/* Landing page button variants */
.btn-landing-primary {
  background: var(--landing-accent-cyan);
  color: var(--landing-bg);
  font-weight: 600;
  padding: var(--space-4) var(--space-8);
  box-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
}

.btn-landing-primary:hover:not(:disabled) {
  background: var(--landing-accent-lime);
  box-shadow: 0 0 30px rgba(212, 255, 0, 0.4);
  transform: translateY(-2px);
  opacity: 1;
}

.btn-landing-secondary {
  background: transparent;
  color: var(--landing-text);
  border: 1px solid var(--landing-border);
  padding: var(--space-4) var(--space-8);
}

.btn-landing-secondary:hover:not(:disabled) {
  border-color: var(--landing-accent-cyan);
  color: var(--landing-accent-cyan);
  opacity: 1;
}

/* Button sizes */
.btn-sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
}

.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-lg);
}

.btn-block {
  width: 100%;
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form-group {
  margin-bottom: var(--space-6);
}

.form-group label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: 500;
  font-size: var(--text-sm);
  color: var(--app-text);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-family: var(--font-body);
  background: var(--app-bg);
  color: var(--app-text);
  transition: all var(--duration-fast) var(--ease-out);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--app-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

/* Auth form specific */
.auth-form {
  max-width: 450px;
  margin: var(--space-16) auto;
  padding: var(--space-10);
  background: var(--landing-surface);
  border: 1px solid var(--landing-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  animation: auth-form-appear 0.4s var(--ease-out);
}

@keyframes auth-form-appear {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-form h2 {
  text-align: center;
  margin-bottom: var(--space-8);
  color: var(--landing-text);
  font-family: var(--font-display);
}

.auth-form .form-group label {
  color: var(--landing-text);
}

.auth-form .form-group input {
  background: var(--landing-bg);
  border-color: var(--landing-border);
  color: var(--landing-text);
}

.auth-form .form-group input:focus {
  border-color: var(--landing-accent-cyan);
  box-shadow: 0 0 0 3px rgba(0, 255, 255, 0.1);
}

.auth-form-footer {
  text-align: center;
  margin-top: var(--space-6);
  font-size: var(--text-sm);
  color: var(--landing-text-muted);
}

.auth-form-footer a {
  color: var(--landing-accent-cyan);
}

/* Query form - Compact single-line search */
.query-form {
  background: var(--app-surface-elevated);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--app-border);
  margin-bottom: var(--space-6);
}

.search-bar {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}

.time-range-selector {
  position: relative;
  min-width: 180px;
}

.time-range-button {
  padding: var(--space-2) var(--space-4);
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--app-text);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  width: 100%;
  font-family: var(--font-body);
}

.time-range-button:hover {
  border-color: var(--app-primary);
  background: var(--app-bg);
}

.time-range-button::after {
  content: '▼';
  font-size: 0.7em;
  opacity: 0.6;
}

.time-range-dropdown {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  right: 0;
  background: var(--app-surface-elevated);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all var(--duration-fast) var(--ease-out);
  z-index: 1000;
  max-height: 400px;
  overflow-y: auto;
}

.time-range-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.time-range-option {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--app-text);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
}

.time-range-option:hover {
  background: var(--app-surface);
}

.time-range-option.selected {
  background: var(--app-primary);
  color: white;
}

.time-range-divider {
  height: 1px;
  background: var(--app-border);
  margin: var(--space-2) 0;
}

.custom-time-inputs {
  padding: var(--space-4);
  display: none;
  border-top: 1px solid var(--app-border);
  background: var(--app-surface);
}

.custom-time-inputs.show {
  display: block;
}

.custom-time-inputs input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  background: var(--app-bg);
  color: var(--app-text);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.custom-time-inputs input:hover {
  border-color: var(--app-primary);
}

.custom-time-inputs input:focus {
  outline: none;
  border-color: var(--app-primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* ==========================================================================
   Flatpickr Calendar Styling (Dark Mode)
   ========================================================================== */

.flatpickr-calendar {
  background: var(--app-surface-elevated);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  font-family: var(--font-body);
}

.flatpickr-months {
  background: var(--app-surface-elevated);
  border-bottom: 1px solid var(--app-border);
}

.flatpickr-month {
  color: var(--app-text);
}

.flatpickr-current-month {
  color: var(--app-text);
}

.flatpickr-current-month .flatpickr-monthDropdown-months {
  background: var(--app-surface);
  color: var(--app-text);
  border: 1px solid var(--app-border);
}

.flatpickr-current-month .flatpickr-monthDropdown-months:hover {
  background: var(--app-bg);
}

.flatpickr-current-month input.cur-year {
  color: var(--app-text);
  background: var(--app-surface);
  border: 1px solid var(--app-border);
}

.flatpickr-weekdays {
  background: var(--app-surface-elevated);
  border-bottom: 1px solid var(--app-border);
}

.flatpickr-weekday {
  color: var(--app-text-muted);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.flatpickr-days {
  background: var(--app-surface-elevated);
}

.flatpickr-day {
  color: var(--app-text);
  border: none;
  border-radius: var(--radius-sm);
}

.flatpickr-day:hover {
  background: var(--app-surface);
  border-color: var(--app-border);
}

.flatpickr-day.today {
  border-color: var(--app-primary);
  background: rgba(59, 130, 246, 0.1);
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
  background: var(--app-primary);
  border-color: var(--app-primary);
  color: white;
}

.flatpickr-day.selected:hover,
.flatpickr-day.startRange:hover,
.flatpickr-day.endRange:hover {
  background: var(--app-primary-hover);
  border-color: var(--app-primary-hover);
}

.flatpickr-day.inRange {
  background: rgba(59, 130, 246, 0.2);
  border-color: transparent;
  box-shadow: none;
}

.flatpickr-day.disabled,
.flatpickr-day.disabled:hover {
  color: var(--app-text-muted);
  opacity: 0.3;
}

.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
  color: var(--app-text-muted);
  opacity: 0.4;
}

.flatpickr-time {
  border-top: 1px solid var(--app-border);
  background: var(--app-surface-elevated);
}

.flatpickr-time input {
  color: var(--app-text);
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-sm);
}

.flatpickr-time input:hover,
.flatpickr-time input:focus {
  background: var(--app-bg);
}

.flatpickr-time .flatpickr-time-separator {
  color: var(--app-text-muted);
}

.flatpickr-time .flatpickr-am-pm {
  color: var(--app-text);
  background: var(--app-surface);
  border: 1px solid var(--app-border);
}

.flatpickr-time .flatpickr-am-pm:hover {
  background: var(--app-bg);
}

.numInputWrapper:hover {
  background: rgba(59, 130, 246, 0.05);
}

.arrowUp,
.arrowDown {
  border-bottom-color: var(--app-text);
}

.arrowDown {
  border-top-color: var(--app-text);
}

.flatpickr-prev-month,
.flatpickr-next-month {
  color: var(--app-text);
  fill: var(--app-text);
}

.flatpickr-prev-month:hover,
.flatpickr-next-month:hover {
  color: var(--app-primary);
  fill: var(--app-primary);
}

/* Light mode overrides */
body.light-mode .flatpickr-day.inRange {
  background: rgba(37, 99, 235, 0.1);
}

body.light-mode .flatpickr-day.today {
  background: rgba(37, 99, 235, 0.05);
}

.search-input-wrapper {
  flex: 1;
  position: relative;
}

.search-input-wrapper input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  padding-left: var(--space-10);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  background: var(--app-bg);
  color: var(--app-text);
  transition: all var(--duration-fast) var(--ease-out);
}

.search-input-wrapper input:focus {
  outline: none;
  border-color: var(--app-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--app-text-muted);
  font-size: var(--text-base);
  pointer-events: none;
}

/* ==========================================================================
   Alerts & Notifications
   ========================================================================== */

.alert {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-6);
  font-size: var(--text-sm);
  animation: alert-slide-down 0.3s var(--ease-out);
}

@keyframes alert-slide-down {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.alert-success {
  background: var(--app-success-bg);
  border: 1px solid var(--app-success-border);
  color: var(--app-success-text);
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--app-danger);
  color: #fca5a5;
}

body.light-mode .alert-error {
  background: #fee2e2;
  color: #991b1b;
}

/* ==========================================================================
   Terminal Logs Display
   ========================================================================== */

.terminal-container {
  background: var(--terminal-bg);
  border: 1px solid var(--terminal-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  margin: var(--space-8) 0;
}

.terminal-header {
  background: rgba(0, 0, 0, 0.05);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--terminal-border);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--app-text-muted);
}

body:not(.light-mode) .terminal-header {
  background: #161616;
}

.terminal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.terminal-dot:nth-child(1) { background: #ff5f56; }
.terminal-dot:nth-child(2) { background: #ffbd2e; }
.terminal-dot:nth-child(3) { background: #27c93f; }

/* Light mode terminal dots - slightly muted */
body.light-mode .terminal-dot:nth-child(1) { background: #ed6a5e; }
body.light-mode .terminal-dot:nth-child(2) { background: #f4bf4f; }
body.light-mode .terminal-dot:nth-child(3) { background: #61c554; }

.terminal-logs {
  padding: var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.7;
  color: var(--terminal-text);
  overflow-x: auto;
  max-height: 70vh;
  overflow-y: auto;
}

.terminal-logs::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.terminal-logs::-webkit-scrollbar-track {
  background: var(--terminal-bg);
}

.terminal-logs::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 5px;
}

.terminal-logs::-webkit-scrollbar-thumb:hover {
  background: #555;
}

.log-entry {
  display: block;
  padding: var(--space-2) 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background var(--duration-fast) var(--ease-out);
}

.log-entry:hover {
  background: rgba(255, 255, 255, 0.03);
}

.log-entry:last-child {
  border-bottom: none;
}

/* Severity colors */
.severity-error,
.severity-fatal {
  color: var(--terminal-error);
  font-weight: 600;
}

.severity-warn {
  color: var(--terminal-warn);
  font-weight: 600;
}

.severity-info {
  color: var(--terminal-info);
  font-weight: 600;
}

.severity-debug,
.severity-trace {
  color: var(--terminal-debug);
}

/* Results info */
.results-info {
  margin-bottom: var(--space-4);
  padding: var(--space-4);
  background: var(--app-surface);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--app-text-muted);
}

/* ==========================================================================
   Tables
   ========================================================================== */

.keys-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--app-surface-elevated);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--app-border);
}

.keys-table th,
.keys-table td {
  padding: var(--space-4);
  text-align: left;
  font-size: var(--text-sm);
}

.keys-table th {
  background: var(--app-surface);
  font-weight: 600;
  color: var(--app-text);
  border-bottom: 2px solid var(--app-border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: var(--text-xs);
}

.keys-table td {
  border-bottom: 1px solid var(--app-border);
}

.keys-table tr:last-child td {
  border-bottom: none;
}

.keys-table tbody tr {
  transition: background var(--duration-fast) var(--ease-out);
}

.keys-table tbody tr:hover {
  background: var(--app-surface);
}

.api-key-display {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--app-text-muted);
}

/* ==========================================================================
   Settings Page
   ========================================================================== */

.settings-section {
  background: var(--app-surface-elevated);
  padding: var(--space-8);
  margin-bottom: var(--space-8);
  border-radius: var(--radius-lg);
  border: 1px solid var(--app-border);
}

.settings-section h2 {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 2px solid var(--app-border);
}

/* Code blocks in setup instructions */
.code-block {
  background: var(--terminal-bg);
  color: var(--terminal-text);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  margin: var(--space-4) 0;
  overflow-x: auto;
  border: 1px solid var(--terminal-border);
  position: relative;
}

.code-block pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) var(--space-4);
  background: #161616;
  border-bottom: 1px solid var(--terminal-border);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: #808080;
}

.copy-btn {
  padding: var(--space-1) var(--space-3);
  background: transparent;
  border: 1px solid var(--terminal-border);
  color: var(--terminal-text);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.copy-btn:hover {
  background: var(--terminal-border);
}

/* ==========================================================================
   Empty States
   ========================================================================== */

.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-8);
  background: var(--app-surface);
  border-radius: var(--radius-lg);
  border: 2px dashed var(--app-border);
  margin: var(--space-8) 0;
}

.empty-state-icon {
  font-size: var(--text-6xl);
  margin-bottom: var(--space-6);
  opacity: 0.3;
}

.empty-state h3 {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-4);
}

.empty-state p {
  color: var(--app-text-muted);
  margin-bottom: var(--space-8);
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

/* ==========================================================================
   Loading States
   ========================================================================== */

.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator {
  display: block;
}

.htmx-request.btn .btn-text {
  display: none;
}

.htmx-request.btn .btn-loading {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.htmx-request.btn .btn-loading::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.btn-loading {
  display: none;
}

/* Results loading overlay */
.results-loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.results-loading.htmx-request {
  display: flex;
}

.loading-spinner-overlay {
  background: var(--app-surface-elevated);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  box-shadow: var(--shadow-xl);
  text-align: center;
  min-width: 300px;
}

.loading-spinner-overlay .spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-4);
  border: 4px solid var(--app-border);
  border-top-color: var(--app-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-spinner-overlay p {
  color: var(--app-text-muted);
  font-size: var(--text-sm);
  margin: 0;
}

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

/* ==========================================================================
   Utilities
   ========================================================================== */

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-muted { color: var(--app-text-muted); }

.mt-4 { margin-top: var(--space-4); }
.mt-8 { margin-top: var(--space-8); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-8 { margin-bottom: var(--space-8); }

/* Visually hidden - accessible to screen readers */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
  /* Navigation mobile adjustments */
  .landing-nav {
    padding: var(--space-3) 0;
  }

  .landing-nav .container {
    padding: 0 var(--space-4);
  }

  .landing-nav-brand {
    font-size: var(--text-base);
  }

  .landing-nav-links {
    gap: var(--space-3);
  }

  .landing-nav-links .btn {
    margin-left: 0;
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-xs);
  }

  /* Hero section mobile */
  .hero {
    min-height: auto;
    padding: calc(80px + var(--space-8)) var(--space-4) var(--space-12);
  }

  .hero-content {
    max-width: 100%;
  }

  .hero-title {
    font-size: var(--text-3xl);
    line-height: 1.15;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .hero-subtitle {
    font-size: var(--text-base);
    line-height: 1.5;
    padding: 0 var(--space-2);
  }

  .hero-subtitle br {
    display: none;
  }

  .hero-cta {
    flex-direction: column;
    gap: var(--space-3);
    margin-bottom: var(--space-8);
  }

  .hero-cta .btn {
    width: 100%;
  }

  .btn-lg {
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-base);
  }

  /* Code window mobile */
  .hero-code {
    margin-top: var(--space-8);
  }

  .code-window {
    max-width: 100%;
    border-radius: var(--radius-md);
  }

  .code-window-body {
    padding: var(--space-3);
  }

  .code-window pre {
    font-size: var(--text-xs);
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
  }

  /* Features section mobile */
  .features-section {
    padding: var(--space-12) 0;
  }

  .features-header {
    margin-bottom: var(--space-8);
    padding: 0 var(--space-2);
  }

  .features-header h2 {
    font-size: var(--text-2xl);
  }

  .features-header p {
    font-size: var(--text-base);
  }

  .features-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .feature-card {
    padding: var(--space-6);
  }

  .feature-card h3 {
    font-size: var(--text-xl);
  }

  .feature-card p {
    font-size: var(--text-sm);
  }

  /* Pricing section mobile */
  .pricing-section {
    padding: var(--space-12) 0;
  }

  .pricing-comparison {
    gap: var(--space-4);
    padding: var(--space-6);
    font-size: var(--text-2xl);
  }

  .pricing-details {
    padding: 0 var(--space-2);
    font-size: var(--text-sm);
  }

  .pricing-details br {
    display: none;
  }

  /* Form adjustments */
  .form-row {
    grid-template-columns: 1fr;
  }

  .search-controls {
    flex-direction: column;
    align-items: stretch;
  }

  /* Footer mobile */
  .footer {
    padding: var(--space-8) 0;
    margin-top: var(--space-12);
  }
}

@media (max-width: 480px) {
  .container,
  .container-sm,
  .container-xs {
    padding: 0 var(--space-4);
  }

  /* Even smaller hero on very small screens */
  .hero {
    padding: calc(70px + var(--space-6)) var(--space-3) var(--space-8);
  }

  .hero-title {
    font-size: var(--text-2xl);
  }

  .hero-subtitle {
    font-size: var(--text-sm);
  }

  /* Smaller nav on tiny screens */
  .landing-nav-brand {
    font-size: var(--text-sm);
  }

  .landing-nav-links a:not(.btn) {
    font-size: var(--text-xs);
  }

  /* Code window tiny screens */
  .code-window pre {
    font-size: 10px;
  }

  /* Features on tiny screens */
  .features-header h2 {
    font-size: var(--text-xl);
  }

  .feature-icon {
    font-size: var(--text-2xl);
    width: 36px;
    height: 36px;
    margin-bottom: var(--space-4);
  }

  .feature-card h3 {
    font-size: var(--text-lg);
  }

  /* Pricing tiny screens */
  .pricing-comparison {
    flex-direction: column;
    gap: var(--space-3);
    font-size: var(--text-xl);
  }
}
