/* ===========================
   VARIABLES & RESET (MAIMBAQ Colors - New Palette)
=========================== */
:root {
  --bg: #F5F1EB;
  --surface: #ffffff;
  --surface2: #F0EBE3;
  --border: #E0D5CB;
  --accent: #B96863;
  --accent-dark: #8B4D48;
  --accent2: #8B6F47;
  --text: #1E1E1E;
  --text-muted: #6B6B6B;
  --radius: 20px;
  --radius-sm: 12px;
  --mono: "Nunito", sans-serif;
  --display: "Nunito", 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;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 0 12px;
  position: relative;
}

/* Subtle radial texture */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(
      circle at 10% 10%,
      rgba(255, 255, 255, 0.02),
      transparent 8%
    ),
    radial-gradient(
      circle at 90% 90%,
      rgba(255, 255, 255, 0.01),
      transparent 10%
    );
  pointer-events: none;
  z-index: 0;
}

/* ===========================
   HEADER
=========================== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  height: 60px;
  max-width: 920px;
  margin: 0 auto;
  position: relative;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--text);
  transition: opacity 0.2s;
}

.logo:hover {
  opacity: 0.8;
}

.logo-icon {
  color: var(--accent);
  font-size: 1.4rem;
  animation: spin 8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.logo-text {
  color: var(--accent);
  font-weight: 900;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

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

/* ===========================
   MAIN LAYOUT
=========================== */
.main {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  padding: 3rem 0 4rem;
  display: flex;
  flex-direction: column;
  gap: 3rem;
}

@media (max-width: 640px) {
  .main {
    padding: 2rem 0 3rem;
    gap: 2rem;
  }
}

/* ===========================
   HERO
=========================== */
.hero {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 0 1.5rem;
}

.hero-title {
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.hero-title em {
  font-style: normal;
  color: var(--accent);
  display: block;
}

.hero-sub {
  max-width: 460px;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  font-weight: 400;
}

/* ===========================
   UPLOAD SECTION
=========================== */
.upload-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 0 1.5rem;
}

.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: all 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(245, 166, 35, 0.05);
}

.upload-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  text-align: center;
  padding: 2rem;
}

.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: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.upload-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* 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: #C4645A;
}

/* ===========================
   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(245, 166, 35, 0.05);
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(245, 166, 35, 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(26, 16, 8, 0.9);
  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(245, 166, 35, 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;
  padding: 0 1.5rem;
}

.results-header {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  position: relative;
}

.results-header #closeLiveCamera {
  position: absolute;
  top: 0;
  right: 0;
}

.results-tag {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-transform: uppercase;
  font-weight: 600;
}

.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-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;
  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;
}

/* ===========================
   UTILITIES
=========================== */
.hidden {
  display: none !important;
}

/* ===========================
   BOTTOM NAVIGATION (MAIMBAQ Integration)
=========================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100vw;
  background: #fff;
  border-top: 1px solid #eee;
  z-index: 200;
  transition: transform 200ms ease;
  transform: translateY(0);
}

.bottom-nav.hide {
  transform: translateY(100%);
}

.bottom-nav-inner {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  max-width: 920px;
  margin: 0 auto;
  padding: 0 10px;
  width: 100%;
}

.nav-item {
  text-decoration: none;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-family: "Nunito", sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: #6B6B6B;
  padding: 6px 10px;
  border-radius: 30px;
  min-width: 72px;
  height: 48px;
  box-sizing: border-box;
  border: 2px solid transparent;
  transition:
    background-color 150ms ease,
    color 150ms ease;
}

.nav-item .icon {
  font-size: 18px;
}

.nav-item:active {
  transform: none;
}

.nav-item.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

/* Adjust main content to accommodate fixed bottom nav */
.main {
  padding-bottom: calc(70px + 80px);
}
