/* ==========================================================================
   VideoGolondrinas PRO - Mobile & Modal Fix Styling System
   ========================================================================== */

:root {
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Color Palette */
  --bg-dark: #090b11;
  --bg-card: rgba(18, 22, 36, 0.75);
  --bg-card-hover: rgba(26, 32, 53, 0.88);

  --accent-primary: #6366f1; /* Indigo */
  --accent-primary-hover: #4f46e5;
  --accent-secondary: #8b5cf6; /* Purple */
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-emerald-hover: #059669;
  --accent-rose: #f43f5e;
  --accent-rose-hover: #e11d48;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --glass-bg: rgba(15, 23, 42, 0.7);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-border-light: rgba(255, 255, 255, 0.2);
  --glass-glow: 0 8px 32px 0 rgba(99, 102, 241, 0.15);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-full: 9999px;

  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

/* Utility Hidden Rule - HIGH PRIORITY */
.hidden {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Modals Overlay System */
.lightbox-modal {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox-modal.hidden {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.lightbox-backdrop {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(5, 7, 12, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.lightbox-content {
  position: relative;
  z-index: 10000;
  max-width: 90vw;
  max-height: 90vh;
  width: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  margin: auto;
}

.btn-close-modal {
  position: absolute;
  top: -14px; right: -14px;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
  transition: transform var(--transition-fast);
}

.btn-close-modal:hover {
  transform: scale(1.1);
}

.lightbox-img-container {
  overflow: auto;
  max-height: 72vh;
  border-radius: var(--radius-sm);
  background: #000;
  display: flex;
  justify-content: center;
  align-items: center;
}

.lightbox-img-container img {
  max-width: 100%;
  max-height: 72vh;
  object-fit: contain;
}

.lightbox-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.lightbox-info {
  display: flex;
  gap: 10px;
  align-items: center;
}

.timestamp-tag, .dim-tag {
  background: rgba(255, 255, 255, 0.08);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

/* Background Orbs */
.app-background {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.35;
  animation: floatOrb 18s ease-in-out infinite alternate;
}

.orb-1 { top: -10%; left: -10%; width: 50vw; height: 50vw; background: radial-gradient(circle, var(--accent-primary) 0%, transparent 70%); }
.orb-2 { bottom: -15%; right: -10%; width: 55vw; height: 55vw; background: radial-gradient(circle, var(--accent-secondary) 0%, transparent 70%); animation-delay: -6s; }
.orb-3 { top: 40%; left: 30%; width: 35vw; height: 35vw; background: radial-gradient(circle, var(--accent-cyan) 0%, transparent 70%); animation-delay: -12s; }

@keyframes floatOrb {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, 60px) scale(1.08); }
  100% { transform: translate(-30px, 30px) scale(0.95); }
}

/* Layout */
.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 60px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.card-glass {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  padding: 20px;
}

/* Header & Brand Logo */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-icon-wrapper {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(99, 102, 241, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.15);
  background: #000;
}

.brand-logo-img { width: 100%; height: 100%; object-fit: cover; }

.brand-text h1 {
  font-size: 1.35rem; font-weight: 800; letter-spacing: -0.5px; display: flex; align-items: center; gap: 6px;
}

.badge-pro { font-size: 0.65rem; background: linear-gradient(135deg, var(--accent-cyan), var(--accent-primary)); padding: 2px 8px; border-radius: var(--radius-full); font-weight: 700; }
.brand-text p { font-size: 0.8rem; color: var(--text-muted); }

/* Banner PWA */
.pwa-install-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
  border: 1px solid rgba(99, 102, 241, 0.4); padding: 12px 16px; border-radius: var(--radius-md); position: relative;
}

.banner-content { display: flex; align-items: center; gap: 12px; }
.banner-logo { width: 40px; height: 40px; border-radius: var(--radius-sm); }
.banner-text strong { font-size: 0.9rem; }
.banner-text p { font-size: 0.78rem; color: var(--text-muted); }

.btn-close-banner { position: absolute; top: 4px; right: 8px; background: transparent; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; }

/* Dropzone */
.dropzone {
  border: 2px dashed var(--glass-border-light);
  border-radius: var(--radius-md);
  padding: 48px 16px;
  text-align: center;
  cursor: pointer;
  background: rgba(15, 23, 42, 0.3);
}

.dropzone-logo-icon {
  width: 64px; height: 64px; border-radius: 50%; object-fit: cover; box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4); margin-bottom: 14px;
}

.dropzone h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: 6px; }
.dropzone p { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 18px; }

/* Video Player Container */
.player-container { display: flex; flex-direction: column; gap: 14px; }

.video-wrapper {
  position: relative; width: 100%; background: #000; border-radius: var(--radius-md);
  overflow: hidden; display: flex; justify-content: center; align-items: center; max-height: 480px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6); user-select: none;
}

video { max-width: 100%; max-height: 480px; width: auto; height: auto; display: block; object-fit: contain; }

.touch-hint {
  position: absolute; top: 50%; transform: translateY(-50%); padding: 12px 18px;
  background: rgba(99, 102, 241, 0.7); backdrop-filter: blur(8px); color: #fff; border-radius: var(--radius-full);
  font-family: var(--font-mono); font-weight: 700; font-size: 0.9rem; opacity: 0; pointer-events: none; transition: opacity 0.2s ease; z-index: 8;
}

.touch-hint-left { left: 20px; }
.touch-hint-right { right: 20px; }
.touch-hint.show { opacity: 1; }

.video-overlay-msg {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(9, 11, 17, 0.85); backdrop-filter: blur(8px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; z-index: 10;
}

.spinner { width: 38px; height: 38px; border: 3px solid rgba(255, 255, 255, 0.15); border-top-color: var(--accent-primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Meta & Seek Bar */
.video-meta-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 8px 14px; background: rgba(255, 255, 255, 0.03); border-radius: var(--radius-sm); font-size: 0.8rem; }
.meta-item { display: flex; align-items: center; gap: 4px; }
.meta-label { color: var(--text-muted); }
.meta-val { font-weight: 600; font-family: var(--font-mono); }

.timeline-controls { display: flex; flex-direction: column; gap: 6px; }
.time-display { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 0.9rem; font-weight: 500; color: var(--accent-cyan); }

.mobile-slider { height: 12px !important; }
input[type="range"]::-webkit-slider-thumb { width: 24px !important; height: 24px !important; }

/* Action Control Bar */
.player-action-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; }
.btn-group { display: flex; align-items: center; gap: 8px; }
.touch-target { min-height: 44px; touch-action: manipulation; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: var(--radius-sm); font-family: var(--font-main); font-size: 0.9rem; font-weight: 600; border: none; cursor: pointer; transition: all var(--transition-fast); }
.btn-primary { background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary)); color: #fff; box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35); }
.btn-secondary { background: rgba(255, 255, 255, 0.08); color: var(--text-main); border: 1px solid var(--glass-border); }
.btn-accent { background: linear-gradient(135deg, var(--accent-cyan), var(--accent-primary)); color: #fff; box-shadow: 0 4px 16px rgba(6, 182, 212, 0.35); }
.btn-success { background: linear-gradient(135deg, var(--accent-emerald), #059669); color: #fff; box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-danger-ghost { background: rgba(244, 63, 94, 0.12); color: var(--accent-rose); border: 1px solid rgba(244, 63, 94, 0.25); }

.btn-icon { width: 44px; height: 44px; padding: 0; border-radius: var(--radius-sm); }
.btn-play { width: 52px; height: 52px; border-radius: 50%; }

.btn-lg { padding: 14px 24px; font-size: 0.95rem; border-radius: var(--radius-md); }
.btn-sm { padding: 8px 14px; font-size: 0.82rem; border-radius: var(--radius-sm); }
.btn-block { width: 100%; }

/* Extractor Settings Panel */
.extractor-panel { display: flex; flex-direction: column; gap: 16px; }
.panel-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--glass-border); padding-bottom: 12px; }
.panel-header h2 { font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }

.tabs { display: flex; background: rgba(0, 0, 0, 0.3); padding: 4px; border-radius: var(--radius-md); border: 1px solid var(--glass-border); }
.tab-btn { padding: 8px 14px; border-radius: var(--radius-sm); background: transparent; color: var(--text-muted); border: none; font-size: 0.82rem; font-weight: 600; cursor: pointer; }
.tab-btn.active { background: var(--accent-primary); color: #fff; }

.tab-content { display: none; }
.tab-content.active { display: block; }

.config-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; align-items: flex-end; }
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-group label { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }

.input-with-unit { position: relative; display: flex; align-items: center; }
.input-with-unit input { padding-right: 75px; }
.input-with-unit .unit { position: absolute; right: 12px; font-size: 0.78rem; color: var(--text-dim); }

input[type="number"], select { width: 100%; padding: 12px 14px; background: rgba(15, 23, 42, 0.6); border: 1px solid var(--glass-border-light); border-radius: var(--radius-sm); color: var(--text-main); font-size: 0.9rem; outline: none; }

/* Gallery & Frame Grid */
.gallery-section { display: flex; flex-direction: column; gap: 16px; }
.gallery-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--glass-border); padding-bottom: 14px; }
.gallery-title h2 { font-size: 1.1rem; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.est-size-badge { font-size: 0.78rem; background: rgba(255, 255, 255, 0.08); padding: 4px 10px; border-radius: var(--radius-full); }

.gallery-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.frames-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.frame-card { position: relative; background: rgba(15, 23, 42, 0.6); border: 1px solid var(--glass-border); border-radius: var(--radius-md); overflow: hidden; display: flex; flex-direction: column; }
.frame-card.selected { border-color: var(--accent-emerald); box-shadow: 0 0 0 2px var(--accent-emerald); }

.frame-thumb-wrapper { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; overflow: hidden; }
.frame-thumb-wrapper img { width: 100%; height: 100%; object-fit: cover; }
.frame-checkbox { position: absolute; top: 6px; left: 6px; z-index: 5; width: 24px; height: 24px; accent-color: var(--accent-emerald); }
.frame-overlay-actions { position: absolute; bottom: 0; left: 0; right: 0; padding: 6px; background: linear-gradient(to top, rgba(0,0,0,0.85), transparent); display: flex; justify-content: flex-end; gap: 4px; }

.frame-info-bar { padding: 8px 10px; display: flex; align-items: center; justify-content: space-between; font-size: 0.75rem; }
.frame-time { font-family: var(--font-mono); color: var(--accent-cyan); }
.empty-gallery-msg { text-align: center; padding: 30px 16px; color: var(--text-muted); font-size: 0.9rem; }

.pwa-guide-logo { width: 56px; height: 56px; border-radius: var(--radius-md); margin-bottom: 10px; }
.ios-steps { margin: 14px 0; padding-left: 20px; text-align: left; font-size: 0.85rem; display: flex; flex-direction: column; gap: 8px; color: var(--text-muted); }

/* Toasts */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 20000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--bg-card); border: 1px solid var(--glass-border); backdrop-filter: blur(12px); padding: 10px 16px; border-radius: var(--radius-sm); font-size: 0.85rem; display: flex; align-items: center; gap: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.toast.toast-success { border-left: 4px solid var(--accent-emerald); }
.toast.toast-error { border-left: 4px solid var(--accent-rose); }

/* Responsive */
@media (max-width: 600px) {
  .app-container { padding: 12px 10px 40px; gap: 16px; }
  .brand-icon-wrapper { width: 42px; height: 42px; }
  .brand-text h1 { font-size: 1.15rem; }
  .dropzone { padding: 32px 12px; }
  .mobile-btn-group { width: 100%; justify-content: space-between; }
  .btn-snap-mobile { width: 100%; font-size: 0.9rem; }
  .frames-grid { grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 10px; }
}
