/* ==========================================================================
   Igapó Things - Design System & UI Styles (Dark & Light Themes)
   ========================================================================== */

/* 1. Default (Light Mode) Theme Variables */
:root {
  color-scheme: light;
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 0.98);
  --bg-input: #f1f5f9;
  --bg-modal: #ffffff;
  --bg-box: #f1f5f9;
  --code-bg: #0f172a;
  --modal-backdrop: rgba(15, 23, 42, 0.5);
  
  --border-subtle: rgba(15, 23, 42, 0.08);
  --border-hover: rgba(99, 102, 241, 0.45);
  --border-focus: #6366f1;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;
  
  --primary-color: #6366f1;
  --primary-hover: #4f46e5;
  --primary-start: #38bdf8;
  --primary-mid: #6366f1;
  --primary-end: #a855f7;
  --primary-gradient: linear-gradient(135deg, #06b6d4 0%, #6366f1 50%, #a855f7 100%);
  --primary-glow: rgba(99, 102, 241, 0.35);
  
  --accent-cyan: #06b6d4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.2);
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.2);
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-rose-glow: rgba(244, 63, 94, 0.25);

  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', var(--font-sans);
  --font-mono: 'JetBrains Mono', 'Fira Code', Menlo, monospace;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.05);
  --shadow-modal: 0 25px 50px -12px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.15);
  
  --transition-fast: 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 0.28s cubic-bezier(0.16, 1, 0.3, 1);

  --glow-1: radial-gradient(circle, rgba(99, 102, 241, 0.15), transparent 70%);
  --glow-2: radial-gradient(circle, rgba(6, 182, 212, 0.12), transparent 70%);
  --glow-3: radial-gradient(circle, rgba(168, 85, 247, 0.08), transparent 70%);
}

/* Explicit Light Theme */
[data-theme="light"] {
  color-scheme: light;
}

/* 2. Optional Dark Theme Variables */
[data-theme="dark"] {
  color-scheme: dark;
  --bg-primary: #07090e;
  --bg-secondary: #0e131f;
  --bg-card: rgba(16, 22, 36, 0.75);
  --bg-card-hover: rgba(23, 32, 52, 0.85);
  --bg-input: rgba(10, 14, 24, 0.7);
  --bg-modal: #0d121d;
  --bg-box: rgba(0, 0, 0, 0.35);
  --code-bg: #060911;
  --modal-backdrop: rgba(4, 6, 11, 0.75);
  
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-hover: rgba(99, 102, 241, 0.4);
  --border-focus: #6366f1;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0b0f19;
  
  --shadow-card: 0 16px 36px -8px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
  --shadow-modal: 0 25px 60px -15px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1);
  --shadow-glow: 0 0 25px var(--primary-glow);
  
  --glow-1: radial-gradient(circle, rgba(99, 102, 241, 0.3), transparent 70%);
  --glow-2: radial-gradient(circle, rgba(6, 182, 212, 0.25), transparent 70%);
  --glow-3: radial-gradient(circle, rgba(168, 85, 247, 0.15), transparent 70%);
}

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

html {
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Ambient dynamic background lighting */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(140px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  transition: all 0.5s ease;
}

.glow-top-left {
  top: -150px;
  left: -100px;
  width: 550px;
  height: 550px;
  background: var(--glow-1);
}

.glow-bottom-right {
  bottom: -200px;
  right: -100px;
  width: 650px;
  height: 650px;
  background: var(--glow-2);
}

.glow-mid {
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 400px;
  background: var(--glow-3);
}

/* Grid layout */
.app-layout {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.app-main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Header & Navigation */
.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.85rem 1.5rem;
  min-height: 72px;
  box-sizing: border-box;
  background: var(--bg-card);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  flex-wrap: wrap;
  transition: all var(--transition-normal);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  height: 42px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #06b6d4 0%, #6366f1 50%, #8b5cf6 100%);
  background-size: 200% 200%;
  background-position: 0% 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px var(--primary-glow), inset 0 1px 1px rgba(255, 255, 255, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  flex-shrink: 0;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  cursor: pointer;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.35s ease,
              background-position 0.6s ease,
              border-color 0.3s ease;
  box-sizing: border-box;
}

/* Ambient glow aura */
.brand-logo::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: linear-gradient(135deg, #06b6d4, #6366f1, #d946ef);
  z-index: -1;
  opacity: 0;
  filter: blur(8px);
  transition: opacity 0.35s ease, filter 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}

/* Prismatic sheen light reflection sweep */
.brand-logo::after {
  content: '';
  position: absolute;
  top: -60%;
  left: -70%;
  width: 50%;
  height: 220%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  transform: rotate(25deg) translateX(-100%);
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transition: transform 0.65s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.brand-logo:hover {
  transform: translateY(-2.5px) scale(1.07);
  background-position: 100% 50%;
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 10px 24px -2px rgba(99, 102, 241, 0.6),
              0 0 20px rgba(6, 182, 212, 0.45),
              inset 0 1px 2px rgba(255, 255, 255, 0.6);
}

.brand-logo:hover::before {
  opacity: 0.85;
  filter: blur(12px);
  transform: scale(1.1);
}

.brand-logo:hover::after {
  opacity: 1;
  transform: rotate(25deg) translateX(360%);
}

.brand-logo:active {
  transform: translateY(1px) scale(0.96);
  box-shadow: 0 2px 8px var(--primary-glow), inset 0 1px 1px rgba(0, 0, 0, 0.2);
  transition-duration: 0.1s;
}

.brand-logo:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--bg-card),
              0 0 0 5px var(--primary-color),
              0 8px 24px var(--primary-glow);
}

/* SVG Telemetry waves & emitter pulse on hover */
.brand-logo svg {
  position: relative;
  z-index: 1;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.35s ease;
}

.brand-logo:hover svg {
  transform: scale(1.08) translateY(-0.5px);
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.8));
}

.brand-logo:hover svg line {
  animation: logoEmitterGlow 1.2s ease-in-out infinite;
}

.brand-logo:hover svg path:nth-of-type(3) {
  animation: logoWaveRadiate 1.2s ease-in-out infinite;
  animation-delay: 0.08s;
}

.brand-logo:hover svg path:nth-of-type(1) {
  animation: logoWaveRadiate 1.2s ease-in-out infinite;
  animation-delay: 0.18s;
}

.brand-logo:hover svg path:nth-of-type(2) {
  animation: logoWaveRadiate 1.2s ease-in-out infinite;
  animation-delay: 0.28s;
}

@keyframes logoEmitterGlow {
  0%, 100% {
    stroke: #ffffff;
    filter: drop-shadow(0 0 2px #fff);
  }
  50% {
    stroke: #a5f3fc;
    filter: drop-shadow(0 0 6px #38bdf8);
  }
}

@keyframes logoWaveRadiate {
  0% {
    opacity: 0.4;
    stroke: #ffffff;
  }
  50% {
    opacity: 1;
    stroke: #e0e7ff;
    filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.9));
  }
  100% {
    opacity: 0.75;
    stroke: #ffffff;
  }
}

@media (prefers-reduced-motion: reduce) {
  .brand-logo,
  .brand-logo::before,
  .brand-logo::after,
  .brand-logo svg,
  .brand-logo svg line,
  .brand-logo svg path {
    transition: none !important;
    animation: none !important;
    transform: none !important;
  }
}

.brand-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 42px;
}

.brand-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  line-height: 1.2;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--primary-color);
  line-height: 1.2;
  text-decoration: none;
  margin: 0;
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1.2;
  margin: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  height: 42px;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 10px #10b981;
  animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  height: 40px;
  min-height: 40px;
  padding: 0 1.15rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  outline: none;
  box-sizing: border-box;
}

.btn-primary {
  background: var(--primary-color);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
  transform: translateY(-1px);
}

.btn-primary:active {
  background: #4338ca;
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-box);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.12);
  color: #e11d48;
  border: 1px solid rgba(244, 63, 94, 0.25);
}

[data-theme="dark"] .btn-danger {
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.3);
}

.btn-danger:hover {
  background: #f43f5e;
  color: #ffffff;
  border-color: #f43f5e;
}

.btn-danger:active {
  background: #e11d48;
}

.btn-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
  background: var(--bg-box);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  box-sizing: border-box;
}

.btn-icon:hover {
  background: rgba(99, 102, 241, 0.12);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-icon.btn-danger:hover,
.channel-card .delete-btn:hover,
.card-icon-actions .delete-btn:hover {
  background: #f43f5e;
  color: #ffffff;
  border-color: #f43f5e;
}

.btn-icon.btn-danger:active,
.channel-card .delete-btn:active,
.card-icon-actions .delete-btn:active {
  background: #e11d48;
}

.btn-sm {
  font-size: 0.78rem;
  padding: 0.4rem 0.75rem;
}

/* Theme Toggle Button Icons */
.theme-icon-sun {
  display: none;
}
.theme-icon-moon {
  display: block;
}

[data-theme="dark"] .theme-icon-moon {
  display: none;
}
[data-theme="dark"] .theme-icon-sun {
  display: block;
}

[data-theme="light"] .theme-icon-sun {
  display: none;
}
[data-theme="light"] .theme-icon-moon {
  display: block;
}

/* Stats Overview Bar */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.4rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition-fast), border-color var(--transition-fast), background var(--transition-normal);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
}

.stat-icon-wrapper {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-indigo {
  background: rgba(99, 102, 241, 0.12);
  color: #6366f1;
}

.stat-cyan {
  background: rgba(6, 182, 212, 0.12);
  color: #0891b2;
}

[data-theme="dark"] .stat-cyan {
  color: #22d3ee;
}

.stat-emerald {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
}

[data-theme="dark"] .stat-emerald {
  color: #34d399;
}

.stat-purple {
  background: rgba(168, 85, 247, 0.12);
  color: #9333ea;
}

[data-theme="dark"] .stat-purple {
  color: #c084fc;
}

.stat-content {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-primary);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Control Bar: Search & Filters */
.controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 260px;
  max-width: 500px;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.7rem 2.4rem 0.7rem 2.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  outline: none;
  transition: all var(--transition-fast);
}

.search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
  background: var(--bg-secondary);
}

.search-clear {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  display: none;
}

.search-clear:hover {
  color: var(--text-primary);
}

.controls-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.count-badge {
  font-size: 0.825rem;
  color: var(--text-secondary);
  background: var(--bg-box);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

/* Channels Grid */
.channels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1.5rem;
}

/* Channel Card */
.channel-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: var(--shadow-card);
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
  animation: cardFadeIn 0.35s ease-out forwards;
}

.channel-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary-color);
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}

.channel-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-hover);
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.12), 0 0 20px rgba(99, 102, 241, 0.15);
}

[data-theme="dark"] .channel-card:hover {
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.7), 0 0 20px rgba(99, 102, 241, 0.2);
}

.channel-card:hover::before {
  opacity: 1;
}

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

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.card-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
}

.card-badges-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.card-id-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  background: rgba(99, 102, 241, 0.12);
  color: #6366f1;
  border: 1px solid rgba(99, 102, 241, 0.25);
  letter-spacing: 0.05em;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

[data-theme="dark"] .card-id-badge {
  color: #a5b4fc;
  border-color: rgba(99, 102, 241, 0.3);
}

.card-visibility-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  letter-spacing: 0.03em;
  transition: all var(--transition-fast);
}

.card-visibility-badge.badge-public {
  color: #059669;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

[data-theme="dark"] .card-visibility-badge.badge-public {
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.3);
}

.card-visibility-badge.badge-private {
  color: #64748b;
  background: rgba(100, 116, 139, 0.12);
  border: 1px solid rgba(100, 116, 139, 0.22);
}

[data-theme="dark"] .card-visibility-badge.badge-private {
  color: #94a3b8;
  border-color: rgba(148, 163, 184, 0.25);
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.card-title a,
.card-title-link {
  color: inherit;
  text-decoration: none;
}

.card-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-desc-empty {
  opacity: 0.5;
}

.card-geo-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: #0284c7;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all var(--transition-fast);
}

[data-theme="dark"] .card-geo-badge {
  color: #38bdf8;
}

.card-geo-badge:hover {
  background: rgba(56, 189, 248, 0.2);
}

/* API Key Strip in Card */
.api-key-box {
  background: var(--bg-box);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.api-key-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.api-key-value {
  font-family: var(--font-mono);
  font-size: 0.825rem;
  color: var(--text-primary);
  letter-spacing: 0.08em;
}

.api-key-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.icon-btn-tiny {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.3rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.icon-btn-tiny:hover {
  background: rgba(99, 102, 241, 0.15);
  color: var(--text-primary);
}

/* Fields Grid inside Card */
.fields-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.fields-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.fields-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.fields-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.field-chip {
  font-size: 0.75rem;
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-sm);
  background: var(--bg-box);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.field-chip-num {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 700;
  background: rgba(0, 0, 0, 0.06);
  padding: 0.08rem 0.3rem;
  border-radius: 3px;
}

[data-theme="dark"] .field-chip-num {
  background: rgba(255, 255, 255, 0.07);
  color: #94a3b8;
}

.field-chip.active {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.3);
  color: var(--text-primary);
}

.field-chip.active .field-chip-num {
  background: rgba(99, 102, 241, 0.25);
  color: #6366f1;
}

[data-theme="dark"] .field-chip.active .field-chip-num {
  color: #a5b4fc;
}

.field-chip.field-chip-empty {
  opacity: 0.6;
}

/* Card Footer Actions */
.card-footer {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
}

.card-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-time {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.card-time svg {
  opacity: 0.7;
}

.card-actions-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.card-actions-group .card-action-btn {
  flex: 1;
  min-width: 0;
  height: 36px;
  min-height: 36px;
  max-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  box-sizing: border-box;
  text-decoration: none;
  line-height: 1;
}

.card-icon-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.card-icon-actions .btn-icon {
  height: 36px;
  width: 36px;
  min-height: 36px;
  min-width: 36px;
  max-height: 36px;
  max-width: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  box-sizing: border-box;
  cursor: pointer;
  flex-shrink: 0;
}

/* Empty State */
.empty-state {
  display: none;
  grid-column: 1 / -1;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 4rem 2rem;
  text-align: center;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.empty-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6366f1;
}

.empty-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
}

.empty-desc {
  max-width: 440px;
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Modal Dialogs */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-backdrop);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-container {
  background: var(--bg-modal);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: translateY(20px) scale(0.97);
  transition: all var(--transition-normal);
  overflow: hidden;
}

.modal-container-sm {
  max-width: 460px;
}

.modal-container-md {
  max-width: 520px;
}

.modal-overlay.active .modal-container {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 1.5rem 1.75rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.02);
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.modal-title-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(99, 102, 241, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6366f1;
}

.modal-icon-indigo {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
}

.modal-icon-cyan {
  background: rgba(6, 182, 212, 0.15);
  color: #22d3ee;
}

.modal-icon-rose {
  background: rgba(244, 63, 94, 0.15);
  color: #f43f5e;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
}

.modal-close:hover {
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
}

.modal-body {
  padding: 1.75rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.modal-text {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
}

.modal-text strong {
  color: var(--text-primary);
}

.modal-footer {
  padding: 1.25rem 1.75rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

.modal-footer-compact {
  padding: 1rem 0 0 0;
  margin-top: 0.5rem;
}

/* Forms */
.form-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #6366f1;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.form-label {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-label-req {
  color: #f43f5e;
}

.form-input, .form-textarea {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  outline: none;
  transition: all var(--transition-fast);
}

.form-input:focus, .form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
  background: var(--bg-secondary);
}

.form-textarea {
  resize: vertical;
  min-height: 70px;
}

.input-with-action {
  display: flex;
  gap: 0.5rem;
}

.input-with-action .form-input {
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

.input-with-action .btn {
  padding: 0.6rem 0.9rem;
}

.form-actions-end {
  display: flex;
  justify-content: flex-end;
}

/* Visibility Toggle Card */
.visibility-toggle-card {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  transition: all var(--transition-fast);
}

.visibility-toggle-card:hover {
  border-color: var(--border-hover);
}

.visibility-toggle-card.is-public {
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.05);
}

[data-theme="dark"] .visibility-toggle-card.is-public {
  border-color: rgba(52, 211, 153, 0.4);
  background: rgba(52, 211, 153, 0.08);
}

.toggle-switch-wrapper {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  cursor: pointer;
  user-select: none;
}

.toggle-switch-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.toggle-switch-slider {
  position: relative;
  width: 44px;
  height: 24px;
  background-color: var(--bg-tertiary, #cbd5e1);
  border-radius: 24px;
  flex-shrink: 0;
  transition: all var(--transition-fast);
  border: 1px solid var(--border-subtle);
}

[data-theme="dark"] .toggle-switch-slider {
  background-color: #334155;
}

.toggle-switch-slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: #ffffff;
  border-radius: 50%;
  transition: all var(--transition-fast);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-switch-input:checked + .toggle-switch-slider {
  background-color: #10b981;
  border-color: #059669;
}

.toggle-switch-input:checked + .toggle-switch-slider::before {
  transform: translateX(20px);
}

.toggle-switch-input:focus + .toggle-switch-slider {
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
}

.toggle-switch-content {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.toggle-title-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.toggle-status-icon {
  display: inline-flex;
  align-items: center;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.visibility-toggle-card.is-public .toggle-status-icon {
  color: #10b981;
}

.toggle-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  transition: color var(--transition-fast);
}

.visibility-toggle-card.is-public .toggle-title {
  color: #059669;
}

[data-theme="dark"] .visibility-toggle-card.is-public .toggle-title {
  color: #34d399;
}

.toggle-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

/* Snippets / Code Inspector */
.code-box {
  background: var(--code-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  position: relative;
}

.code-box pre {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #38bdf8;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.6;
}

.code-copy-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  font-size: 0.75rem;
  padding: 0.3rem 0.65rem;
}

.snippet-tabs {
  display: flex;
  gap: 0.4rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1rem;
}

.snippet-tab {
  padding: 0.5rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.snippet-tab.active {
  color: #6366f1;
  border-bottom-color: #6366f1;
}

[data-theme="dark"] .snippet-tab.active {
  color: #38bdf8;
  border-bottom-color: #38bdf8;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 420px;
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-modal);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-primary);
  font-size: 0.875rem;
  animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: all 0.3s ease;
}

.toast-success {
  border-color: rgba(16, 185, 129, 0.4);
}

.toast-success .toast-icon {
  color: #10b981;
}

.toast-error {
  border-color: rgba(244, 63, 94, 0.4);
}

.toast-error .toast-icon {
  color: #f43f5e;
}

.toast-info {
  border-color: rgba(6, 182, 212, 0.4);
}

.toast-info .toast-icon {
  color: #0891b2;
}

[data-theme="dark"] .toast-info .toast-icon {
  color: #38bdf8;
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Responsive queries */
@media (max-width: 768px) {
  .app-layout {
    padding: 1rem 0.75rem 3rem;
    gap: 1.25rem;
  }

  .header-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    justify-content: space-between;
  }

  .channels-grid {
    grid-template-columns: 1fr;
  }

  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* App Footer */
.app-footer {
  text-align: center;
  padding: 1.5rem 0 0.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  border-top: 1px solid var(--border-subtle);
}

.app-footer a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--transition-fast);
}

.app-footer a:hover {
  color: var(--primary-color, #6366f1);
  text-decoration: underline;
}

/* ==========================================================================
   Authentication UI Styles
   ========================================================================== */
.auth-section {
  display: inline-flex;
  align-items: center;
}

.user-auth-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  height: 40px;
  min-height: 40px;
  padding: 0 0.75rem 0 0.85rem;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.28);
  color: var(--primary-color);
  font-size: 0.825rem;
  font-weight: 600;
  box-sizing: border-box;
}

[data-theme="dark"] .user-auth-badge {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.35);
  color: #a5b4fc;
}

.user-auth-icon {
  flex-shrink: 0;
}

.user-email {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-logout {
  display: inline-flex;
  align-items: center;
  margin-left: 0.2rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  background: rgba(244, 63, 94, 0.12);
  color: var(--accent-rose);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 700;
  transition: all var(--transition-fast);
}

.user-logout:hover {
  background: var(--accent-rose);
  color: #ffffff;
}

.btn-login {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  height: 40px;
  min-height: 40px;
  padding: 0 1rem;
  border-radius: var(--radius-md);
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.28);
  color: var(--primary-color);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition-fast);
  box-sizing: border-box;
}

.btn-login:hover {
  background: var(--primary-color);
  color: #ffffff;
  border-color: var(--primary-color);
  box-shadow: 0 4px 14px var(--primary-glow);
}

[data-theme="dark"] .btn-login {
  background: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
}

[data-theme="dark"] .btn-login:hover {
  background: var(--primary-color);
  color: #ffffff;
}

.api-key-box.api-key-locked {
  background: rgba(15, 23, 42, 0.03);
  border-color: var(--border-subtle);
}

[data-theme="dark"] .api-key-box.api-key-locked {
  background: rgba(0, 0, 0, 0.25);
}

.api-key-locked-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary-color);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.api-key-locked-link:hover {
  background: var(--primary-color);
  color: #ffffff;
}


