/* ============================================
   Mini Media Server v2.5 - Dark Mode Glassmorphism
   OLED Optimized for iPhone 13 Pro Max
   Synology DS224+ (Intel J4125) Compatible
   ============================================ */

/* CSS Variables - OLED Dark Mode */
:root {
  /* OLED-Optimized Backgrounds (True Black) */
  --bg-primary: #000000;
  --bg-secondary: #0a0a0a;
  --bg-tertiary: #111111;
  --bg-elevated: #1a1a1a;

  /* Glassmorphism Effects */
  --glass-bg: rgba(20, 20, 25, 0.75);
  --glass-bg-light: rgba(35, 35, 40, 0.6);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-border-hover: rgba(255, 255, 255, 0.15);
  --glass-highlight: rgba(255, 255, 255, 0.03);
  --blur-amount: 20px;

  /* OLED-Friendly Accents (Reduced Blue Light) */
  --accent-primary: #ff3b30;
  --accent-primary-hover: #ff5549;
  --accent-secondary: #ff9500;
  --accent-glow: rgba(255, 59, 48, 0.35);
  --accent-success: #34c759;
  --accent-info: #30d158;

  /* Text Colors (High Contrast for OLED) */
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-tertiary: rgba(255, 255, 255, 0.5);
  --text-muted: rgba(255, 255, 255, 0.35);

  /* Gradients */
  --gradient-hero: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.7) 50%, var(--bg-primary) 100%);
  --gradient-card: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, transparent 100%);
  --gradient-glass: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 100%);

  /* Spacing */
  --header-height: 70px;
  --header-height-mobile: 60px;
  --section-padding: 32px;
  --card-gap: 16px;
  --safe-area-top: env(safe-area-inset-top);
  --safe-area-bottom: env(safe-area-inset-bottom);

  /* Transitions */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);

  /* Shadows (Subtle for OLED) */
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px var(--accent-glow);
  --shadow-elevated: 0 8px 32px rgba(0, 0, 0, 0.6);

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

/* Reset & Base - OLED Optimized */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg-primary);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
  /* OLED burn-in protection - subtle pixel shifting */
  animation: oledShift 30s infinite;
}

@keyframes oledShift {

  0%,
  100% {
    transform: translate(0, 0);
  }

  50% {
    transform: translate(0.5px, 0.5px);
  }
}

/* OLED Subtle Background Pattern */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(ellipse at 15% 15%, rgba(255, 59, 48, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 85%, rgba(255, 149, 0, 0.03) 0%, transparent 50%);
  z-index: -1;
  pointer-events: none;
}

/* Utility Classes */
.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================
   GLASSMORPHISM COMPONENTS
   ============================================ */

.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur-amount));
  -webkit-backdrop-filter: blur(var(--blur-amount));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.glass-dropdown {
  background: rgba(15, 15, 18, 0.95);
  backdrop-filter: blur(var(--blur-amount));
  -webkit-backdrop-filter: blur(var(--blur-amount));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-elevated);
}

.glass-modal {
  background: rgba(12, 12, 14, 0.98);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8);
}

.glass-button {
  background: var(--glass-bg-light);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  transition: var(--transition-normal);
}

.glass-button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--glass-border-hover);
}

/* ============================================
   LOGIN SCREEN
   ============================================ */

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

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 48px 40px;
  animation: fadeInUp 0.6s ease;
}

.login-card .logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 40px;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.login-card .logo svg {
  width: 40px;
  height: 40px;
  color: var(--accent-primary);
}

.input-group {
  position: relative;
  margin-bottom: 24px;
}

.input-group input {
  width: 100%;
  padding: 16px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1rem;
  transition: var(--transition-normal);
}

.input-group input:focus {
  outline: none;
  border-color: var(--accent-primary);
  background: rgba(255, 255, 255, 0.06);
}

.input-group label {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
  pointer-events: none;
  transition: var(--transition-normal);
}

.input-group input:focus+label,
.input-group input:not(:placeholder-shown)+label {
  top: 0;
  font-size: 0.75rem;
  background: var(--bg-secondary);
  padding: 0 6px;
  color: var(--accent-primary);
}

.login-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 20px;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-normal);
}

.btn-primary {
  background: var(--accent-primary);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.login-card .btn-primary {
  width: 100%;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--glass-border-hover);
}

.btn-glow {
  box-shadow: 0 0 20px rgba(255, 59, 48, 0.25);
}

.btn-glow:hover {
  box-shadow: 0 0 30px rgba(255, 59, 48, 0.4);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
}

.btn-vlc {
  background: #ff8800;
  color: white;
}

.btn-vlc:hover {
  background: #ff9a20;
  box-shadow: 0 0 20px rgba(255, 136, 0, 0.3);
}

.btn-download {
  background: var(--accent-success);
  color: white;
}

.btn-download:hover {
  background: #3dd868;
  box-shadow: 0 0 20px rgba(52, 199, 89, 0.3);
}

/* ============================================
   APP LAYOUT
   ============================================ */

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

/* Header - OLED Optimized */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  padding-top: var(--safe-area-top);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.9) 0%, transparent 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1000;
  transition: var(--transition-normal);
}

.header.scrolled {
  background: rgba(0, 0, 0, 0.95);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-primary);
}

.logo svg {
  width: 28px;
  height: 28px;
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  gap: 8px;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-normal);
}

.nav-tab svg {
  width: 18px;
  height: 18px;
}

.nav-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
  color: var(--text-primary);
  background: rgba(255, 59, 48, 0.15);
}

/* Header Right */
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.search-container {
  position: relative;
}

.search-container input {
  width: 280px;
  padding: 12px 16px 12px 44px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  color: var(--text-primary);
  font-size: 0.9375rem;
  transition: var(--transition-normal);
}

.search-container input:focus {
  outline: none;
  width: 320px;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

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

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

/* User Menu */
.user-menu-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition-normal);
}

.user-menu-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.avatar {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.avatar svg {
  width: 22px;
  height: 22px;
}

.user-menu {
  position: absolute;
  top: calc(var(--header-height) + var(--safe-area-top) - 10px);
  right: 32px;
  min-width: 220px;
  padding: 12px 0;
  z-index: 1001;
}

.user-info {
  padding: 12px 16px;
}

.user-info span:first-child {
  display: block;
  font-weight: 600;
  color: var(--text-primary);
}

.user-role {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.menu-divider {
  height: 1px;
  background: var(--glass-border);
  margin: 8px 0;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  text-align: left;
  cursor: pointer;
  transition: var(--transition-fast);
}

.menu-item svg {
  width: 18px;
  height: 18px;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.main-content {
  flex: 1;
  padding-top: calc(var(--header-height) + var(--safe-area-top));
}

.tab-content {
  display: none;
  animation: fadeIn 0.4s ease;
}

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

/* Hero Section - OLED Optimized */
.hero-section {
  position: relative;
  height: 45vh;
  min-height: 350px;
  display: flex;
  align-items: flex-end;
  padding: 0 32px 48px;
  background: linear-gradient(135deg, rgba(255, 59, 48, 0.15) 0%, rgba(255, 149, 0, 0.1) 100%);
  overflow: hidden;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.02'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.3;
}

.series-hero {
  background: linear-gradient(135deg, rgba(0, 122, 255, 0.15) 0%, rgba(88, 86, 214, 0.1) 100%);
}

.hero-content {
  position: relative;
  z-index: 2;
  max-width: 600px;
}

.hero-title {
  font-size: 2.75rem;
  font-weight: 800;
  margin-bottom: 12px;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
  letter-spacing: -0.02em;
}

.hero-subtitle {
  font-size: 1.125rem;
  color: var(--text-secondary);
}

.hero-gradient {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 200px;
  background: var(--gradient-hero);
  pointer-events: none;
}

/* Content Section */
.content-section {
  padding: var(--section-padding);
  padding-bottom: calc(var(--section-padding) + var(--safe-area-bottom));
}

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

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

.section-subtitle {
  color: var(--text-muted);
  font-size: 0.9375rem;
  margin-top: 4px;
}

.item-count {
  color: var(--text-muted);
  font-size: 0.9375rem;
}

/* ============================================
   MEDIA GRID - LAZY LOADING OPTIMIZED
   ============================================ */

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

.media-card {
  position: relative;
  aspect-ratio: 2/3;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-tertiary);
  cursor: pointer;
  transition: var(--transition-normal);
  transform: translateZ(0);
  will-change: transform;
  /* OLED pixel alignment */
  transform-style: preserve-3d;
}

.media-card:hover {
  transform: scale(1.03) translateY(-4px);
  z-index: 10;
  box-shadow: var(--shadow-card);
}

.media-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-card);
  z-index: 1;
  opacity: 0;
  transition: var(--transition-normal);
}

.media-card:hover::before {
  opacity: 1;
}

/* Poster Image with Lazy Loading */
.media-poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--bg-tertiary);
  transition: opacity 0.3s ease;
}

.media-poster.lazy {
  opacity: 0;
}

.media-poster.loaded {
  opacity: 1;
}

/* Skeleton Loading for Posters */
.poster-skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
      var(--bg-tertiary) 25%,
      var(--bg-elevated) 50%,
      var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.5s infinite;
}

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

  100% {
    background-position: -200% 0;
  }
}

.media-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
}

.media-placeholder svg {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.media-placeholder span {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  padding: 0 16px;
  word-break: break-word;
}

.media-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 60px 12px 12px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.95));
  z-index: 2;
  transform: translateY(100%);
  transition: var(--transition-normal);
}

.media-card:hover .media-info {
  transform: translateY(0);
}

.media-title {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.media-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Action Buttons on Card */
.media-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transform: translateY(-10px);
  transition: var(--transition-normal);
  z-index: 3;
}

.media-card:hover .media-actions {
  opacity: 1;
  transform: translateY(0);
}

.media-action-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  transition: var(--transition-fast);
}

.media-action-btn:hover {
  transform: scale(1.1);
}

.media-action-btn.vlc:hover {
  background: #ff8800;
}

.media-action-btn.download:hover {
  background: var(--accent-success);
}

.media-action-btn svg {
  width: 16px;
  height: 16px;
}

/* Play Button */
.media-play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 56px;
  height: 56px;
  background: var(--accent-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  transition: var(--transition-normal);
  box-shadow: var(--shadow-glow);
}

.media-card:hover .media-play-icon {
  transform: translate(-50%, -50%) scale(1);
}

.media-play-icon svg {
  width: 22px;
  height: 22px;
  color: white;
  margin-left: 3px;
}

/* ============================================
   SERIES HIERARCHY
   ============================================ */

.series-list {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.series-item {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur-amount));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.series-header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.series-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

.series-poster {
  width: 80px;
  height: 120px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg-tertiary);
}

.series-info {
  flex: 1;
}

.series-name {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.series-meta {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.series-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.series-action-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.series-action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--glass-border-hover);
  color: var(--text-primary);
}

.expand-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.expand-icon.rotated {
  transform: rotate(180deg);
}

.seasons-container {
  padding: 0 20px 20px;
}

.season-item {
  margin-bottom: 16px;
}

.season-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 12px;
}

.season-name {
  font-weight: 600;
  font-size: 0.9375rem;
}

.season-episodes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  padding-left: 16px;
}

/* Temporada 0 (Especiales) styling */
.season-item[data-season="0"] .season-header {
  background: rgba(255, 149, 0, 0.1);
  border: 1px solid rgba(255, 149, 0, 0.2);
}

.season-item[data-season="0"] .season-name {
  color: var(--accent-secondary);
}

/* ============================================
   LIBRARIES SECTION
   ============================================ */

.libraries-section {
  max-width: 1000px;
  margin: 0 auto;
  padding-top: 80px;
}

.libraries-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.library-item {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  transition: var(--transition-normal);
}

.library-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--glass-border-hover);
}

.library-icon {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 59, 48, 0.12);
  border-radius: var(--radius-sm);
}

.library-icon svg {
  width: 26px;
  height: 26px;
  color: var(--accent-primary);
}

.library-info {
  flex: 1;
}

.library-name {
  font-size: 1.0625rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.library-path {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-family: 'SF Mono', monospace;
}

.library-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}

.library-type {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  font-size: 0.6875rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.library-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

.library-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.library-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.library-btn.delete:hover {
  background: rgba(255, 59, 48, 0.15);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.library-btn svg {
  width: 18px;
  height: 18px;
}

/* ============================================
   USER MANAGEMENT
   ============================================ */

.users-section {
  max-width: 900px;
  margin: 0 auto;
  padding-top: 80px;
}

.users-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
}

.user-avatar {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 50%;
  color: var(--text-secondary);
}

.user-details {
  flex: 1;
}

.user-name {
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 2px;
}

.user-role-badge {
  display: inline-flex;
  padding: 2px 8px;
  background: rgba(255, 59, 48, 0.15);
  border-radius: 12px;
  font-size: 0.6875rem;
  color: var(--accent-primary);
  text-transform: uppercase;
  font-weight: 600;
}

.user-role-badge.guest {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.user-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============================================
   MODALS
   ============================================ */

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

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

.player-container {
  position: relative;
  width: 100%;
  max-width: 1400px;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  z-index: 2001;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.9);
}

.player-container video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  z-index: 2002;
  transition: var(--transition-fast);
}

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

.close-btn svg {
  width: 24px;
  height: 24px;
}

.player-info {
  position: absolute;
  bottom: 80px;
  left: 24px;
  z-index: 2002;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
}

.player-info h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.player-info p {
  color: var(--text-secondary);
}

/* Action buttons for non-admin users */
.player-actions {
  position: absolute;
  bottom: 24px;
  left: 24px;
  display: flex;
  gap: 12px;
  z-index: 2002;
}

.player-action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 600;
  color: white;
  cursor: pointer;
  transition: var(--transition-fast);
}

.player-action-btn svg {
  width: 18px;
  height: 18px;
}

/* Glass Modal */
.glass-modal {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow: hidden;
  z-index: 2001;
  animation: scaleIn 0.3s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 24px 0;
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  max-height: 60vh;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 0 24px 24px;
}

.modal-footer .btn {
  width: auto;
  padding: 12px 24px;
}

/* Form Elements */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"] {
  width: 100%;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1rem;
  transition: var(--transition-normal);
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent-primary);
  background: rgba(255, 255, 255, 0.06);
}

/* Select styling */
.form-group select {
  width: 100%;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.5)' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
}

/* Radio Group */
.radio-group {
  display: flex;
  gap: 24px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.radio-label input {
  display: none;
}

.radio-custom {
  width: 20px;
  height: 20px;
  border: 2px solid var(--glass-border);
  border-radius: 50%;
  position: relative;
  transition: var(--transition-fast);
}

.radio-label input:checked+.radio-custom {
  border-color: var(--accent-primary);
}

.radio-label input:checked+.radio-custom::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  background: var(--accent-primary);
  border-radius: 50%;
}

/* Path Browser */
.path-browser {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.path-breadcrumb {
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--glass-border);
  font-family: 'SF Mono', monospace;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.folder-list {
  max-height: 200px;
  overflow-y: auto;
}

.folder-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.folder-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.folder-item.selected {
  background: rgba(255, 59, 48, 0.12);
}

.folder-item svg {
  width: 20px;
  height: 20px;
  color: var(--accent-primary);
}

.folder-item span {
  font-size: 0.9375rem;
}

/* Poster Upload Area */
.poster-upload {
  border: 2px dashed var(--glass-border);
  border-radius: var(--radius-md);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-normal);
}

.poster-upload:hover {
  border-color: var(--accent-primary);
  background: rgba(255, 59, 48, 0.05);
}

.poster-upload svg {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.poster-preview {
  width: auto;
  min-width: 140px;
  max-width: 240px;
  height: 360px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  margin: 0 auto 20px;
  background: rgba(0, 0, 0, 0.3);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: block;
}

.poster-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.poster-preview .poster-placeholder-large {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
}

.poster-preview .poster-placeholder-large svg {
  width: 48px;
  height: 48px;
  opacity: 0.5;
}

.poster-action-container {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 16px;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 3000;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur-amount));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  animation: slideInRight 0.3s ease;
  max-width: 400px;
}

.toast.success {
  border-left: 3px solid var(--accent-success);
}

.toast.error {
  border-left: 3px solid var(--accent-primary);
}

.toast.info {
  border-left: 3px solid #007aff;
}

/* ============================================
   LOADING OVERLAY
   ============================================ */

.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 4000;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-overlay span {
  color: var(--text-secondary);
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
}

.empty-state svg {
  width: 72px;
  height: 72px;
  color: var(--text-muted);
  margin-bottom: 24px;
  opacity: 0.4;
}

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

.empty-state span {
  color: var(--text-muted);
  font-size: 0.9375rem;
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

/* ============================================
   RESPONSIVE DESIGN - iPhone 13 Pro Max
   ============================================ */

/* Tablet */
@media (max-width: 1024px) {
  .header {
    padding: 0 24px;
    padding-top: var(--safe-area-top);
  }

  .header-left {
    gap: 24px;
  }

  .nav-tabs {
    gap: 4px;
  }

  .nav-tab {
    padding: 8px 14px;
    font-size: 0.875rem;
  }

  .nav-tab span {
    display: none;
  }

  .search-container input {
    width: 200px;
  }

  .search-container input:focus {
    width: 240px;
  }

  .hero-title {
    font-size: 2.25rem;
  }

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

/* Mobile - iPhone 13 Pro Max (428px) */
@media (max-width: 768px) {
  :root {
    --header-height: 60px;
    --section-padding: 20px;
    --card-gap: 12px;
  }

  .header {
    padding: 0 16px;
    padding-top: var(--safe-area-top);
    height: var(--header-height);
  }

  .header-left {
    gap: 12px;
  }

  .logo span {
    display: none;
  }

  .nav-tabs {
    gap: 2px;
  }

  .nav-tab {
    padding: 8px 10px;
  }

  .nav-tab svg {
    width: 20px;
    height: 20px;
  }

  .search-container input {
    width: 40px;
    padding: 10px;
    border-radius: 50%;
  }

  .search-container input:focus {
    position: fixed;
    top: calc(var(--header-height) + var(--safe-area-top) + 8px);
    left: 16px;
    right: 16px;
    width: calc(100% - 32px);
    padding: 12px 16px 12px 44px;
    border-radius: var(--radius-xl);
    z-index: 1002;
  }

  .search-icon {
    left: 50%;
    transform: translate(-50%, -50%);
  }

  .search-container input:focus+.search-icon {
    left: 16px;
    transform: translateY(-50%);
  }

  .user-menu {
    right: 16px;
    left: 16px;
    top: calc(var(--header-height) + var(--safe-area-top));
    min-width: auto;
  }

  .hero-section {
    height: 35vh;
    min-height: 280px;
    padding: 0 20px 32px;
  }

  .hero-title {
    font-size: 1.75rem;
  }

  .hero-subtitle {
    font-size: 0.9375rem;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .media-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  .media-card {
    aspect-ratio: 2/3;
  }

  .media-info {
    padding: 40px 8px 8px;
  }

  .media-title {
    font-size: 0.6875rem;
  }

  .media-meta {
    font-size: 0.625rem;
  }

  .media-play-icon {
    width: 44px;
    height: 44px;
  }

  .media-play-icon svg {
    width: 18px;
    height: 18px;
  }

  .media-actions {
    opacity: 1;
    transform: none;
    top: 4px;
    right: 4px;
  }

  .media-action-btn {
    width: 28px;
    height: 28px;
  }

  .libraries-section,
  .users-section {
    padding-top: 60px;
  }

  .library-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
  }

  .library-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .player-container {
    aspect-ratio: 16/9;
    border-radius: 0;
    max-height: 100vh;
  }

  .player-actions {
    flex-direction: column;
    left: 16px;
    right: 16px;
    bottom: 16px;
  }

  .player-action-btn {
    width: 100%;
    justify-content: center;
  }

  .glass-modal {
    max-height: 95vh;
    margin: 10px;
  }

  .modal-body {
    max-height: 50vh;
  }

  .toast-container {
    left: 16px;
    right: 16px;
    bottom: calc(16px + var(--safe-area-bottom));
  }

  .toast {
    max-width: 100%;
  }

  /* Series hierarchy mobile */
  .series-header {
    padding: 16px;
  }

  .series-poster {
    width: 60px;
    height: 90px;
  }

  .series-name {
    font-size: 1rem;
  }

  .season-episodes {
    grid-template-columns: repeat(2, 1fr);
    padding-left: 8px;
  }
}

/* Small Mobile */
@media (max-width: 375px) {
  .media-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .hero-title {
    font-size: 1.5rem;
  }
}

/* iPhone 13 Pro Max Specific (428×926) */
@media (width: 428px) and (height: 926px) {
  .header {
    padding-top: max(12px, var(--safe-area-top));
  }

  .main-content {
    padding-top: calc(var(--header-height) + max(12px, var(--safe-area-top)));
  }

  .media-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
}

/* Safe Area Support */
@supports (padding: max(0px)) {
  .header {
    padding-left: max(32px, var(--safe-area-inset-left));
    padding-right: max(32px, var(--safe-area-inset-right));
  }

  .main-content {
    padding-bottom: var(--safe-area-inset-bottom);
  }

  @media (max-width: 768px) {
    .header {
      padding-left: max(16px, var(--safe-area-inset-left));
      padding-right: max(16px, var(--safe-area-inset-right));
    }
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #000000;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  body {
    animation: none;
  }
}

/* OLED Burn-in Protection - Pixel Shifting Disabled for User Preference */
@media (prefers-reduced-motion: reduce) {
  body {
    animation: none;
  }
}

/* Print Styles */
@media print {

  .header,
  .modal,
  .toast-container,
  .loading-overlay {
    display: none !important;
  }
}