/* UltimaQR PWA Styles */

:root {
  --bg: #0a0a1a;
  --surface: #1a1a2e;
  --surface-hover: #222240;
  --border: #333;
  --text: #e0e0e0;
  --text-dim: #888;
  --accent: #e94560;
  --accent-hover: #c73650;
  --success: #2ecc71;
  --warning: #f39c12;
  --error: #e74c3c;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

.header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.header-actions {
  display: flex;
  gap: 8px;
}

/* Main content */
.main {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* Scanner view */
.scanner {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.scanner video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.scanner-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-dim);
  text-align: center;
  padding: 40px;
}

.scanner-placeholder svg {
  width: 64px;
  height: 64px;
  opacity: 0.3;
}

/* Scan guide overlay */
.scan-guide {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 260px;
  height: 260px;
  border: 2px solid rgba(233, 69, 96, 0.3);
  border-radius: 12px;
  pointer-events: none;
  transition: border-color 0.2s;
}

.scan-guide.active {
  border-color: var(--success);
  box-shadow: 0 0 20px rgba(46, 204, 113, 0.2);
}

.scan-guide-line {
  position: absolute;
  left: 10%;
  right: 10%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  top: 50%;
  animation: scanLine 2s ease-in-out infinite;
}

@keyframes scanLine {
  0%, 100% { top: 10%; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  50% { top: 90%; }
}

/* Status bar */
.status-bar {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-dim);
  z-index: 15;
  white-space: nowrap;
  transition: all 0.3s;
}

.status-bar .active-status {
  color: var(--success);
}

/* Result type badge */
.result-type {
  display: inline-block;
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.scan-guide::before,
.scan-guide::after {
  content: '';
  position: absolute;
  width: 30px;
  height: 30px;
  border-color: var(--accent);
  border-style: solid;
}

.scan-guide::before {
  top: -2px;
  left: -2px;
  border-width: 3px 0 0 3px;
  border-radius: 8px 0 0 0;
}

.scan-guide::after {
  bottom: -2px;
  right: -2px;
  border-width: 0 3px 3px 0;
  border-radius: 0 0 8px 0;
}

/* Result panel */
.results-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  max-height: 50%;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 20;
  overflow: hidden;
}

.results-panel.open {
  transform: translateY(0);
}

.results-handle {
  display: flex;
  justify-content: center;
  padding: 8px;
  cursor: grab;
}

.results-handle::after {
  content: '';
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
}

.results-content {
  padding: 0 16px 16px;
  overflow-y: auto;
  max-height: calc(50% - 20px);
}

/* Result card */
.result-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
  transition: border-color 0.2s;
}

.result-card:hover {
  border-color: var(--accent);
}

.result-data {
  font-family: var(--mono);
  font-size: 14px;
  word-break: break-all;
  margin-bottom: 8px;
  line-height: 1.4;
}

.result-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.result-actions {
  display: flex;
  gap: 8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

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

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.btn-accent:hover {
  background: var(--accent-hover);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

/* HUD */
.hud {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 8px 12px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  color: var(--success);
  z-index: 15;
  pointer-events: none;
  user-select: none;
}

/* Camera controls */
.camera-controls {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  z-index: 15;
}

/* History panel */
.history-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 360px;
  max-width: 100%;
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 30;
  display: flex;
  flex-direction: column;
}

.history-panel.open {
  transform: translateX(0);
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.history-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.history-item {
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
}

.history-item:hover {
  background: var(--surface-hover);
}

.history-item-data {
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-all;
  margin-bottom: 4px;
}

.history-item-time {
  font-size: 11px;
  color: var(--text-dim);
}

.history-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-dim);
  font-size: 14px;
}

/* File upload overlay */
.upload-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.upload-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.upload-zone {
  width: 90%;
  max-width: 400px;
  padding: 48px 24px;
  border: 2px dashed var(--border);
  border-radius: 16px;
  text-align: center;
  color: var(--text-dim);
  transition: border-color 0.2s;
}

.upload-zone.dragover {
  border-color: var(--accent);
  color: var(--text);
}

.upload-zone svg {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  transition: all 0.3s;
  z-index: 50;
  pointer-events: none;
}

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

/* Responsive */
@media (max-width: 600px) {
  .history-panel {
    width: 100%;
  }

  .scan-guide {
    width: 200px;
    height: 200px;
  }

  .hud {
    font-size: 10px;
    padding: 6px 10px;
  }
}

@media (min-width: 1024px) {
  .main {
    max-width: 1200px;
    margin: 0 auto;
  }

  .scan-guide {
    width: 320px;
    height: 320px;
  }
}

/* Animations */
@keyframes pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.loading {
  animation: pulse 1.5s infinite;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Visually hidden (for screen readers) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
