/* Custom Premium Stylesheet for MovieStory PWA */

:root {
  --bg-primary: #05070c;
  --bg-secondary: #0b0f19;
  --bg-card: rgba(255, 255, 255, 0.03);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --glass-bg: rgba(11, 15, 25, 0.65);
  --glass-border: rgba(255, 255, 255, 0.07);
  
  --accent-primary: #8a2be2;      /* Neon purple */
  --accent-secondary: #00e5ff;    /* Electric cyan */
  --accent-gradient: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dark: #111827;
  
  --font-family: 'Outfit', sans-serif;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --border-radius: 16px;
}

/* Reset and Core Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-family);
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(138, 43, 226, 0.1) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(0, 229, 255, 0.08) 0px, transparent 50%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* App Header */
.app-header {
  background: rgba(5, 7, 12, 0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.logo-icon {
  color: var(--accent-secondary);
  width: 32px;
  height: 32px;
}

.logo span span {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.language-selector-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  padding: 8px 12px;
  border-radius: 20px;
  transition: var(--transition-smooth);
}

.language-selector-wrapper:focus-within {
  border-color: var(--accent-secondary);
}

.lang-icon {
  color: var(--text-muted);
  width: 18px;
  height: 18px;
}

#app-language {
  background: transparent;
  border: none;
  color: var(--text-main);
  outline: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

#app-language option {
  background: var(--bg-secondary);
  color: var(--text-main);
}

/* App Main Layout */
.app-main {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  padding-bottom: 120px; /* Padding for bottom player */
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Search Section */
.search-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.search-bar-container {
  display: flex;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 6px 6px 6px 18px;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-premium);
  transition: var(--transition-smooth);
}

.search-bar-container:focus-within {
  border-color: var(--accent-secondary);
  box-shadow: 0 0 15px rgba(0, 229, 255, 0.15);
}

.search-icon {
  color: var(--text-muted);
  width: 22px;
  height: 22px;
}

#search-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  outline: none;
  font-size: 16px;
}

#search-input::placeholder {
  color: var(--text-muted);
}

.btn-primary {
  background: var(--accent-gradient);
  border: none;
  color: white;
  padding: 12px 24px;
  border-radius: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(138, 43, 226, 0.4);
}

.filter-pills-container {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
}

/* Hide scrollbar for webkit browsers */
.filter-pills-container::-webkit-scrollbar {
  display: none;
}

.filter-pill {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-smooth);
}

.filter-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.filter-pill.active {
  background: var(--text-main);
  color: var(--bg-primary);
  border-color: var(--text-main);
}

/* Main Content Columns */
.content-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

.primary-column h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 16px;
}

/* Movie Grid */
.movie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
}

.movie-card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition-smooth);
  position: relative;
  display: flex;
  flex-direction: column;
}

.movie-card:hover {
  transform: translateY(-6px);
  border-color: rgba(255, 255, 255, 0.2);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-premium);
}

.poster-wrapper {
  position: relative;
  aspect-ratio: 2/3;
  width: 100%;
  background: #1e293b;
}

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

.rating-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(5, 7, 12, 0.85);
  backdrop-filter: blur(4px);
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.listen-overlay-btn {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: var(--accent-gradient);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: scale(0.8);
  transition: var(--transition-smooth);
}

.movie-card:hover .listen-overlay-btn {
  opacity: 1;
  transform: scale(1);
}

.movie-info {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.movie-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.movie-meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* Sidebar Details View */
.detail-sidebar {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-premium);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 90px;
  max-height: calc(100vh - 240px);
  overflow: hidden;
}

/* Desktop: content area scrolls inside the sidebar */
.detail-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 24px 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--glass-border) transparent;
}
.detail-content::-webkit-scrollbar { width: 4px; }
.detail-content::-webkit-scrollbar-track { background: transparent; }
.detail-content::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 4px; }

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--glass-border);
  padding: 16px 20px;
  flex-shrink: 0; /* Never squash the header */
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.sidebar-brand-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0; /* required for flex child to truncate text */
}

.icon-btn-back {
  background: transparent;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  display: none; /* Only visible on mobile/tablet */
}

/* Empty State */
.empty-state {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 300px;
  color: var(--text-muted);
}

.empty-message {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-message i {
  width: 48px;
  height: 48px;
  opacity: 0.5;
}

/* Shimmer Loading Effect */
.loading-shimmer {
  width: 100%;
  height: 300px;
  background: linear-gradient(90deg, var(--bg-card) 25%, rgba(255, 255, 255, 0.06) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--border-radius);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Bottom Floating Media Player */
.audio-deck {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 40px);
  max-width: 900px;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  z-index: 999;
  overflow: hidden;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
}

.audio-deck.hidden {
  transform: translate(-50%, 150%);
  opacity: 0;
  pointer-events: none;
}

.audio-deck-content {
  display: flex;
  padding: 12px 16px 8px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* Social bar ad must be fully contained — no overflow or absolute children visible outside deck */
#social-bar-ad-deck {
  width: 100%;
  overflow: hidden;
  max-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 0; /* keep below the deck's own z-index */
}


.audio-movie-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.audio-poster-img {
  width: 44px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
  background: #1e293b;
}

.audio-text-info {
  min-width: 0;
}

#audio-title {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#audio-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audio-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.control-btn {
  background: transparent;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
  opacity: 0.8;
}

.control-btn:hover {
  opacity: 1;
  color: var(--accent-secondary);
}

.control-btn.play-main {
  background: var(--accent-gradient);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: white;
  opacity: 1;
  box-shadow: 0 4px 12px rgba(138, 43, 226, 0.3);
}

.control-btn.play-main:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 16px rgba(0, 229, 255, 0.4);
}

.audio-settings {
  display: flex;
  align-items: center;
  gap: 16px;
}

.speed-control {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

#audio-speed {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 4px 8px;
  border-radius: 8px;
  outline: none;
  cursor: pointer;
}

.voice-selector-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  padding: 6px 12px;
  border-radius: 12px;
}

#audio-voice {
  background: transparent;
  border: none;
  color: var(--text-main);
  outline: none;
  font-size: 13px;
  cursor: pointer;
}

.audio-progress-container {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  width: 100%;
}

.audio-progress-bar {
  height: 100%;
  background: var(--accent-gradient);
  width: 0%;
  transition: width 0.1s linear;
}

/* Detail View Layout Components */
.detail-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 250px; /* Padding to ensure comment box isn't hidden by audio deck */
}

.detail-banner {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 12px;
  overflow: hidden;
  background: #1e293b;
  position: relative;
}

.detail-banner-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-info-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-title {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
}

.detail-badge-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

/* Action bar with language + listen button right below title */
.detail-action-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.lang-select-inline {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 13px;
  outline: none;
  cursor: pointer;
  flex: 0 1 auto;
  min-width: 100px;
}

.listen-btn-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 20px;
  white-space: nowrap;
}


.badge {
  background: rgba(255, 255, 255, 0.07);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--glass-border);
}

.badge.rating {
  color: var(--accent-secondary);
  border-color: rgba(0, 229, 255, 0.2);
}

.detail-plot-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-plot-section h4 {
  font-size: 16px;
  font-weight: 700;
}

.detail-plot {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
}

.detail-plot::-webkit-scrollbar {
  width: 4px;
}
.detail-plot::-webkit-scrollbar-thumb {
  background: var(--surface-light);
  border-radius: 4px;
}

.crew-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  max-height: 25vh;
  overflow-y: auto;
}

.crew-item h5 {
  font-size: 12px;
  color: var(--text-muted);
}

.crew-item p {
  font-size: 14px;
  font-weight: 600;
}

/* Watch Providers Section */
.watch-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid var(--glass-border);
  padding-top: 16px;
}

.watch-section h4 {
  font-size: 14px;
  font-weight: 700;
}

.providers-list {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.provider-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: var(--transition-smooth);
}

.provider-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--text-main);
}

.provider-icon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
}

/* Discussion Board */
.discussion-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid var(--glass-border);
  padding-top: 16px;
  margin-top: 8px;
}

.discussion-section h4 {
  font-size: 15px;
  font-weight: 700;
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 200px;
  overflow-y: auto;
  padding-right: 4px;
}

.comment-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  padding: 10px 12px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.comment-user {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-secondary);
}

.comment-text {
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-main);
}

.comment-input-row {
  display: flex;
  gap: 8px;
}

.comment-input-row input {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 8px 12px;
  color: var(--text-main);
  outline: none;
  font-size: 13px;
}

.comment-input-row input:focus {
  border-color: var(--accent-secondary);
}

.btn-icon {
  background: var(--accent-gradient);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-icon:hover {
  transform: scale(1.05);
}

/* Responsive Rules */
@media (max-width: 1024px) {
  .content-layout {
    grid-template-columns: 1fr;
  }

  /* On mobile the sidebar is a full-screen overlay panel */
  .detail-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    z-index: 998;
    border-radius: 0;
    border: none;
    padding: 0;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* outer panel never scrolls */
  }

  .detail-sidebar.open {
    transform: translateX(0);
  }

  /* Only the content area scrolls, not the whole sidebar */
  .detail-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px 16px 180px; /* bottom pad = audio deck height */
    overscroll-behavior: contain; /* prevent scroll bleed to background */
  }

  .icon-btn-back {
    display: block;
  }

  /* Lock body scroll when sidebar is open */
  body.sidebar-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
  }
}

@media (max-width: 600px) {
  .app-main {
    padding: 12px;
  }

  .movie-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }

  /* On phones, audio deck sits flush at very bottom */
  .audio-deck {
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    transform: translateY(0);
  }
  .audio-deck.hidden {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
  }

  .audio-deck-content {
    padding: 10px 12px 6px;
    flex-wrap: wrap;
    justify-content: space-between;
  }

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

  .audio-controls {
    order: 3;
    width: 100%;
    justify-content: center;
    margin-top: 4px;
  }

  .audio-settings {
    order: 2;
    flex: 1;
    justify-content: flex-end;
    gap: 8px;
  }
}

/* Playlist Mode Bar */
.playlist-mode-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: none;
}
.playlist-mode-bar::-webkit-scrollbar { display: none; }
.playlist-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.playlist-chips {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
}
.pchip {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-smooth);
}
.pchip:hover, .pchip.active {
  background: var(--accent-gradient);
  border-color: transparent;
  color: white;
}

/* Playlist Filter Modal */
.playlist-modal {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1100;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.playlist-modal.hidden {
  display: none;
}
.playlist-modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 600px;
  padding: 20px;
  max-height: 70vh;
  overflow-y: auto;
}
.playlist-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.playlist-modal-header h4 {
  font-size: 16px;
  font-weight: 700;
}
.playlist-filter-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: 12px;
  outline: none;
  margin-bottom: 12px;
  font-size: 14px;
}
.playlist-filter-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.filter-option-btn {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition-smooth);
}
.filter-option-btn:hover {
  background: var(--accent-gradient);
  border-color: transparent;
  color: white;
}

/* Footer Styling */
.app-footer {
  text-align: center;
  padding-top: 24px;
  border-top: 1px solid var(--glass-border);
  margin-top: 24px;
}

.app-footer p {
  font-size: 13px;
  color: var(--text-muted);
}

.app-footer a {
  color: var(--accent-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition-smooth);
}

.app-footer a:hover {
  color: var(--accent-primary);
  text-shadow: 0 0 8px rgba(138, 43, 226, 0.4);
}
