/* =========================================================
   QR Bridge — Tactical Tech Theme (Fixed)
   ========================================================= */

:root, [data-theme="dark"] {
  /* --- Dimensions --- */
  --bar-h: 64px;
  --sidebar-w: 260px;
  --dock-h: 80px;

  /* --- Palette --- */
  --bg-deep: #050507;
  --bg-panel: #0f0f13;
  --bg-card: rgba(20, 20, 25, 0.8);

  /* --- Accents --- */
  --accent: #00e5ff;       /* Cyan */
  --accent-dim: rgba(0, 229, 255, 0.15);
  --success: #00ff9d;
  --danger: #ff3366;

  /* --- Text --- */
  --text-main: #ffffff;
  --text-muted: #888899;
  --font-ui: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* --- Borders & Glass --- */
  --border: 1px solid rgba(255, 255, 255, 0.1);
  --border-active: 1px solid var(--accent);

  /* --- Shapes --- */
  --radius: 12px;
}

/* Light Theme */
[data-theme="light"] {
  --bg-deep: #f0f2f5;
  --bg-panel: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.9);
  --accent: #0088cc;
  --accent-dim: rgba(0, 136, 204, 0.15);
  --success: #00b368;
  --danger: #e53355;
  --text-main: #1a1a2e;
  --text-muted: #5a5a6e;
  --border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Reset */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; padding: 0; overflow-x: hidden; }

body {
  font-family: var(--font-ui);
  background-color: var(--bg-deep);
  color: var(--text-main);
}

[data-theme="dark"] body,
:root body {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  background-attachment: fixed;
}

[data-theme="light"] body {
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  background-attachment: fixed;
}

h1, h2, h3, h4 { margin: 0 0 12px 0; font-weight: 700; letter-spacing: -0.02em; color: var(--text-main); }
p { line-height: 1.6; color: var(--text-muted); margin-bottom: 16px; }
small { font-size: 0.85em; color: var(--text-muted); }
code { font-family: var(--font-mono); background: var(--accent-dim); padding: 2px 6px; border-radius: 4px; color: var(--accent); }

/* Light theme specific overrides */
[data-theme="light"] .topbar,
[data-theme="light"] .dock {
  background: rgba(255, 255, 255, 0.95);
}
[data-theme="light"] .primary {
  color: #fff;
}
[data-theme="light"] .card {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}
[data-theme="light"] .secondary {
  color: var(--text-main);
  border-color: rgba(0, 0, 0, 0.2);
}
[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-main);
}
[data-theme="light"] input::placeholder,
[data-theme="light"] textarea::placeholder {
  color: var(--text-muted);
}
[data-theme="light"] .scanner-controls button {
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-main);
  border-color: rgba(0, 0, 0, 0.2);
}
[data-theme="light"] .scanner-controls .secondary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
[data-theme="light"] .dock a {
  color: var(--text-muted);
}
[data-theme="light"] .dock a:hover,
[data-theme="light"] .dock a:active,
[data-theme="light"] .dock a:focus {
  color: var(--accent);
}

/* Page Header with Back Button (Desktop) */
.page-header {
  display: none;
  width: 100%;
  max-width: 1000px;
  margin-bottom: 20px;
  text-align: left;
}
.page-header .back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 8px;
  transition: 0.2s;
}
.page-header .back-link:hover {
  color: var(--accent);
  background: var(--accent-dim);
}
@media (min-width: 1024px) {
  .page-header {
    display: block;
  }
}

/* =========================================================
   Layout Structure (Responsive)
   ========================================================= */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(var(--bar-h) + 20px) 16px calc(var(--dock-h) + 20px) 16px;
  max-width: 100vw;
  box-sizing: border-box;
}

/* Tablet Layout */
@media (min-width: 768px) {
  .app {
    padding: calc(var(--bar-h) + 30px) 30px 30px 30px;
  }
}

/* Desktop Layout */
@media (min-width: 1024px) {
  .app {
    padding: 50px 40px;
    justify-content: flex-start;
  }

  /* Hide Mobile Elements */
  .topbar, .dock { display: none !important; }

  /* Hide Desktop Sidebar */
  .desktop-nav {
    display: none !important;
  }
}

/* Mobile Header */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--bar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  z-index: 50;
  background: rgba(5, 5, 7, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: var(--border);
}

.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 18px; letter-spacing: 1px; text-transform: uppercase; }
.brand img { height: 32px; width: auto; }

/* =========================================================
   Components
   ========================================================= */
.menu {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  box-sizing: border-box;
}

@media (min-width: 1024px) {
  .menu {
    max-width: 1000px;
  }
}

.card {
  background: var(--bg-card);
  border: var(--border);
  border-radius: var(--radius);
  padding: 24px;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  transition: 0.2s ease;
}
.card:hover { border-color: var(--accent); }

/* Action Grid - 4 buttons */
.action-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  width: 100%;
}
.action-card {
  text-decoration: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 100px;
  padding: 20px;
}
.action-card h3 {
  font-size: 12px;
  margin: 0;
  color: var(--text-main);
}
.action-icon {
  font-size: 24px;
  margin-bottom: 10px;
}

@media (min-width: 768px) {
  .action-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .action-card {
    min-height: 120px;
  }
  .action-card h3 {
    font-size: 14px;
  }
}

/* Inputs */
input, select, textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: var(--border);
  color: white;
  padding: 14px 16px;
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 15px;
  transition: 0.2s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-dim);
}
label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 6px; display: block; font-weight: 700; }

/* Buttons */
.cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; }

button, .primary, .secondary {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 14px 24px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  border: none;
}

.primary {
  background: var(--accent);
  color: #000;
  box-shadow: 0 0 15px var(--accent-dim);
}
.primary:hover { background: #fff; transform: translateY(-2px); }

.secondary {
  background: transparent;
  color: var(--text-main);
  border: 1px solid rgba(255,255,255,0.2);
}
.secondary:hover { border-color: var(--text-main); background: rgba(255,255,255,0.05); }

/* =========================================================
   Navigation
   ========================================================= */
/* Mobile Dock */
.dock {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 20px;
  padding: 12px 24px;
  background: rgba(15, 15, 20, 0.95);
  backdrop-filter: blur(12px);
  border: var(--border);
  border-radius: 100px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
  z-index: 90;
}
.dock a {
  color: var(--text-muted); text-decoration: none; font-size: 12px; font-weight: 600; text-transform: uppercase; transition: 0.2s;
}
.dock a:hover { color: #fff; }

/* Desktop Sidebar Links */
.desktop-nav a {
  display: block;
  padding: 14px 0;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: 0.2s;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.desktop-nav a:hover { color: var(--accent); padding-left: 8px; }
.desktop-nav .brand { margin-bottom: 40px; }

/* FAB (Mobile Only) */
.fab {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--accent);
  border: 4px solid rgba(20, 20, 25, 1);
  box-shadow: 0 0 20px var(--accent-dim);
  display: grid; place-items: center;
  margin: -40px 0 0 0;
  transition: 0.3s;
  cursor: pointer;
}
.fab:hover { transform: scale(1.1); box-shadow: 0 0 30px var(--accent); }
.fab img { width: 28px; filter: brightness(0); }

/* =========================================================
   Scanner HUD
   ========================================================= */
.video-wrap {
  width: 100%;
  max-width: 900px;
  aspect-ratio: 16/9;
  max-height: 80vh;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255,255,255,0.15);
  margin: 0 auto;
}

/* HUD Corners */
.video-wrap::before {
  content: ''; position: absolute; inset: 15px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px; pointer-events: none; z-index: 2;
}

/* Found state styling */
.video-wrap.found { border-color: var(--success); box-shadow: 0 0 30px rgba(0, 255, 157, 0.2); }

#video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.overlay { position: absolute; inset: 0; pointer-events: auto; }

#model-caption {
  position: absolute; left: 50%; bottom: 30px; transform: translateX(-50%); z-index: 3;
  background: rgba(10, 10, 12, 0.85);
  backdrop-filter: blur(8px);
  border-left: 3px solid var(--accent);
  padding: 12px 20px;
  min-width: 220px;
  color: #fff;
  border-radius: 0 8px 8px 0;
}
#model-caption strong { display: block; font-family: var(--font-mono); text-transform: uppercase; color: var(--accent); font-size: 12px; margin-bottom: 4px; }

/* Utilities */
.hidden { display: none !important; }
.screen {
  display: none;
  width: 100%;
  max-width: 1200px;
  flex-direction: column;
  align-items: center;
  flex: 1;
  box-sizing: border-box;
}
.screen.active {
  display: flex;
}
#scanner.active {
  justify-content: center;
  align-items: center;
  padding: 0;
  max-width: none;
}

/* Intro Logo Animation */
.intro-logo {
  width: 120px; /* Bigger logo */
  height: auto;
  margin-bottom: 24px;
  filter: drop-shadow(0 0 15px var(--accent));
  animation: pulse 2s infinite;
}
@keyframes pulse { 0% { opacity: 0.8; } 50% { opacity: 1; transform: scale(1.02); } 100% { opacity: 0.8; } }

/* Scanner Controls Bar */
.scanner-controls {
  position: absolute;
  top: 15px;
  right: 15px;
  display: flex;
  gap: 10px;
  z-index: 30;
}
.scanner-controls button {
  padding: 10px 16px;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  backdrop-filter: blur(10px);
}
.scanner-controls button:hover {
  border-color: var(--accent);
  background: rgba(0, 229, 255, 0.1);
}

/* Desktop Scanner Layout */
@media (min-width: 1024px) {
  #scanner.active {
    position: fixed;
    inset: 0;
    min-height: 100vh;
    padding: 40px;
    z-index: 200;
    background: var(--bg-deep);
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .video-wrap {
    max-width: 1200px;
    width: 90%;
    max-height: calc(100vh - 80px);
  }
}

/* Tablet Tweaks */
@media (min-width: 769px) and (max-width: 1023px) {
  .video-wrap {
    max-width: 700px;
    aspect-ratio: 16/9;
  }
}

/* Fullscreen Mode */
.video-wrap:fullscreen,
.video-wrap:-webkit-full-screen {
  max-width: 100%;
  width: 100%;
  max-height: 100%;
  height: 100%;
  border-radius: 0;
  border: none;
}
.video-wrap:fullscreen #video,
.video-wrap:-webkit-full-screen #video {
  object-fit: contain;
}
.video-wrap:fullscreen .scanner-controls,
.video-wrap:-webkit-full-screen .scanner-controls {
  top: 20px;
  right: 20px;
}

/* Mobile Tweaks */
@media (max-width: 768px) {
  .video-wrap {
    border-radius: 0;
    width: 100vw;
    height: 100vh;
    max-height: none;
    max-width: none;
    aspect-ratio: unset;
    border: none;
    position: fixed;
    inset: 0;
    z-index: 0;
  }
  .app { padding-bottom: 100px; } /* Space for dock */
  #model-caption { bottom: 120px; } /* Move caption above dock */
  .scanner-controls { top: 10px; right: 10px; }
  .menu { padding: 0; }
}

/* Hide dock on tablet when topbar is still visible */
@media (min-width: 769px) and (max-width: 1023px) {
  .dock { display: none; }
  .app { padding-bottom: 30px; }
}