/* =====================================================================
   ZapFlix — Mobile / Responsive enhancement layer (ADDITIVE ONLY)
   - Does NOT change desktop theme: every rule is gated behind a mobile
     media query or (hover:none) touch query.
   - Reuses existing theme variables/colors from style.css. No recoloring.
   - Powers the JS-built mobile drawer (.zf-mnav-*) and bottom tab bar
     (.zf-bottomnav) created by js/mobile.js.
   ===================================================================== */

:root{
  --zf-red: var(--netflix-red, #E50914);
  --zf-dark: var(--netflix-dark, #181818);
  --zf-black: var(--netflix-black, #141414);
  --zf-safe-top: env(safe-area-inset-top, 0px);
  --zf-safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Global touch niceties (safe on desktop, no visual change) */
.movie-row, .search-grid, .content-section{ -webkit-overflow-scrolling: touch; }
img{ -webkit-touch-callout: none; }

/* ============================ PHONES/TABLETS ======================== */
@media (max-width: 900px){
  html, body{ overflow-x: hidden; max-width: 100vw; }

  /* Respect the notch / status bar */
  .navbar{
    padding-top: var(--zf-safe-top);
    height: calc(52px + var(--zf-safe-top));
    gap: 8px;
  }

  /* Hamburger button (injected by mobile.js) */
  .zf-mnav-toggle{
    display: inline-flex; flex-direction: column; justify-content: center;
    gap: 4px; width: 40px; height: 40px; padding: 8px; margin-inline-end: 4px;
    background: transparent; border: 0; cursor: pointer; border-radius: 8px;
    flex: 0 0 auto;
  }
  .zf-mnav-toggle span{
    display: block; height: 2px; width: 22px; border-radius: 2px;
    background: #fff; transition: transform .25s ease, opacity .2s ease;
  }
  .zf-mnav-toggle.open span:nth-child(1){ transform: translateY(6px) rotate(45deg); }
  .zf-mnav-toggle.open span:nth-child(2){ opacity: 0; }
  .zf-mnav-toggle.open span:nth-child(3){ transform: translateY(-6px) rotate(-45deg); }

  /* Slide-in drawer */
  .zf-mnav-backdrop{
    position: fixed; inset: 0; background: rgba(0,0,0,.6);
    opacity: 0; visibility: hidden; transition: opacity .25s ease;
    z-index: 4000; backdrop-filter: blur(2px);
  }
  .zf-mnav-backdrop.open{ opacity: 1; visibility: visible; }
  .zf-mnav-drawer{
    position: fixed; top: 0; bottom: 0; inset-inline-start: 0;
    width: min(82vw, 320px); background: var(--zf-black, #141414);
    box-shadow: 2px 0 24px rgba(0,0,0,.5); z-index: 4001;
    transform: translateX(-105%); transition: transform .28s cubic-bezier(.4,0,.2,1);
    display: flex; flex-direction: column; padding-top: var(--zf-safe-top);
    overflow-y: auto;
  }
  html[dir="rtl"] .zf-mnav-drawer{ transform: translateX(105%); }
  .zf-mnav-drawer.open{ transform: translateX(0); }
  .zf-mnav-head{
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 20px; border-bottom: 1px solid rgba(255,255,255,.08);
  }
  .zf-mnav-head .logo{ font-size: 22px; }
  .zf-mnav-close{
    background: transparent; border: 0; color: #fff; font-size: 26px;
    line-height: 1; cursor: pointer; width: 40px; height: 40px; border-radius: 8px;
  }
  .zf-mnav-links{ display: flex; flex-direction: column; padding: 8px 0; }
  .zf-mnav-links a{
    display: flex; align-items: center; gap: 14px; padding: 16px 24px;
    color: #b3b3b3; text-decoration: none; font-size: 16px; font-weight: 500;
    border: 0; border-bottom: 1px solid rgba(255,255,255,.04);
    transition: color 0.2s, background 0.2s;
  }
  .zf-mnav-links a:active{ background: rgba(255,255,255,.06); }
  .zf-mnav-links a.active{ color: #fff; background: rgba(229,9,20,0.1); border-left: 4px solid var(--zf-red); }
  html[dir="rtl"] .zf-mnav-links a.active{ border-left: none; border-right: 4px solid var(--zf-red); }

  /* Hide the desktop inline links (already hidden at 768; extend to 900) */
  .navbar .nav-links{ display: none !important; }

  /* Declutter the top bar on phones: search is in the bottom tab bar,
     language + auth + account live in the hamburger drawer. This fixes the
     cramped/overlapping navbar on small screens. */
  .nav-right{ gap: 8px; }
  .navbar .search-box{ display: none !important; }
  .navbar .netflix-search-box{ display: none !important; }
  .navbar .lang-switcher{ display: none !important; }
  .nav-right .role-badge{ display: none !important; }
  .nav-right .username{ display: none !important; }
  .nav-right .user-info{ display: none !important; }
  .nav-right .btn-logout{ display: none !important; }
  .nav-right .btn-outline,
  .nav-right .btn-primary{ display: none !important; } /* moved into drawer */

  /* Billboard/hero: comfortable on phones */
  .billboard{ height: 62vh; min-height: 320px; }
  .billboard-content{ max-width: 92% !important; }
  .billboard-content .movie-logo{ font-size: 1.7em; }
  .billboard-buttons .btn{ min-height: 44px; padding: 10px 18px; font-size: 14px; }

  /* Rows: Momentum horizontal scroll + snap like App Store */
  .movie-row {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    scroll-snap-type: x mandatory !important;
    padding-bottom: 20px;
    gap: 12px !important;
    padding-inline: 4%;
  }
  .movie-row .movie-card {
    scroll-snap-align: center !important;
    flex: 0 0 45% !important; /* Larger cards for mobile swiping */
    border-radius: var(--radius-md) !important;
  }

  /* Touch = no hover: reveal card info always, remove hover-scale jump */
  .movie-card:hover { transform: none; }
  .movie-card:hover .card-img { transform: none; }
  
  /* Improve card text readability on mobile */
  .card-overlay {
      background: linear-gradient(0deg, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.4) 50%, transparent 100%);
      padding: 12px;
  }
  .card-overlay .card-title { font-size: 13px !important; font-weight: 700 !important; }

  /* Tap targets */
  .card-overlay .card-btn{ width: 32px; height: 32px; }
  .btn{ min-height: 42px; }
  a, button{ -webkit-tap-highlight-color: rgba(229,9,20,.2); }

  /* Forms: 16px prevents iOS auto-zoom; full width */
  input, select, textarea{ font-size: 16px !important; }
  .auth-box{ width: 92%; max-width: 420px; padding: 34px 22px; }

  /* Give the page bottom padding so the bottom tab bar never covers content */
  body.zf-has-bottomnav{ padding-bottom: calc(58px + var(--zf-safe-bottom)); }
}

/* ============================ TOUCH DEVICES ========================= */
@media (hover: none) and (pointer: coarse){
  /* On touch, the hover-reveal overlay is unreachable — keep it visible */
  .movie-card .card-overlay{ opacity: 1; }
}

/* ======================= BOTTOM TAB BAR (mobile) =================== */
@media (max-width: 900px){
  .zf-bottomnav{
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 3500;
    display: flex; justify-content: space-around; align-items: stretch;
    background: rgba(18, 18, 18, 0.75); backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px);
    border-top: 1px solid rgba(255,255,255,.08);
    padding-bottom: env(safe-area-inset-bottom, 20px);
  }
  .zf-bottomnav a{
    flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 4px; padding: 10px 2px 6px;
    color: #888; text-decoration: none; font-size: 11px; font-weight: 500;
    min-height: 56px;
    transition: color 0.2s;
  }
  .zf-bottomnav a .zf-ic{ font-size: 22px; line-height: 1; transition: transform 0.2s, filter 0.2s; }
  .zf-bottomnav a.active{ color: #fff; }
  .zf-bottomnav a.active .zf-ic{ 
    filter: drop-shadow(0 0 8px rgba(229,9,20,.8)); 
    transform: scale(1.1);
    color: var(--zf-red);
  }
  .zf-bottomnav a:active .zf-ic{ transform: scale(0.95); }
}

/* ============================ SMALL PHONES ========================= */
@media (max-width: 480px){
  .billboard-buttons{ flex-wrap: wrap; }
  .nav-right .search-box input{ width: 32vw; }
  .content-section .section-title{ font-size: 15px; }
}

/* Landscape video: let the player fill the screen on phones */
@media (max-width: 900px) and (orientation: landscape){
  .modal-video, .modal-video video, .modal-video iframe{ min-height: 82vh; }
}

/* =====================================================================
   ADMIN PANEL — mobile collapse (additive; admin uses .zf-admin-nav)
   ===================================================================== */
@media (max-width: 900px){
  .zf-admin-nav{ padding-top: var(--zf-safe-top); flex-wrap: nowrap; gap: 0; }
  /* Collapse the inline admin links into the shared drawer */
  .zf-admin-nav a.zf-link{ display: none !important; }
  .zf-admin-nav a.zf-right{ display: none !important; }
  .zf-admin-nav .zf-spacer{ display: none !important; }
  .zf-admin-nav .zf-brand{ margin-inline-start: 4px; }
  /* Toggle lives inside the admin bar */
  .zf-admin-nav .zf-mnav-toggle span{ background:#fff; }
  .admin-container{ padding-left: 12px !important; padding-right: 12px !important; }
  .users-table, table{ display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
}

/* =====================================================================
   IMMERSIVE PLAYER PAGES — fill the phone screen nicely
   ===================================================================== */
@media (max-width: 900px){
  .player-wrap, .video-wrap, #playerContainer, .sf-player, .plyr{ width: 100% !important; max-width: 100vw !important; }
  video{ max-width: 100vw; }
  /* No bottom nav on player pages (immersive mode) */
  .zfx13-mobile-player .zf-bottomnav{ display: none !important; }
  .zfx13-mobile-player { padding-bottom: 0 !important; }
  /* Prevent body scroll on player page */
  .zfx13-mobile-player { overflow: hidden !important; position: fixed !important; inset: 0 !important; }
}
@media (max-width: 900px) and (orientation: landscape){
  .player-wrap, .video-wrap, #playerContainer, .sf-player{ height: 100vh !important; height: 100dvh !important; }
}

/* ============ Language switcher inside the mobile drawer ============ */
@media (max-width: 900px){
  .zf-mnav-links .zf-mnav-lang{
    display: flex; gap: 14px; align-items: center;
    padding: 14px 20px; margin-top: 6px;
    border-top: 1px solid var(--zf-border, #333);
    font-size: 15px;
  }
  .zf-mnav-links .zf-mnav-lang a{
    display: inline; padding: 0; border: 0; color: #b3b3b3;
  }
  .zf-mnav-links .zf-mnav-lang a:hover{ color: #fff; }
}

/* ==================== ZFX12: RTL DRAWER FIX (Arabic) ==================== */
/* Root cause: "html[dir=rtl] .zf-mnav-drawer { translateX(105%) }" outranked
   ".zf-mnav-drawer.open" by specificity, so in Arabic the drawer NEVER slid in:
   the backdrop dimmed, the icon turned into an X, but the menu stayed off-screen. */
@media (max-width: 900px) {
  html[dir="rtl"] .zf-mnav-drawer.open { transform: translateX(0) !important; }
  html[dir="rtl"] .zf-mnav-drawer { box-shadow: -2px 0 24px rgba(0,0,0,.5); }
  /* Keep the 3-line icon pixel-perfect regardless of text direction */
  .zf-mnav-toggle { direction: ltr !important; text-align: left !important; letter-spacing: 0 !important; }
  .zf-mnav-toggle span { margin: 0 !important; }
  /* Drawer content reads naturally in Arabic */
  html[dir="rtl"] .zf-mnav-head { direction: rtl; }
  html[dir="rtl"] .zf-mnav-links a { text-align: right; }
}
