/* ===========================
   VARIABLES & RESET
=========================== */
:root {
  --bg: #0a0a0f;
  --surface: #13131a;
  --surface2: #1c1c27;
  --border: #2a2a3a;
  --accent: #c8f542;
  --accent2: #7b5cff;
  --text: #eaeaf0;
  --text-muted: #7a7a90;
  --radius: 14px;
  --radius-sm: 8px;
  --mono: "Space Mono", monospace;
  --display: "Syne", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--display);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Background grid texture */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.25;
  pointer-events: none;
  z-index: 0;
}

/* ===========================
   HEADER
=========================== */
.header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

@media (max-width: 640px) {
  .header {
    padding: 1rem 1.5rem;
  }
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.logo-icon {
  color: var(--accent);
  font-size: 1.4rem;
  animation: spin 8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.badge {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--accent);
  background: rgba(200, 245, 66, 0.1);
  border: 1px solid rgba(200, 245, 66, 0.3);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ===========================
   MAIN LAYOUT
=========================== */
.main {
  position: relative;
  z-index: 1;
  flex: 1;
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
  padding: 3rem 1.5rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 3rem;
}

@media (max-width: 640px) {
  .main {
    padding: 2rem 1rem 3rem;
    gap: 2rem;
  }
}

/* ===========================
   HERO
=========================== */
.hero {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.hero-title {
  font-size: clamp(2.5rem, 6vw, 5.5rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-stretch: normal;
  font-style: normal;
}

.hero-title em {
  font-style: normal;
  color: var(--accent);
  display: block;
  font-stretch: normal;
}

.hero-sub {
  max-width: 460px;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.6;
  font-weight: 400;
}

/* ===========================
   UPLOAD SECTION
=========================== */
.upload-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.upload-zone {
  position: relative;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    border-color 0.2s,
    background 0.2s;
  overflow: hidden;
}

@media (max-width: 640px) {
  .upload-zone {
    min-height: 180px;
  }
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(200, 245, 66, 0.04);
}

.upload-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  text-align: center;
  padding: 2rem;
  transition: opacity 0.3s;
}

.upload-icon-wrap {
  width: 56px;
  height: 56px;
  background: var(--surface2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

.upload-icon {
  width: 28px;
  height: 28px;
}

.upload-text {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.upload-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

/* Preview */
.preview-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--surface);
  border-radius: calc(var(--radius) - 2px);
}

.remove-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 5;
}

.remove-btn:hover {
  background: #e53935;
}

/* ===========================
   BUTTONS
=========================== */
.action-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .action-buttons {
    gap: 0.5rem;
  }
  
  .btn {
    padding: 0.65rem 1rem;
    font-size: 0.8rem;
  }
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-family: var(--display);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.18s;
  text-decoration: none;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(200, 245, 66, 0.05);
}

.btn-primary {
  background: var(--accent);
  color: #0a0a0f;
}

.btn-primary:hover:not(:disabled) {
  background: #d4fc52;
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(200, 245, 66, 0.3);
}

.btn-primary:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 0.5rem 0;
}

.btn-ghost:hover {
  color: var(--text);
}

.full-width {
  width: 100%;
  justify-content: center;
}

/* ===========================
   CAMERA MODAL
=========================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem;
  animation: fadeUp 0.25s ease;
}

@media (max-width: 640px) {
  .modal-box {
    max-width: 95vw;
    padding: 1rem;
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
}

.close-modal {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.25rem;
  transition: color 0.2s;
}

.close-modal:hover {
  color: var(--text);
}

.video-wrap {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
  aspect-ratio: 4/3;
}

#videoEl {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-overlay {
  position: absolute;
  inset: 0;
  border: 2px solid rgba(200, 245, 66, 0.3);
  border-radius: var(--radius-sm);
  pointer-events: none;
}

/* ===========================
   RESULTS
=========================== */
.results-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  animation: fadeUp 0.3s ease;
}

.results-header {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  position: relative;
}

.results-header #closeLiveCamera {
  position: absolute;
  top: 0;
  right: 0;
}

.results-tag {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-transform: uppercase;
}

.results-title {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

/* Cámara en vivo integrada */
.live-camera-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1rem;
  max-width: 100%;
}

.live-video-wrap {
  position: relative;
  width: 100%;
  max-height: 480px;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: calc(var(--radius) - 1px);
  overflow: hidden;
}

.live-video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1rem;
}

@media (max-width: 900px) {
  .results-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .results-grid {
    grid-template-columns: 1fr;
  }
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 640px) {
  .result-card {
    padding: 1.25rem;
    min-height: 180px;
  }
}

.result-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.8rem;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.result-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.result-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.result-text {
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.7;
  font-family: var(--mono);
  white-space: pre-wrap;
}

.thumb-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 4/3;
}

.thumb-wrap.hidden {
  display: none !important;
}

.thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ===========================
   FOOTER
=========================== */
.footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-family: var(--mono);
}

.footer strong {
  color: var(--text);
}

/* ===========================
   UTILITIES
=========================== */
.hidden {
  display: none !important;
}
