/* ═══════════════════════════════════════════════════════════════
   MediaVault — components.css
   Modern, High-Performance UI Components (Mobile-Optimized)
   ═══════════════════════════════════════════════════════════════ */

/* ─── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  position: relative;
  overflow: hidden;
  text-align: center;
}

.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* Primary — Jio Blue */
.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: var(--shadow-btn);
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 6px 20px rgba(0,87,217,0.4);
  transform: translateY(-1px);
}

/* Secondary */
.btn-secondary {
  background: #ffffff;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-secondary:hover {
  background: var(--primary-light);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-normal);
}
.btn-ghost:hover {
  color: var(--primary);
  border-color: var(--primary-border);
  background: var(--primary-light);
}

/* Danger */
.btn-danger {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}
.btn-danger:hover { background: #fee2e2; }

/* Icon Button */
.btn-icon { width: 42px; height: 42px; min-width: 42px; padding: 0; border-radius: var(--radius-md); }

/* Sizes */
.btn-sm  { min-height: 34px; padding: 6px 14px; font-size: var(--font-size-xs); border-radius: var(--radius-sm); }
.btn-lg  { min-height: 48px; padding: 12px 28px; font-size: var(--font-size-md); border-radius: var(--radius-lg); }
.btn-xl  { min-height: 52px; padding: 14px 34px; font-size: var(--font-size-lg); border-radius: var(--radius-lg); font-weight: 700; }

/* Loading state */
.btn.loading .btn-text { opacity: 0; }
.btn.loading::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ─── Input Fields ─────────────────────────────────────────────── */
.input-group { display: flex; flex-direction: column; gap: 6px; }

.input-label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
}

.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-normal);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 16px; /* iOS auto-zoom prevention */
  transition: all var(--transition-fast);
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,87,217,0.12);
  background: var(--bg-input);
}

.input::placeholder { color: #94a3b8; font-size: 14.5px; }
.input:focus-visible { outline: none; }

[data-theme="dark"] .input {
  background: #16203b;
  border-color: rgba(255,255,255,0.12);
  color: #f8fafc;
}
[data-theme="dark"] .input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.25); }

/* Search Input */
.search-wrapper { position: relative; }

.search-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
  display: flex; align-items: center;
}

.search-wrapper .input { padding-left: 42px; }

/* ─── Hero Search Bar (Fully Responsive) ───────────────────────── */
.hero-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-primary);
  border: 1.5px solid var(--border-normal);
  border-radius: var(--radius-xl);
  padding: 6px 6px 6px 18px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
  transition: all var(--transition-normal);
  max-width: 680px;
  width: 100%;
}

.hero-search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,87,217,0.15), 0 4px 20px rgba(0,0,0,0.08);
}

.hero-search input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 16px; /* Prevents iOS mobile zoom */
  font-weight: 500;
  min-width: 0;
  padding: 8px 0;
}
.hero-search input::placeholder { color: #94a3b8; font-size: 14.5px; }
.hero-search input:focus { outline: none; }

.btn-paste {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-card);
  border: 1px solid var(--border-normal);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  padding: 6px 13px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}
.btn-paste:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary-border);
}
.btn-paste:active { transform: scale(0.95); }

.hero-search .btn { flex-shrink: 0; }

[data-theme="dark"] .hero-search {
  background: #131d35;
  border-color: rgba(255,255,255,0.12);
}
[data-theme="dark"] .hero-search input { color: #f8fafc; }
[data-theme="dark"] .btn-paste {
  background: #1e293b;
  border-color: rgba(255,255,255,0.15);
  color: #cbd5e1;
}
[data-theme="dark"] .btn-paste:hover {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

/* Share and QR Buttons */
.btn-share {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f0fdf4;
  color: #16a34a;
  border: 1.5px solid #bbf7d0;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-xs);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.btn-share:hover {
  background: #dcfce7;
  transform: translateY(-1px);
}
[data-theme="dark"] .btn-share {
  background: rgba(22,163,74,0.15);
  border-color: rgba(22,163,74,0.3);
  color: #4ade80;
}

.btn-qr {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fdf4ff;
  color: #9333ea;
  border: 1.5px solid #f0abfc;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-xs);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.btn-qr:hover {
  background: #fae8ff;
  transform: translateY(-1px);
}
[data-theme="dark"] .btn-qr {
  background: rgba(147,51,234,0.15);
  border-color: rgba(147,51,234,0.3);
  color: #c084fc;
}

/* Generic Modal Overlay & Container */
.mv-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.mv-modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.mv-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-normal);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 440px;
  padding: 24px;
  text-align: center;
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}
.mv-modal-backdrop.open .mv-modal {
  transform: scale(1);
}
.mv-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
}
.mv-modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

@media (max-width: 540px) {
  .hero-search {
    flex-direction: column;
    padding: 10px;
    border-radius: var(--radius-lg);
    gap: 8px;
  }
  .hero-search input {
    width: 100%;
    padding: 4px 6px;
    text-align: center;
  }
  .hero-search-actions {
    display: flex;
    gap: 8px;
    width: 100%;
  }
  .hero-search .btn {
    flex: 1;
    min-height: 44px;
  }
  .hero-search .btn-paste {
    min-height: 44px;
    padding: 0 16px;
  }
  .hero-search .search-icon { display: none; }
}

/* ─── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: all var(--transition-normal);
  overflow: hidden;
}

.card:hover {
  border-color: var(--primary-border);
  box-shadow: var(--shadow-raised);
  transform: translateY(-2px);
}

.card-body   { padding: var(--space-md) var(--space-lg); }
.card-header { padding: var(--space-lg) var(--space-lg) 0; }
.card-footer {
  padding: var(--space-sm) var(--space-lg) var(--space-md);
  border-top: 1px solid var(--border-subtle);
  margin-top: var(--space-sm);
}

[data-theme="dark"] .card { background: #131d35; }

/* Feature card */
.feature-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-lg) var(--space-md);
  box-shadow: var(--shadow-card);
  transition: all var(--transition-normal);
  text-align: center;
  cursor: pointer;
  display: block;
}

.feature-card:hover {
  border-color: var(--primary);
  box-shadow: 0 8px 24px rgba(0,87,217,0.14);
  transform: translateY(-3px);
}

.feature-icon {
  width: 52px; height: 52px;
  background: var(--primary-light);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto var(--space-md);
  font-size: 24px;
  color: var(--primary);
  border: 1.5px solid var(--primary-border);
}

/* Media card (Grid of images/reels) */
.media-card {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--bg-secondary);
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: all var(--transition-normal);
  border: 1px solid var(--border-subtle);
}

.media-card:hover { transform: scale(1.02); box-shadow: var(--shadow-raised); }
.media-card img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--transition-slow); }
.media-card:hover img { transform: scale(1.05); }

.media-card-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 60%);
  opacity: 0;
  transition: opacity var(--transition-normal);
  display: flex; align-items: flex-end;
  padding: var(--space-sm);
}
.media-card:hover .media-card-overlay { opacity: 1; }

.media-card-badge {
  position: absolute; top: 6px; right: 6px;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  border-radius: var(--radius-full);
  padding: 3px 8px;
  font-size: 11px; font-weight: 600;
  color: white;
  display: flex; align-items: center; gap: 4px;
}

/* Profile Card */
.profile-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-2xl);
  padding: var(--space-xl);
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.profile-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 5px;
  background: var(--gradient-main);
}

.profile-avatar-wrap { position: relative; display: inline-block; }

.profile-avatar {
  width: 90px; height: 90px;
  border-radius: 50%;
  border: 3px solid #ffffff;
  object-fit: cover;
  position: relative; z-index: 1;
  box-shadow: 0 4px 16px rgba(0,87,217,0.15);
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: var(--space-lg);
}

.stat-box {
  background: var(--blue-50);
  border: 1px solid var(--blue-100);
  border-radius: var(--radius-md);
  padding: 10px 8px;
  text-align: center;
  transition: all var(--transition-fast);
}

.stat-box:hover {
  border-color: var(--primary-border);
  background: var(--primary-light);
}

[data-theme="dark"] .stat-box { background: #1a2747; border-color: rgba(255,255,255,0.08); }

.stat-number {
  font-size: clamp(16px, 3.5vw, 20px);
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
}

[data-theme="dark"] .stat-number { color: #60a5fa; }

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* ─── Tabs (Horizontal Scroll on Mobile) ───────────────────────── */
.tabs, .hero-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 4px;
  border: 1px solid var(--border-subtle);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  /* Prevent wrapping — let it scroll */
  flex-wrap: nowrap;
}
.tabs::-webkit-scrollbar, .hero-tabs::-webkit-scrollbar { display: none; }

.tab-btn, .hero-tab {
  /* flex: 0 0 auto — DO NOT grow/shrink, let container scroll */
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-muted);
  transition: all var(--transition-fast);
  display: flex; align-items: center; justify-content: center;
  gap: 6px;
  white-space: nowrap;
  min-height: 38px;
  cursor: pointer;
}

.tab-btn:hover, .hero-tab:hover { color: var(--primary); background: var(--primary-light); }
.tab-btn.active, .hero-tab.active { background: var(--primary); color: white; box-shadow: var(--shadow-btn); }

[data-theme="dark"] .tab-btn.active, [data-theme="dark"] .hero-tab.active { background: #2563eb; }

/* Mobile tab size override */
@media (max-width: 480px) {
  .tabs, .hero-tabs {
    gap: 3px;
    padding: 3px;
    border-radius: var(--radius-md);
  }
  .tab-btn, .hero-tab {
    padding: 6px 10px;
    font-size: 12px;
    min-height: 34px;
    gap: 4px;
  }
}

/* ─── Badges ───────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.03em;
}

.badge-purple { background: #ede9fe; color: #7c3aed; border: 1px solid #ddd6fe; }
.badge-pink   { background: #fce7f3; color: #be185d; border: 1px solid #fbcfe8; }
.badge-green  { background: #d1fae5; color: #059669; border: 1px solid #a7f3d0; }
.badge-orange { background: #fef3c7; color: #d97706; border: 1px solid #fde68a; }
.badge-blue   { background: var(--primary-light); color: var(--primary); border: 1px solid var(--primary-border); }
.badge-red    { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; }

/* ─── Modals ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-md);
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-primary);
  border: 1px solid var(--border-normal);
  border-radius: var(--radius-2xl);
  box-shadow: 0 24px 64px rgba(0,0,0,0.2);
  width: 100%; max-width: 520px; max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-normal);
}

.modal-overlay.open .modal { transform: scale(1) translateY(0); }

/* ─── Toast Notifications ──────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: var(--space-lg); right: var(--space-lg);
  z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}

.toast {
  background: var(--bg-primary);
  border: 1px solid var(--border-normal);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0,0,0,0.14);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
  font-size: var(--font-size-sm); font-weight: 500;
  pointer-events: all;
  min-width: 260px; max-width: 360px;
  animation: slideInRight 0.28s ease forwards;
  border-left: 4px solid var(--primary);
  color: var(--text-primary);
}

.toast.success  { border-left-color: #059669; }
.toast.error    { border-left-color: #dc2626; }
.toast.warning  { border-left-color: #d97706; }
.toast.info     { border-left-color: var(--primary); }
.toast.download { border-left-color: var(--primary); }

@media (max-width: 600px) {
  .toast-container {
    left: 16px; right: 16px; bottom: 16px;
    align-items: center;
  }
  .toast { width: 100%; max-width: 100%; }
}

/* ─── Video & Reel Player Responsive ───────────────────────────── */
.reel-player-wrap {
  position: relative;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: #000;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
}

.reel-player-wrap video {
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  display: block;
}

@media (max-height: 700px) {
  .reel-player-wrap video { max-height: 400px; }
}

.speed-bar {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.speed-btn {
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: 700;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
}

.speed-btn:hover, .speed-btn.active {
  background: var(--primary);
  color: white; border-color: var(--primary);
}

/* ─── YouTube Quality Grid (Mobile Touch Optimized) ────────────── */
.quality-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.quality-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1.5px solid var(--border-normal);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  gap: 3px;
  width: 100%;
}

.quality-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.quality-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(0,87,217,0.12);
}

.quality-res-badge {
  font-size: 11px;
  font-weight: 800;
  color: white;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.03em;
}

.quality-label { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.quality-sub   { font-size: 11px; color: var(--text-muted); }
.quality-size  { font-size: 11px; color: var(--primary); font-weight: 600; }

.quality-btn.audio-btn { border-color: #a7f3d0; }
.quality-btn.audio-btn:hover, .quality-btn.audio-btn.active {
  border-color: #059669;
  background: #ecfdf5;
}

/* ─── Theme Toggle Button ──────────────────────────────────────── */
.theme-toggle {
  width: 38px; height: 38px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--transition-fast); font-size: 16px;
}
.theme-toggle:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

/* ─── Spinner ──────────────────────────────────────────────────── */
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--blue-100);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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