/* ==========================================================================
   QVIBE DESIGN SYSTEM — CORE TOKENS & UTILITIES
   Theme: True Obsidian / Onyx Neutral Dark Mode (Zero Blue Tint)
   Bulletproof Text Overflow & Flexbox Safety
   ========================================================================== */

:root {
  --bg-main: #09090b;             /* Deep pitch neutral black */
  --bg-surface: #121214;          /* Pure neutral charcoal surface */
  --bg-surface-elevated: #18181b; /* Elevated neutral surface */
  --bg-surface-hover: #222226;
  
  --glass-bg: rgba(18, 18, 20, 0.88);
  --glass-border: rgba(255, 255, 255, 0.09);
  --glass-border-hover: rgba(255, 255, 255, 0.2);
  --glass-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);

  --accent: #ffffff;
  --accent-light: #f4f4f5;
  --accent-glow: rgba(255, 255, 255, 0.12);
  
  --emerald: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.25);
  --coral: #ef4444;
  --coral-glow: rgba(239, 68, 68, 0.25);
  --amber: #f59e0b;
  --amber-glow: rgba(245, 158, 11, 0.25);

  --text-primary: #ffffff;
  --text-secondary: #a1a1aa;      /* Neutral Zinc-400 */
  --text-muted: #71717a;          /* Neutral Zinc-500 */
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

html, body {
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Bulletproof text wrapping prevention across all elements */
*, *::before, *::after {
  box-sizing: border-box;
}

p, span, h1, h2, h3, h4, h5, h6, div, label, a, button, li, td, th, input, textarea, select {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Ensure flex/grid children don't blow out parent containers */
.glass-panel, .card, .form-group, .modal-content, .tab-pane, 
.stream-item, .quick-q-item, .check-item, .kpi-card, .stage-deck {
  min-width: 0;
  max-width: 100%;
}

/* Subtle Neutral Atmosphere (No blue/purple hazes) */
.ambient-glow {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.02) 0%, transparent 70%);
}

/* Glass Surface Container */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
  min-width: 0; /* Prevents flexbox child blowout */
}

.glass-panel:hover {
  border-color: var(--glass-border-hover);
}

/* Typography Helpers */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  overflow-wrap: break-word;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  user-select: none;
  white-space: normal;
  text-align: center;
  max-width: 100%;
  box-sizing: border-box;
  flex-shrink: 0;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: #ffffff;
  color: #09090b;
  box-shadow: 0 4px 14px rgba(255, 255, 255, 0.15);
}

.btn-primary:hover {
  background: #f4f4f5;
  box-shadow: 0 6px 18px rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #18181b;
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
  background: #27272a;
  border-color: var(--glass-border-hover);
}

.btn-success {
  background: #10b981;
  color: #fff;
  box-shadow: 0 4px 14px var(--emerald-glow);
}

.btn-success:hover {
  background: #059669;
}

.btn-warning {
  background: #f59e0b;
  color: #fff;
  box-shadow: 0 4px 14px var(--amber-glow);
}

.btn-danger {
  background: #ef4444;
  color: #fff;
  box-shadow: 0 4px 14px var(--coral-glow);
}

.btn-lg {
  padding: 14px 26px;
  font-size: 1.1rem;
  border-radius: var(--radius-md);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

/* Badges & Tags */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-draft {
  background: #18181b;
  color: #a1a1aa;
  border: 1px solid #27272a;
}

.badge-active {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
  box-shadow: 0 0 12px var(--emerald-glow);
}

.badge-paused {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.badge-finished {
  background: #27272a;
  color: #e4e4e7;
  border: 1px solid #3f3f46;
}

/* Pulsing Dot Indicator */
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  position: relative;
  flex-shrink: 0;
}

.pulse-dot.online {
  background-color: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
}

.pulse-dot.online::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 50%;
  border: 2px solid var(--emerald);
  animation: pulse-ring 1.8s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.9); opacity: 0.9; }
  80%, 100% { transform: scale(2.2); opacity: 0; }
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  padding: 20px;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-content {
  background: #121214;
  border: 1px solid #27272a;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  transform: translateY(20px) scale(0.96);
  transition: transform var(--transition-normal);
  padding: 28px;
}

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

/* Form Controls with strict box model */
.form-group {
  margin-bottom: 20px;
  width: 100%;
  min-width: 0;
}

.form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  overflow-wrap: break-word;
}

.form-control {
  width: 100%;
  max-width: 100%;
  padding: 12px 16px;
  background: #18181b;
  border: 1px solid #27272a;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  box-sizing: border-box;
}

.form-control:focus {
  border-color: #52525b;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
  background: #1c1c20;
}

textarea.form-control {
  resize: vertical;
  min-height: 100px;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: calc(100vw - 48px);
}

.toast {
  pointer-events: all;
  background: #18181b;
  border: 1px solid #27272a;
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  color: #fff;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  animation: toast-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  max-width: 420px;
  overflow-wrap: break-word;
  word-break: break-word;
}

.toast.success { border-left: 4px solid var(--emerald); }
.toast.error { border-left: 4px solid var(--coral); }
.toast.info { border-left: 4px solid #a1a1aa; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.4);
}

::-webkit-scrollbar-thumb {
  background: #27272a;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #3f3f46;
}
