/* ==========================================
   YGT COMMAND CENTER - PREMIUM CSS DESIGN SYSTEM
   ========================================== */

:root {
  /* Colors - Default Dark Mode */
  --bg-gradient: radial-gradient(circle at 50% 0%, #0c0f24 0%, #05060f 100%);
  --bg-dark: #05060f;
  --panel-bg: rgba(13, 17, 38, 0.6);
  --card-bg: rgba(18, 24, 51, 0.65);
  --card-bg-hover: rgba(26, 34, 71, 0.8);
  --border-light: rgba(255, 255, 255, 0.07);
  --border-medium: rgba(255, 255, 255, 0.12);
  --border-glow: rgba(59, 130, 246, 0.3);
  
  --text-primary: #f1f3f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  /* Accents */
  --accent-blue: #3b82f6;
  --accent-blue-rgb: 59, 130, 246;
  --accent-purple: #8b5cf6;
  --accent-purple-rgb: 139, 92, 246;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --accent-gold: #f59e0b;
  
  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.7);
  --shadow-blue-glow: 0 0 20px rgba(59, 130, 246, 0.15);
  
  /* Transitions */
  --ease-premium: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: all 0.2s var(--ease-premium);
  --transition-normal: all 0.4s var(--ease-premium);
}

html[data-theme="light"] {
  --bg-gradient: radial-gradient(circle at 50% 0%, #fcfaf6 0%, #f3eee3 100%);
  --bg-dark: #f3eee3;
  --panel-bg: rgba(255, 255, 255, 0.7);
  --card-bg: rgba(255, 255, 255, 0.8);
  --card-bg-hover: rgba(255, 255, 255, 0.95);
  --border-light: rgba(0, 0, 0, 0.06);
  --border-medium: rgba(0, 0, 0, 0.12);
  --border-glow: rgba(59, 130, 246, 0.15);
  
  --text-primary: #2d2a26;
  --text-secondary: #706a60;
  --text-muted: #8c857b;
  
  --accent-blue: #1b63c4;
  --accent-purple: #6d28d9;
  --accent-emerald: #15803d;
  --accent-rose: #be123c;
  --accent-gold: #b45309;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.12);
  --shadow-blue-glow: 0 0 20px rgba(27, 99, 196, 0.08);
}


/* Reset & Scrollbar */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Outfit', 'Space Grotesk', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-dark);
  background-image: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  max-width: 100%;
  position: relative;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-blue);
}

/* Auth-check loading overlay — shown by default, hidden once onAuthStateChanged
   resolves. Without this, pages default to showing either the app shell or the
   login screen BEFORE Firebase has confirmed the real auth state; on a slow/cold
   auth check that gap is visible and reads as "got logged out", even though the
   page self-corrects a moment later. Previously this div existed on some pages
   with no CSS at all, so it never actually covered anything. */
#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-dark);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  font-family: 'Outfit', sans-serif;
}

/* Glassmorphism utility */
.glass {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-md);
  border-radius: 20px;
  transition: var(--transition-normal);
}

.glass:hover {
  border-color: var(--border-medium);
  box-shadow: var(--shadow-lg), var(--shadow-blue-glow);
}

/* ------------------------------------------
   PREMIUM LOGIN SYSTEM STYLING
   ------------------------------------------ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: fixed;
  inset: 0;
  background: var(--bg-dark);
  background-image: var(--bg-gradient);
  z-index: 1000;
  animation: fadeIn 0.4s var(--ease-premium);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: rgba(18, 24, 51, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-lg), 0 0 50px rgba(59, 130, 246, 0.05);
  padding: 40px 32px;
  border-radius: 24px;
  text-align: center;
  animation: scaleIn 0.5s var(--ease-premium);
}

.login-card h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.login-card p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 32px;
}

.field {
  text-align: left;
  margin-bottom: 20px;
  position: relative;
}

.field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.field input {
  width: 100%;
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition-fast);
}

.field input:focus {
  border-color: var(--accent-blue);
  background: rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.login-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-purple) 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  margin-top: 10px;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.25);
  transition: var(--transition-fast);
}

.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
  opacity: 0.95;
}

.login-btn:active {
  transform: translateY(1px);
}

.login-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.err {
  font-size: 13px;
  color: var(--accent-rose);
  text-align: center;
  margin-top: 12px;
  min-height: 20px;
}

/* ------------------------------------------
   SHARED SYNC DOT & TOP NAV
   ------------------------------------------ */
.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  box-shadow: 0 0 0 0px rgba(255, 255, 255, 0.1);
  transition: var(--transition-normal);
}

.sync-dot.live {
  background: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald), 0 0 0 4px rgba(16, 185, 129, 0.2);
}

/* ------------------------------------------
   PREMIUM MODALS
   ------------------------------------------ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 15, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.3s var(--ease-premium);
}

.modal-overlay.open, .modal-overlay.active {
  display: flex;
}

.modal-box {
  background: var(--card-bg);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1px solid var(--border-medium);
  box-shadow: var(--shadow-lg), 0 0 40px rgba(var(--accent-blue-rgb), 0.06);
  border-radius: 24px;
  padding: 32px 28px;
  width: 100%;
  max-width: 480px;
  animation: slideUp 0.4s var(--ease-premium);
  position: relative;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 24px;
  letter-spacing: -0.3px;
}

.modal-field {
  margin-bottom: 20px;
}

.modal-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.modal-field input, .modal-field select, .modal-field textarea {
  width: 100%;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition-fast);
}

.modal-field input:focus, .modal-field select:focus, .modal-field textarea:focus {
  border-color: var(--accent-blue);
  background: rgba(0, 0, 0, 0.4);
}

.modal-field textarea {
  min-height: 80px;
  resize: vertical;
}

.modal-btns {
  display: flex;
  gap: 12px;
  margin-top: 28px;
}

.btn-save, .modal-save {
  flex: 2;
  padding: 12px;
  background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-purple) 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-save:hover, .modal-save:hover {
  opacity: 0.95;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.btn-cancel, .modal-cancel {
  flex: 1;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-cancel:hover, .modal-cancel:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

/* ------------------------------------------
   TOAST NOTIFICATION
   ------------------------------------------ */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(18, 24, 51, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(59, 130, 246, 0.1);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: 50px;
  font-size: 13.5px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s var(--ease-premium);
  pointer-events: none;
  z-index: 9999;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  text-align: center;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ------------------------------------------
   ANIMATIONS
   ------------------------------------------ */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes pulseGlow {
  0% { box-shadow: 0 0 0 0px rgba(59, 130, 246, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(59, 130, 246, 0); }
  100% { box-shadow: 0 0 0 0px rgba(59, 130, 246, 0); }
}

/* Responsive improvements */
@media (max-width: 576px) {
  .modal-box {
    margin: 10px;
    padding: 24px 20px;
  }
  .login-card {
    padding: 30px 20px;
  }
}

/* ==========================================
   THEME TOGGLE BUTTON & LIGHT MODE OVERRIDES
   ========================================== */
.theme-toggle-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 18px;
  transition: var(--transition-fast);
  flex-shrink: 0;
  outline: none;
}

.theme-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-medium);
  color: var(--text-primary);
  transform: scale(1.05);
}

/* Light Theme Overrides */
html[data-theme="light"] .net-bg {
  opacity: 0.04;
  background-image: 
    linear-gradient(rgba(0, 0, 0, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.08) 1px, transparent 1px);
}

html[data-theme="light"] .glow-blob {
  opacity: 0.03;
}

html[data-theme="light"] .theme-toggle-btn {
  background: rgba(0, 0, 0, 0.02);
}

html[data-theme="light"] .theme-toggle-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}

