/* ==========================================================================
   KEYHUB — Modern License & Store Portal
   Theme: Deep Navy Glassmorphism & High-Contrast Cyber Accents
   ========================================================================== */

:root {
  --kh-bg: #071019;
  --kh-card: #0d1825;
  --kh-card2: #101d2b;
  --kh-card-glass: rgba(16, 29, 43, 0.88);
  --kh-border: rgba(148, 163, 184, 0.16);
  --kh-border-subtle: rgba(255, 255, 255, 0.06);
  --kh-muted: #8290a5;
  --kh-blue: #19a7ff;
  --kh-blue-glow: rgba(25, 167, 255, 0.22);
  --kh-cyan: #00d6c9;
  --kh-cyan-glow: rgba(0, 214, 201, 0.22);
  --kh-green: #21d07a;
  --kh-red: #ff4d57;
  --kh-orange: #ffae22;
}

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background-color: var(--kh-bg);
  color: #f1f5f9;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 12% 0%, rgba(0, 174, 255, 0.09), transparent 28%),
    radial-gradient(circle at 90% 35%, rgba(0, 214, 201, 0.08), transparent 30%),
    radial-gradient(circle at 50% 90%, rgba(25, 167, 255, 0.05), transparent 35%),
    linear-gradient(135deg, #071019, #09131f 55%, #061016);
  background-attachment: fixed;
}

/* Cyber Glow Background Layer */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(circle at 20% 15%, rgba(25, 167, 255, 0.10), transparent 22%),
    radial-gradient(circle at 82% 12%, rgba(112, 80, 255, 0.08), transparent 24%);
}

/* Touch & Inputs */
button, input, select, textarea {
  touch-action: manipulation;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #071019;
}
::-webkit-scrollbar-thumb {
  background: #1a2736;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #25394d;
}

/* Glassmorphism Cards */
.glass-card {
  background: linear-gradient(145deg, rgba(16, 29, 43, 0.94), rgba(10, 21, 33, 0.94)) !important;
  border: 1px solid var(--kh-border) !important;
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.20), inset 0 1px 0 rgba(255, 255, 255, 0.035);
  border-radius: 20px !important;
}

.premium-panel {
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, rgba(17, 30, 46, 0.98), rgba(8, 17, 28, 0.98));
  border: 1px solid rgba(104, 160, 220, 0.16);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.035);
  border-radius: 22px;
}

.premium-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.035), transparent 28%, transparent 72%, rgba(25, 167, 255, 0.025));
}

/* Input Fields */
.premium-input {
  background: rgba(7, 15, 25, 0.85) !important;
  border: 1px solid rgba(148, 163, 184, 0.16) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
  color: #f8fafc !important;
  border-radius: 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.premium-input:focus {
  border-color: rgba(25, 167, 255, 0.65) !important;
  box-shadow: 0 0 0 3px rgba(25, 167, 255, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.025) !important;
  outline: none;
}
.premium-input::placeholder {
  color: #556579;
}

/* Primary Button */
.premium-primary {
  background: linear-gradient(135deg, #1689ff, #2563eb) !important;
  box-shadow: 0 10px 25px rgba(37, 99, 235, 0.28);
  color: #ffffff !important;
  font-weight: 700 !important;
  border-radius: 14px !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  transition: transform 0.18s ease, filter 0.18s ease, box-shadow 0.18s ease !important;
}
.premium-primary:hover {
  filter: brightness(1.09);
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.38);
}
.premium-primary:active {
  transform: scale(0.98);
}
.premium-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  filter: grayscale(0.5);
}

/* Secondary Button */
.premium-secondary {
  background: rgba(16, 29, 43, 0.90) !important;
  border: 1px solid rgba(148, 163, 184, 0.18) !important;
  color: #cbd5e1 !important;
  font-weight: 600 !important;
  border-radius: 14px !important;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease !important;
}
.premium-secondary:hover {
  background: rgba(25, 167, 255, 0.10) !important;
  border-color: rgba(25, 167, 255, 0.30) !important;
  color: #ffffff !important;
}

/* Navigation Items */
.premium-nav-item {
  border: 1px solid transparent !important;
  min-height: 46px;
  border-radius: 12px;
  transition: all 0.2s ease;
  color: #94a3b8;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
}
.premium-nav-item:hover {
  background: rgba(25, 167, 255, 0.08) !important;
  border-color: rgba(25, 167, 255, 0.15) !important;
  color: #f1f5f9;
}
.premium-nav-item.active {
  background: linear-gradient(135deg, rgba(22, 137, 255, 0.22), rgba(37, 99, 235, 0.28)) !important;
  border-color: rgba(25, 167, 255, 0.45) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 18px rgba(25, 167, 255, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Stats Cards */
.kh-stat {
  position: relative;
  overflow: hidden;
  min-height: 135px;
  padding: 20px;
  border-radius: 20px;
  background: linear-gradient(145deg, #101d2b, #0c1723);
  border: 1px solid rgba(148, 163, 184, 0.14);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
}
.kh-stat::after {
  content: "";
  position: absolute;
  width: 110px;
  height: 110px;
  right: -30px;
  top: -40px;
  border-radius: 50%;
  background: rgba(25, 167, 255, 0.08);
  filter: blur(4px);
}
.kh-stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(25, 167, 255, 0.12);
  color: #22adff;
  border: 1px solid rgba(25, 167, 255, 0.16);
}
.kh-stat-value {
  font-size: clamp(1.65rem, 4vw, 2.25rem);
  font-weight: 800;
  line-height: 1.05;
  margin-top: 14px;
  letter-spacing: -0.03em;
  color: #ffffff;
}
.kh-stat-label {
  margin-top: 6px;
  color: #8794a8;
  font-size: 0.85rem;
  font-weight: 500;
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.badge-active, .badge-approved, .badge-success {
  background: rgba(33, 208, 122, 0.12);
  color: #34d399;
  border: 1px solid rgba(33, 208, 122, 0.25);
}
.badge-pending, .badge-warning {
  background: rgba(255, 174, 34, 0.12);
  color: #fbbf24;
  border: 1px solid rgba(255, 174, 34, 0.25);
}
.badge-inactive, .badge-rejected, .badge-danger {
  background: rgba(255, 77, 87, 0.12);
  color: #f87171;
  border: 1px solid rgba(255, 77, 87, 0.25);
}
.badge-info, .badge-generated {
  background: rgba(25, 167, 255, 0.12);
  color: #38bdf8;
  border: 1px solid rgba(25, 167, 255, 0.25);
}

/* Tables */
.responsive-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.12);
}
.responsive-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
.responsive-table th {
  background: rgba(11, 22, 34, 0.95);
  color: #7b8ba0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  white-space: nowrap;
}
.responsive-table td {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  font-size: 0.88rem;
  color: #cbd5e1;
  vertical-align: middle;
}
.responsive-table tr:last-child td {
  border-bottom: 0;
}
.responsive-table tr:hover td {
  background: rgba(25, 167, 255, 0.03);
}

/* Modals */
.kh-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 14, 0.82);
  backdrop-filter: blur(10px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.kh-modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.kh-modal {
  background: linear-gradient(145deg, #101d2b, #0a1622);
  border: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  border-radius: 22px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.kh-modal-backdrop.open .kh-modal {
  transform: scale(1) translateY(0);
}

/* User Info Modal Specifics */
.user-info-tab {
  color: #9ca3af;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.2s ease;
  padding: 8px 16px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
}
.user-info-tab:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}
.user-info-tab.active {
  color: #ffffff;
  background: rgba(6, 182, 212, 0.16);
  border-color: rgba(6, 182, 212, 0.40);
  box-shadow: 0 0 0 1px rgba(6, 182, 212, 0.10) inset;
}
.user-info-section {
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 18px;
  padding: 18px;
  background: rgba(15, 23, 42, 0.45);
}

/* Mobile Slide-Out Panel */
.mobile-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 12, 0.75);
  backdrop-filter: blur(8px);
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.mobile-nav-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.mobile-nav-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(86vw, 320px);
  background: linear-gradient(160deg, #0a1420 0%, #060e17 100%);
  border-right: 1px solid rgba(148, 163, 184, 0.16);
  z-index: 85;
  transform: translateX(-105%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 10px 0 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
}
.mobile-nav-panel.open {
  transform: translateX(0);
}

/* Mobile Bottom Navigation */
.kh-bottom-nav {
  display: none;
}
@media (max-width: 767px) {
  body {
    padding-bottom: 84px;
  }
  .desktop-sidebar {
    display: none !important;
  }
  .mobile-menu-btn {
    display: flex !important;
  }
  .mobile-nav-overlay {
    display: block;
  }
  .dashboard-main {
    padding: 14px !important;
  }
  .dashboard-header {
    min-height: 64px !important;
    padding: 10px 14px !important;
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(8, 17, 28, 0.95) !important;
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  }
  .kh-bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 74px;
    z-index: 70;
    background: rgba(9, 18, 29, 0.97);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(148, 163, 184, 0.14);
    align-items: center;
    justify-content: space-around;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .kh-bottom-nav button {
    flex: 1;
    color: #718097;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 700;
    min-width: 58px;
    padding: 6px 2px;
    background: transparent;
    border: none;
    cursor: pointer;
  }
  .kh-bottom-nav button.active {
    color: #19a7ff;
  }
  .kh-bottom-nav .nav-center {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: linear-gradient(135deg, #1689ff, #0284c7);
    color: #fff;
    box-shadow: 0 8px 24px rgba(22, 137, 255, 0.38);
    margin-top: -18px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .kh-bottom-nav .nav-center + span {
    color: #19a7ff;
  }
  .modal-mobile {
    max-height: calc(100vh - 2rem);
    border-radius: 22px !important;
  }
  .responsive-table {
    min-width: 680px;
  }
  input, select, textarea {
    font-size: 16px !important;
    min-height: 46px;
  }
  button.premium-primary, button.premium-secondary {
    min-height: 46px;
  }
  .kh-modal {
    width: min(94vw, 580px) !important;
    padding: 18px !important;
  }
}

@media (min-width: 768px) {
  .mobile-menu-btn {
    display: none !important;
  }
  .desktop-sidebar {
    display: flex !important;
    background: rgba(9, 17, 27, 0.96) !important;
    border-right: 1px solid rgba(148, 163, 184, 0.12) !important;
  }
}

/* Offline Banner & Connection Status - Completely suppressed from normal UI */
#offline-indicator,
.firebase-status-banner,
.firebase-connection-status,
.connection-status-toast {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  height: 0 !important;
  min-height: 0 !important;
  max-height: 0 !important;
  overflow: hidden !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* ==========================================================================
   Initial App Preloader
   ========================================================================== */
#app-preloader.preloader-hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

@keyframes kh-preloader-shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(200%);
  }
}

.kh-preloader-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, #38bdf8, #00d6c9, transparent);
  border-radius: 9999px;
  animation: kh-preloader-shimmer 1.3s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
