/* ═══════════════════════════════════════
   AnimeBot — Dark Anime Vault Theme
   ═══════════════════════════════════════ */

:root {
  --bg-primary: #09090b;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.6);
  --bg-card-hover: rgba(17, 24, 39, 0.9);
  --bg-glass: rgba(17, 24, 39, 0.4);
  --bg-input: rgba(255, 255, 255, 0.06);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-active: rgba(147, 51, 234, 0.5);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-dim: #64748b;

  --accent-purple: #9333ea;
  --accent-purple-light: #a855f7;
  --accent-pink: #ec4899;
  --accent-cyan: #06b6d4;
  --accent-red: #ef4444;
  --accent-green: #22c55e;

  --gradient-primary: linear-gradient(135deg, #9333ea, #ec4899);
  --gradient-glow: linear-gradient(135deg, #9333ea, #a855f7, #ec4899);
  --gradient-card: linear-gradient(180deg, rgba(17, 24, 39, 0.3), rgba(17, 24, 39, 0.8));

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(147, 51, 234, 0.3);

  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ─── Reset ───────────────────────────── */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ─── Login Screen ────────────────────── */

.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-primary);
  position: relative;
}

.login-screen::before {
  content: '';
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(147, 51, 234, 0.15) 0%, transparent 70%);
  pointer-events: none;
}

.login-card {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}

.login-logo { margin-bottom: 32px; }

.logo-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.login-logo h1 {
  font-size: 28px;
  font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.login-logo p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 6px;
}

.login-form { width: 100%; }

.input-group {
  display: flex;
  gap: 8px;
  width: 100%;
}

.input-group input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
}

.input-group input:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.15);
}

.input-group input::placeholder {
  color: var(--text-dim);
}

.login-error {
  color: var(--accent-red);
  font-size: 13px;
  margin-top: 12px;
  min-height: 20px;
}

/* ─── Buttons ─────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  border: none;
  box-shadow: 0 2px 8px rgba(147, 51, 234, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(147, 51, 234, 0.5);
  transform: translateY(-1px);
}

.btn-glow {
  background: var(--gradient-primary);
  color: white;
  border: none;
  box-shadow: var(--shadow-glow);
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 12px rgba(147, 51, 234, 0.3); }
  50% { box-shadow: 0 0 24px rgba(147, 51, 234, 0.5); }
}

.btn-glow:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 30px rgba(147, 51, 234, 0.6);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.btn-ghost:hover {
  background: var(--bg-input);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.1);
}

.btn-danger {
  background: transparent;
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.5);
}

.btn-lg {
  padding: 14px 24px;
  font-size: 15px;
  border-radius: var(--radius-md);
}

/* ─── Header ──────────────────────────── */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: rgba(9, 9, 11, 0.8);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon-sm { font-size: 24px; }

.header-title {
  font-size: 18px;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Modal ───────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 90%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.25s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-input);
}

.modal-hint {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 16px;
}

.add-status {
  margin-top: 12px;
  font-size: 13px;
  color: var(--accent-green);
  min-height: 20px;
}

.add-status.error { color: var(--accent-red); }

/* ─── Player Modal ────────────────────── */

.player-container {
  position: relative;
  width: 94%;
  max-width: 1100px;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.25s ease;
}

.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(17, 24, 39, 0.9);
}

.player-header h3 {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-controls-overlay {
  position: absolute;
  bottom: 60px;
  right: 20px;
  z-index: 10;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Show overlay when hovering or tapping the player area */
.player-frame:hover .player-controls-overlay,
.player-frame:focus-within .player-controls-overlay,
.player-controls-overlay:focus-within {
  opacity: 1;
  transform: translateY(0);
}

.player-overlay-select {
  background: rgba(9, 9, 11, 0.75);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: var(--transition);
}

.player-overlay-select:hover {
  background: rgba(147, 51, 234, 0.85);
  border-color: var(--accent-purple-light);
  box-shadow: 0 4px 16px rgba(147, 51, 234, 0.4);
}

.player-overlay-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.player-frame {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
}

.player-frame iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ─── Main Content ────────────────────── */

.main-content {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.badge {
  background: var(--bg-input);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border-subtle);
}

/* ─── Media Grid ──────────────────────── */

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

@media (min-width: 768px) {
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

@media (min-width: 1200px) {
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

.media-card {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  group: card;
}

.media-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md), var(--shadow-glow);
  border-color: var(--border-active);
}

.card-poster {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  display: block;
  background: var(--bg-secondary);
  transition: var(--transition);
}

.media-card:hover .card-poster {
  filter: brightness(1.1);
}

.card-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.95));
  padding: 40px 10px 10px;
}

.card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-badge.series {
  background: rgba(147, 51, 234, 0.8);
  color: white;
}

.card-badge.movie {
  background: rgba(236, 72, 153, 0.8);
  color: white;
}

.card-status {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
}

.card-status.scraping {
  background: rgba(251, 191, 36, 0.8);
  color: #000;
  animation: blink 1.5s infinite;
}

.card-status.error {
  background: rgba(239, 68, 68, 0.8);
  color: white;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.card-eps {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ─── Empty State ─────────────────────── */

.empty-state {
  text-align: center;
  padding: 80px 20px;
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.empty-state p {
  color: var(--text-dim);
  font-size: 14px;
}

/* ─── Loading State ───────────────────── */

.loading-state {
  text-align: center;
  padding: 60px 20px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--accent-purple);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.8s linear infinite;
}

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

.loading-state p {
  color: var(--text-dim);
  font-size: 14px;
}

/* ─── Detail View ─────────────────────── */

.detail-view {
  padding: 24px;
  max-width: 1000px;
  margin: 0 auto;
}

.btn-back {
  margin-bottom: 20px;
}

.detail-hero {
  display: flex;
  gap: 28px;
  margin-bottom: 32px;
}

.detail-poster {
  width: 200px;
  min-width: 200px;
  border-radius: var(--radius-md);
  object-fit: cover;
  box-shadow: var(--shadow-md);
  aspect-ratio: 2/3;
  background: var(--bg-secondary);
}

.detail-info {
  flex: 1;
  min-width: 0;
}

.detail-title {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-input);
  padding: 4px 10px;
  border-radius: 16px;
}

.detail-genres {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.genre-tag {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 16px;
  background: rgba(147, 51, 234, 0.15);
  color: var(--accent-purple-light);
  border: 1px solid rgba(147, 51, 234, 0.25);
}

.detail-overview {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 20px;
}

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

/* ─── Episodes ────────────────────────── */

.episodes-section { margin-top: 8px; }

.episodes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.episode-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}

.episode-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
  box-shadow: var(--shadow-sm);
}

.ep-number {
  width: 40px;
  height: 40px;
  min-width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-purple-light);
}

.ep-info { flex: 1; min-width: 0; }

.ep-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ep-sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.ep-play {
  color: var(--text-dim);
  transition: var(--transition);
}

.episode-card:hover .ep-play {
  color: var(--accent-purple-light);
}

.ep-no-video {
  font-size: 11px;
  color: var(--accent-red);
  opacity: 0.7;
}

/* ─── Responsive & Mobile-First Optimizations ──────── */

/* Small devices (phones, 640px and down) */
@media (max-width: 640px) {
  .header {
    padding: 12px 16px;
  }

  .header-title {
    font-size: 16px;
  }

  .main-content {
    padding: 16px;
  }

  .section-title {
    font-size: 18px;
  }

  /* Library grid: fluid 2-column on small screens, preventing clipping */
  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
  }

  /* Login card responsiveness */
  .login-card {
    padding: 32px 24px;
    width: 92%;
  }

  /* Stack input groups on tiny screens to avoid squishing */
  .input-group {
    flex-direction: column;
    gap: 10px;
  }

  .input-group input {
    width: 100%;
  }

  .input-group .btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
  }

  /* Detail hero layout: stack poster above text */
  .detail-view {
    padding: 16px;
  }

  .detail-hero {
    flex-direction: column;
    align-items: center;
    gap: 20px;
    text-align: center;
  }

  .detail-poster {
    width: 150px;
    min-width: 150px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  }

  .detail-title {
    font-size: 22px;
    font-weight: 700;
  }

  .detail-meta,
  .detail-genres {
    justify-content: center;
  }

  /* Make actions full width and stackable on mobile */
  .detail-actions {
    flex-direction: column;
    width: 100%;
    gap: 8px;
  }

  .detail-actions .btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
  }

  /* Touch targets for episode list */
  .episode-card {
    padding: 14px 12px;
  }

  .ep-number {
    width: 36px;
    height: 36px;
    min-width: 36px;
    font-size: 13px;
  }

  .ep-title {
    font-size: 12px;
  }

  /* Modal fitting for mobile screens */
  .modal-content {
    padding: 20px;
    width: 94%;
  }

  /* Hide button labels on mobile headers to save space */
  .header-right .btn span {
    display: none;
  }

  .header-right .btn {
    padding: 10px;
    border-radius: 50%;
  }

  /* Video player fills the viewport width */
  .player-container {
    width: 100%;
    border-radius: 0;
    border: none;
  }

  .player-header {
    padding: 10px 12px;
  }
}

/* Medium devices (tablets, 641px to 1024px) */
@media (min-width: 641px) and (max-width: 1024px) {
  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
  }

  .detail-hero {
    gap: 24px;
  }

  .detail-poster {
    width: 180px;
    min-width: 180px;
  }
}

/* Touch device optimizations (active states for taps) */
@media (hover: none) {
  .media-card:active {
    transform: scale(0.98);
    border-color: var(--border-active);
  }

  .episode-card:active {
    background: var(--bg-card-hover);
  }

  .btn:active {
    transform: translateY(1px);
    opacity: 0.9;
  }
}

/* Mobile Landscape orientation optimization */
@media (max-width: 950px) and (orientation: landscape) {
  .modal {
    padding: 0;
  }
  
  .player-container {
    width: 100vw;
    height: 100vh;
    max-width: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0;
    z-index: 9999;
  }
  
  .player-frame {
    flex: 1;
    padding-bottom: 0;
    height: 100%;
  }
  
  .player-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.85), transparent);
    z-index: 10;
    padding: 10px 16px;
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  
  /* Show header overlay when player is touched/hovered */
  .player-container:hover .player-header,
  .player-container:active .player-header,
  .player-container:focus-within .player-header {
    opacity: 1;
  }
}

