/* =============================================
   CloudDrama - Dark Theme Styles
   Mobile-first, Netflix/ShortTV inspired
   ============================================= */

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #141414;
  --bg-card: #1a1a1a;
  --bg-elevated: #222222;
  --bg-overlay: rgba(0, 0, 0, 0.65);
  --text-primary: #ffffff;
  --text-secondary: #b3b3b3;
  --text-muted: #808080;
  --accent: #e50914;
  --accent-hover: #f40612;
  --accent-gold: #d4a017;
  --accent-green: #46d369;
  --border: #2a2a2a;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --header-height: 52px;
  --bottom-nav-height: 60px;
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

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

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

button {
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

input {
  font: inherit;
  border: none;
  outline: none;
  background: none;
  color: inherit;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  display: none;
}

/* --- App Layout --- */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --- Header --- */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: linear-gradient(180deg, rgba(10,10,10,0.95) 0%, rgba(10,10,10,0.8) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding-top: var(--safe-area-top);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--header-height);
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #e50914, #ff6b6b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}

.icon-btn:hover {
  background: var(--bg-elevated);
}

/* --- Bottom Navigation --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: var(--bottom-nav-height);
  background: rgba(20, 20, 20, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-area-bottom);
}

.bottom-nav.hidden {
  display: none;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 0.65rem;
  color: var(--text-muted);
  transition: color 0.2s;
  padding: 6px 16px;
}

.nav-item.active {
  color: var(--accent);
}

.nav-item:hover {
  color: var(--text-primary);
}

/* --- Page Container --- */
.page-container {
  flex: 1;
  padding-top: calc(var(--header-height) + var(--safe-area-top));
  padding-bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom) + 16px);
}

.page-container.no-bottom-nav {
  padding-bottom: 16px;
}

/* --- Tab Bar (Featured / Trending / New) --- */
.tab-bar {
  display: flex;
  gap: 0;
  padding: 12px 16px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.tab-item {
  flex: 1;
  text-align: center;
  padding: 8px 0 12px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  cursor: pointer;
}

.tab-item.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

/* --- Category Scroll --- */
.category-scroll {
  display: flex;
  gap: 8px;
  padding: 0 16px 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.category-chip {
  flex-shrink: 0;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  transition: all 0.2s;
  scroll-snap-align: start;
  cursor: pointer;
  white-space: nowrap;
}

.category-chip.active {
  background: var(--text-primary);
  color: var(--bg-primary);
  border-color: var(--text-primary);
}

.category-chip:hover {
  border-color: var(--text-secondary);
}

/* --- Today's Exclusive (Hero) --- */
.hero-section {
  margin: 0 16px 24px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--bg-secondary);
}

.hero-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-gold);
  background: rgba(0,0,0,0.6);
  padding: 4px 10px;
  border-radius: 4px;
}

.hero-cover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(10, 10, 10, 0.95) 0%,
    rgba(10, 10, 10, 0.5) 40%,
    transparent 70%
  );
  z-index: 1;
}

.hero-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2;
  padding: 16px;
}

.hero-tags {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.hero-tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.65rem;
  font-weight: 600;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hero-tag.trending {
  background: var(--accent);
  color: white;
}

.hero-tag.new {
  background: var(--accent-green);
  color: #000;
}

.hero-title {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 6px;
}

.hero-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero-meta-tags {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.hero-meta-tag {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.hero-actions {
  display: flex;
  gap: 10px;
}

.btn-watch {
  flex: 1;
  padding: 10px 20px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
  text-align: center;
}

.btn-watch:hover {
  background: var(--accent-hover);
}

.btn-details {
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
  text-align: center;
}

.btn-details:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* --- Continue Watching --- */
.continue-section {
  margin: 0 16px 24px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
}

.continue-icon {
  width: 40px;
  height: 40px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.continue-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 2px;
}

.continue-title {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.continue-ep {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.continue-play {
  width: 36px;
  height: 36px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* --- Section Title --- */
.section-title {
  padding: 0 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.section-title a {
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: color 0.2s;
}

.section-title a:hover {
  color: var(--text-primary);
}

/* --- Drama Grid --- */
.drama-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 0 16px;
  margin-bottom: 24px;
}

.drama-card {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-card);
  transition: transform 0.2s;
}

.drama-card:active {
  transform: scale(0.96);
}

.drama-card-cover {
  aspect-ratio: 3 / 4;
  width: 100%;
  object-fit: cover;
}

.drama-card-badges {
  position: absolute;
  top: 6px;
  left: 6px;
  display: flex;
  gap: 4px;
}

.card-badge {
  padding: 1px 6px;
  font-size: 0.55rem;
  font-weight: 700;
  border-radius: 3px;
  text-transform: uppercase;
}

.card-badge.trending {
  background: var(--accent);
  color: white;
}

.card-badge.new {
  background: var(--accent-green);
  color: #000;
}

.drama-card-ep {
  position: absolute;
  bottom: 40px;
  right: 6px;
  font-size: 0.6rem;
  font-weight: 600;
  background: rgba(0,0,0,0.7);
  padding: 2px 6px;
  border-radius: 3px;
}

.drama-card-info {
  padding: 8px;
}

.drama-card-title {
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.drama-card-category {
  font-size: 0.6rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- VIP Banner --- */
.vip-banner {
  margin: 0 16px 24px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #1a1500, #2a2000, #1a1500);
  border: 1px solid #3d3000;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 12px;
}

.vip-badge-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent-gold), #ffd700);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 900;
  font-size: 1rem;
  color: #000;
}

.vip-info {
  flex: 1;
}

.vip-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-gold);
  margin-bottom: 2px;
}

.vip-desc {
  font-size: 0.7rem;
  color: #a08800;
}

.vip-join-btn {
  padding: 8px 16px;
  background: linear-gradient(135deg, var(--accent-gold), #ffd700);
  color: #000;
  font-weight: 700;
  font-size: 0.75rem;
  border-radius: 20px;
  flex-shrink: 0;
  transition: opacity 0.2s;
}

.vip-join-btn:hover {
  opacity: 0.85;
}

/* =============================================
   Drama Detail Page
   ============================================= */
.detail-page {
  padding: 0 0 24px;
}

.detail-hero {
  position: relative;
  aspect-ratio: 9 / 14;
  max-height: 400px;
  overflow: hidden;
}

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

.detail-hero-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    var(--bg-primary) 0%,
    rgba(10,10,10,0.4) 40%,
    transparent 60%
  );
}

.detail-brand {
  position: absolute;
  top: 16px;
  left: 16px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(0,0,0,0.5);
  padding: 4px 10px;
  border-radius: 4px;
}

.detail-body {
  padding: 0 16px;
  margin-top: -40px;
  position: relative;
  z-index: 2;
}

.detail-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 10px;
}

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

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

.detail-tag {
  padding: 4px 12px;
  font-size: 0.75rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.detail-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.btn-start {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: white;
  font-size: 1rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  text-align: center;
  margin-bottom: 16px;
  transition: background 0.2s;
}

.btn-start:hover {
  background: var(--accent-hover);
}

.payment-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
}

/* --- Episode List --- */
.episodes-section {
  padding: 0 16px;
}

.episodes-section h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.episode-pagination {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.ep-page-btn {
  padding: 6px 14px;
  font-size: 0.8rem;
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.ep-page-btn.active {
  background: var(--text-primary);
  color: var(--bg-primary);
  border-color: var(--text-primary);
}

.episodes-list {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 24px;
}

.ep-item {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.ep-item:active {
  transform: scale(0.93);
}

.ep-item.free {
  border-color: var(--accent-green);
  color: var(--accent-green);
}

.ep-item.locked {
  opacity: 0.6;
}

.ep-item.locked::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 12px;
  height: 12px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23808080' stroke-width='2'%3E%3Crect x='3' y='11' width='18' height='11' rx='2'/%3E%3Cpath d='M7 11V7a5 5 0 0110 0v4'/%3E%3C/svg%3E") no-repeat center;
  background-size: contain;
}

.ep-item.watched {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* =============================================
   Video Player Overlay
   ============================================= */
.video-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #000;
  display: flex;
  flex-direction: column;
}

.video-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  padding-top: calc(12px + var(--safe-area-top));
  background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent);
}

.video-back-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  transition: background 0.2s;
}

.video-back-btn:hover {
  background: rgba(255,255,255,0.2);
}

.video-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#video-drama-title {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#video-episode-title {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.video-views {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.video-player-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-player-wrap video {
  width: 100%;
  max-height: 100%;
  background: #000;
}

.video-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  padding: 16px;
  padding-bottom: calc(16px + var(--safe-area-bottom));
  background: linear-gradient(to top, rgba(0,0,0,
/* =============================================
   Skeleton Loading Screen
   ============================================= */
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 0 16px;
}

.skeleton-card {
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-card);
}

.skeleton-cover {
  aspect-ratio: 3 / 4;
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-text {
  height: 12px;
  margin: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-text.short { width: 60%; }

.skeleton-hero {
  margin: 0 16px 24px;
  border-radius: var(--radius-lg);
  aspect-ratio: 16 / 10;
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

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

/* =============================================
   Page Transition Animations
   ============================================= */
.page-container > * {
  animation: pageSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pageSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =============================================
   Network Offline Banner
   ============================================= */
.offline-banner {
  position: fixed;
  top: calc(var(--header-height) + var(--safe-area-top));
  left: 0;
  right: 0;
  z-index: 200;
  background: #ff4444;
  color: white;
  text-align: center;
  padding: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.offline-banner.show {
  transform: translateY(0);
}

/* =============================================
   Toast Notification
   ============================================= */
.app-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  z-index: 9999;
  background: rgba(30, 30, 30, 0.95);
  color: white;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 0.85rem;
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.app-toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
