/* =========================================================
   Hello Auto Dashcam — Premium Responsive Stylesheet
   ========================================================= */

:root {
  --bg-main: #090d16;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(26, 36, 56, 0.85);
  --bg-input: rgba(13, 19, 32, 0.85);
  
  --primary: #38bdf8;
  --primary-glow: rgba(56, 189, 248, 0.25);
  --accent: #10b981;
  --accent-glow: rgba(16, 185, 129, 0.25);
  --warning: #f59e0b;
  --danger: #ef4444;
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-active: rgba(56, 189, 248, 0.5);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 9999px;
  
  --transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Ambient glow orbs */
.glow-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.15;
}
.orb-1 {
  width: 450px;
  height: 450px;
  background: #38bdf8;
  top: -100px;
  right: -100px;
}
.orb-2 {
  width: 500px;
  height: 500px;
  background: #10b981;
  bottom: -150px;
  left: -150px;
}

.app-container {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

/* ================= HEADER ================= */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.logo-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(16, 185, 129, 0.2));
  border: 1px solid rgba(56, 189, 248, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  box-shadow: 0 0 20px var(--primary-glow);
}

.brand-text h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand-text h1 span {
  color: var(--primary);
}
.subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.header-badges {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  font-size: 0.82rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
}
.status-badge.connected .status-dot {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}
.status-badge.error .status-dot {
  background: var(--danger);
}

/* ================= NAVIGATION TABS ================= */
.nav-tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.75rem;
  margin-bottom: 1.5rem;
  scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1.15rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-main);
}

.tab-btn.active {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 15px var(--primary-glow);
}

.tab-step {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}
.tab-btn.active .tab-step {
  background: var(--primary);
  color: #000;
}

.badge-counter {
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #000;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ================= CARDS & LAYOUTS ================= */
.glass-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.75rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.card-header {
  margin-bottom: 1.5rem;
}
.card-header.space-between {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
}

.card-badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-sm);
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.card-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
}
.card-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease-out;
}

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

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

@media (max-width: 768px) {
  .grid-2-col {
    grid-template-columns: 1fr;
  }
}

/* ================= SCANNER (TAB 1) ================= */
.scanner-viewport {
  width: 100%;
  aspect-ratio: 4/3;
  max-height: 340px;
  background: #060911;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#qr-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scan-frame {
  width: 65%;
  height: 65%;
  border: 2px solid rgba(56, 189, 248, 0.8);
  border-radius: 12px;
  position: relative;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.4);
}

.laser-scanner {
  position: absolute;
  width: 65%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #38bdf8, transparent);
  box-shadow: 0 0 8px #38bdf8;
  animation: scanLaser 2s infinite ease-in-out;
}

@keyframes scanLaser {
  0% { top: 20%; opacity: 0.2; }
  50% { top: 75%; opacity: 1; }
  100% { top: 20%; opacity: 0.2; }
}

.scan-hint {
  position: absolute;
  bottom: 12px;
  font-size: 0.8rem;
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.6);
  padding: 0.3rem 0.8rem;
  border-radius: var(--radius-pill);
}

.camera-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-dim);
  text-align: center;
  padding: 1rem;
}
.camera-placeholder p {
  font-weight: 600;
  color: var(--text-muted);
}
.camera-placeholder span {
  font-size: 0.8rem;
}

.scanner-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

/* Data extracted panel */
.panel-box {
  background: var(--bg-input);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  padding: 1.25rem;
}

.panel-box h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--primary);
}

.data-field-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.data-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
  transition: var(--transition);
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 10px var(--primary-glow);
}

.field-with-btn {
  display: flex;
  gap: 0.4rem;
}
.btn-copy, .btn-toggle-pwd, .btn-refresh {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 0 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.btn-copy:hover, .btn-toggle-pwd:hover, .btn-refresh:hover {
  background: rgba(255, 255, 255, 0.15);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.manual-json-details {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.manual-json-details summary {
  cursor: pointer;
  padding: 0.3rem 0;
}
.manual-json-details textarea {
  margin-top: 0.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
}

.next-step-bar {
  margin-top: 1.25rem;
}

/* ================= WI-FI CONNECTION (TAB 2) ================= */
.wifi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 768px) {
  .wifi-grid {
    grid-template-columns: 1fr;
  }
}

.wifi-qr-card, .pc-wifi-card {
  background: var(--bg-input);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  padding: 1.5rem;
}

.qr-code-holder {
  display: flex;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.qr-canvas-wrapper {
  width: 220px;
  height: 220px;
  background: #ffffff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}
.qr-canvas-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qr-empty-state {
  color: #64748b;
  text-align: center;
  font-size: 0.8rem;
  padding: 1rem;
}

.wifi-instructions h4, .pc-wifi-card h4 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.wifi-instructions p, .pc-wifi-card p {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.credentials-badge {
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
  margin-bottom: 1rem;
}
.credentials-badge div {
  margin-bottom: 0.25rem;
}
.credentials-badge strong {
  color: var(--primary);
}

.gateway-detect-box {
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-top: 1.25rem;
  border: 1px solid var(--border-subtle);
}

.gateway-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.gateway-ip-badge {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.4rem 0;
  font-size: 1.2rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
}

.tag-status {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-pill);
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent);
  font-family: inherit;
}

.small-text {
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* ================= DASHCAM TCP (TAB 3) ================= */
.conn-config-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.field-hint {
  display: block;
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.3rem;
}
.field-hint code {
  color: var(--primary);
  font-family: 'JetBrains Mono', monospace;
}

.conn-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* Terminal Console */
.conn-logs-panel {
  background: #060911;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  height: 380px;
}

.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border-subtle);
}

.terminal-dots {
  display: flex;
  gap: 5px;
}
.terminal-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #334155;
}
.terminal-dots span:nth-child(1) { background: #ef4444; }
.terminal-dots span:nth-child(2) { background: #f59e0b; }
.terminal-dots span:nth-child(3) { background: #10b981; }

.terminal-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}
.btn-clear-term {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.75rem;
  cursor: pointer;
}
.btn-clear-term:hover { color: var(--text-main); }

.terminal-body {
  flex: 1;
  padding: 0.85rem;
  overflow-y: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.log-line {
  line-height: 1.4;
  word-break: break-all;
}
.log-line .log-time {
  color: var(--text-dim);
  margin-right: 0.4rem;
}
.log-line.info { color: #94a3b8; }
.log-line.success { color: #10b981; }
.log-line.warning { color: #f59e0b; }
.log-line.error { color: #ef4444; }

/* ================= VIDEOS GRID (TAB 4) ================= */
.download-progress-banner {
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  animation: fadeIn 0.3s ease-out;
}

.progress-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.file-name-progress {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(56, 189, 248, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.stats-progress {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  color: var(--primary);
}

.progress-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #10b981);
  box-shadow: 0 0 10px var(--primary-glow);
  transition: width 0.3s ease;
}

.batch-counter-row {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  text-align: right;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.video-card {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.85rem;
  transition: var(--transition);
}
.video-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
  transform: translateY(-2px);
}

.video-card-top {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.video-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.video-meta h4 {
  font-size: 0.95rem;
  font-weight: 600;
  word-break: break-all;
  line-height: 1.3;
}
.video-meta .video-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.video-card-bottom {
  display: flex;
  gap: 0.5rem;
}

.empty-videos-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-dim);
}
.empty-videos-state svg {
  margin-bottom: 0.75rem;
}
.empty-videos-state h3 {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

/* ================= SAVED VIDEOS (TAB 5) ================= */
.player-wrapper {
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-subtle);
}

.player-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.88rem;
  font-weight: 500;
}

.btn-close-player {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}

.video-container {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
}
.video-container video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.saved-files-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.saved-file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.15rem;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  flex-wrap: wrap;
  gap: 0.75rem;
}
.saved-file-row:hover {
  background: var(--bg-card-hover);
}

.file-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.file-name {
  font-weight: 500;
  font-size: 0.9rem;
}
.file-size-date {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.file-row-actions {
  display: flex;
  gap: 0.5rem;
}

/* ================= BUTTONS & UTILITIES ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
}

.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
}
.btn-lg {
  padding: 0.85rem 1.5rem;
  font-size: 0.95rem;
}
.w-100 { width: 100%; }

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: #ffffff;
  box-shadow: 0 4px 15px var(--primary-glow);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(56, 189, 248, 0.4);
}

.btn-accent {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #ffffff;
  box-shadow: 0 4px 15px var(--accent-glow);
}
.btn-accent:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.btn-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.status-msg {
  font-size: 0.85rem;
  margin-top: 0.6rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  display: none;
}
.status-msg.info { display: block; background: rgba(56, 189, 248, 0.1); color: var(--primary); }
.status-msg.success { display: block; background: rgba(16, 185, 129, 0.1); color: var(--accent); }
.status-msg.error { display: block; background: rgba(239, 68, 68, 0.1); color: var(--danger); }

/* ================= FOOTER ================= */
.app-footer {
  margin-top: 3rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border-subtle);
  padding-top: 1.5rem;
}
