/* ============================================================
   FLEXVISION — Estética Apple TV+ cinematográfica
   Fraunces (display editorial) + Geist (UI sans-serif)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,300;9..144,400;9..144,600;9..144,800&display=swap');
@import url('https://cdn.jsdelivr.net/npm/geist@1.3.1/dist/fonts/geist-sans/style.css');

:root {
    --bg: #000000;
    --bg-card: #0a0a0a;
    --bg-card-hover: #141414;
    --surface: rgba(255, 255, 255, 0.04);
    --surface-strong: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --text: #f5f5f7;
    --text-dim: rgba(245, 245, 247, 0.65);
    --text-muted: rgba(245, 245, 247, 0.45);
    --accent: #ffffff;
    --accent-blue: #0a84ff;
    --accent-warm: #d4a574;
    --danger: #ff453a;
    --success: #30d158;
    --shadow-glow: 0 0 80px rgba(255, 255, 255, 0.06);
    --radius: 14px;
    --radius-lg: 22px;
    --easing: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Geist', -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv11', 'ss01', 'ss03';
    letter-spacing: -0.01em;
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
img { max-width: 100%; display: block; }
input, select, textarea { font-family: inherit; }

/* ============= TIPOGRAFÍA ============= */
.serif {
    font-family: 'Fraunces', 'Times New Roman', serif;
    font-variation-settings: 'opsz' 144;
    letter-spacing: -0.025em;
}

h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.1; }

/* ============= LAYOUT ============= */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 32px;
}

@media (max-width: 768px) {
    .container { padding: 0 20px; }
}

/* ============= NAV ============= */
.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    background: rgba(0, 0, 0, 0.72);
    border-bottom: 1px solid var(--border);
}

.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    padding: 0 32px;
    max-width: 1400px;
    margin: 0 auto;
}

.brand {
    font-family: 'Fraunces', serif;
    font-weight: 600;
    font-size: 22px;
    letter-spacing: -0.03em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-mark {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: linear-gradient(135deg, #ffffff 0%, #888888 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-weight: 800;
    font-size: 13px;
    font-family: 'Geist', sans-serif;
}

.nav-links {
    display: flex;
    gap: 28px;
    align-items: center;
}

.nav-links a {
    font-size: 14px;
    color: var(--text-dim);
    transition: color 0.2s;
}
.nav-links a:hover { color: var(--text); }
.nav-links a.active { color: var(--text); }

@media (max-width: 768px) {
    .nav-inner { padding: 0 20px; height: 56px; }
    .nav-links { gap: 16px; }
    .nav-links a { font-size: 13px; }
}

/* ============= HERO LANDING ============= */
.hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 120px 0 80px;
}

.hero-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 30%, rgba(10, 132, 255, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 70%, rgba(212, 165, 116, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 100%, rgba(255, 255, 255, 0.04) 0%, transparent 60%);
    z-index: 0;
}

.hero-grain {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.4;
    z-index: 1;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.08 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 900px;
    padding: 0 24px;
    opacity: 0;
    animation: fadeUp 1.2s var(--easing) 0.2s forwards;
}

.hero-eyebrow {
    display: inline-block;
    font-size: 13px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 24px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 100px;
    background: var(--surface);
}

.hero h1 {
    font-family: 'Fraunces', serif;
    font-weight: 400;
    font-size: clamp(52px, 9vw, 132px);
    line-height: 0.95;
    letter-spacing: -0.04em;
    margin-bottom: 28px;
    background: linear-gradient(180deg, #ffffff 30%, #888888 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero h1 em {
    font-style: italic;
    font-variation-settings: 'opsz' 144, 'SOFT' 100;
    background: linear-gradient(180deg, #d4a574 0%, #b08856 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    font-size: clamp(17px, 2vw, 21px);
    color: var(--text-dim);
    max-width: 580px;
    margin: 0 auto 48px;
    line-height: 1.5;
}

.hero-cta {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

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

/* ============= BOTONES ============= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    border-radius: 100px;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: -0.01em;
    transition: all 0.25s var(--easing);
    cursor: pointer;
    border: 1px solid transparent;
    white-space: nowrap;
}

.btn-primary {
    background: var(--text);
    color: var(--bg);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 32px rgba(255, 255, 255, 0.15); }

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
    backdrop-filter: blur(10px);
}
.btn-secondary:hover { background: var(--surface-strong); border-color: rgba(255,255,255,0.3); }

.btn-telegram {
    background: linear-gradient(135deg, #2AABEE 0%, #229ED9 100%);
    color: #fff;
}
.btn-telegram:hover { transform: translateY(-1px); box-shadow: 0 8px 32px rgba(42, 171, 238, 0.35); }

.btn-ghost {
    color: var(--text-dim);
    padding: 10px 16px;
}
.btn-ghost:hover { color: var(--text); }

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-block { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 13px; }

/* ============= AUTH FORM ============= */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 24px 40px;
    position: relative;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: rgba(20, 20, 20, 0.6);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    position: relative;
    z-index: 2;
}

.auth-card h2 {
    font-family: 'Fraunces', serif;
    font-size: 32px;
    font-weight: 500;
    margin-bottom: 8px;
    letter-spacing: -0.03em;
}

.auth-card .subtitle {
    color: var(--text-dim);
    font-size: 15px;
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 16px;
}

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

.form-control {
    width: 100%;
    padding: 13px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-size: 15px;
    transition: all 0.2s;
}
.form-control:focus {
    outline: none;
    border-color: var(--accent-blue);
    background: rgba(255, 255, 255, 0.06);
}
.form-control::placeholder { color: var(--text-muted); }

.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0;
    color: var(--text-muted);
    font-size: 12px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.auth-footer {
    margin-top: 24px;
    text-align: center;
    font-size: 14px;
    color: var(--text-dim);
}
.auth-footer a { color: var(--text); border-bottom: 1px solid var(--border-strong); padding-bottom: 1px; }

/* ============= ALERTS ============= */
.alert {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 16px;
    border: 1px solid;
}
.alert-success { background: rgba(48, 209, 88, 0.1); border-color: rgba(48, 209, 88, 0.3); color: #5cd97e; }
.alert-error { background: rgba(255, 69, 58, 0.1); border-color: rgba(255, 69, 58, 0.3); color: #ff7268; }
.alert-info { background: rgba(10, 132, 255, 0.1); border-color: rgba(10, 132, 255, 0.3); color: #4ba3ff; }

/* ============= CATÁLOGO ============= */
.catalog-header {
    padding: 80px 0 40px;
    text-align: center;
}

.catalog-header h1 {
    font-family: 'Fraunces', serif;
    font-weight: 400;
    font-size: clamp(40px, 6vw, 72px);
    margin-bottom: 12px;
    letter-spacing: -0.03em;
}

.catalog-header p {
    color: var(--text-dim);
    font-size: 17px;
}

.movie-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
    padding-bottom: 80px;
}

.movie-card {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-card);
    cursor: pointer;
    transition: transform 0.4s var(--easing), box-shadow 0.4s var(--easing);
    aspect-ratio: 16 / 10;
}

.movie-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255,255,255,0.1);
    z-index: 2;
}

.movie-card-poster {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    transition: transform 0.6s var(--easing);
}
.movie-card:hover .movie-card-poster { transform: scale(1.05); }

.movie-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 40%, rgba(0,0,0,0.92) 100%);
}

.movie-card-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
}

.movie-card-title {
    font-family: 'Fraunces', serif;
    font-weight: 500;
    font-size: 22px;
    line-height: 1.15;
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}

.movie-card-meta {
    font-size: 12px;
    color: var(--text-dim);
    display: flex;
    gap: 8px;
    align-items: center;
}
.movie-card-meta span:not(:last-child)::after {
    content: '·';
    margin-left: 8px;
    color: var(--text-muted);
}

.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-dim);
}
.empty-state h3 {
    font-family: 'Fraunces', serif;
    font-size: 28px;
    margin-bottom: 8px;
    color: var(--text);
}

/* ============= REPRODUCTOR (CORREGIDO) ============= */
.player-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: #000;
}

.player-back {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 100;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(20px);
    color: #fff;
    padding: 10px 16px;
    border-radius: 100px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(255,255,255,0.1);
    transition: all 0.2s;
}

.player-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    position: relative;
}

.player-frame {
    position: relative;
    width: 100%;
    max-width: 1280px;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 40px 120px rgba(0,0,0,0.8);
}

/* El video ahora permite clics directamente */
#yt-player {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    border: 0;
    z-index: 5;
    pointer-events: auto;
}

.player-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none; /* Deja pasar clicks al video */
    background: linear-gradient(180deg, rgba(0,0,0,0.5) 0%, transparent 20%, transparent 80%, rgba(0,0,0,0.8) 100%);
    transition: opacity 0.3s;
}

/* Solo los controles recuperan el clic */
.player-top, .player-bottom, .player-btn, .progress-container {
    pointer-events: auto;
}

.player-frame.controls-hidden .player-overlay,
.player-frame.controls-hidden .player-back {
    opacity: 0;
}

.player-top { padding: 24px 32px; color: #fff; }

.player-bottom { padding: 0 32px 24px; }

/* Contenedor de progreso para mejorar el área de clic */
.progress-container {
    width: 100%;
    padding: 12px 0;
    cursor: pointer;
}

.progress-bar {
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 100px;
    position: relative;
    transition: height 0.2s;
}

.progress-container:hover .progress-bar { height: 6px; }

.progress-bar-fill {
    height: 100%;
    background: #fff;
    width: 0%;
    border-radius: 100px;
    position: relative;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    right: -7px; top: 50%;
    transform: translateY(-50%);
    width: 14px; height: 14px;
    background: #fff;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s;
}

.progress-container:hover .progress-bar-fill::after { opacity: 1; }

.player-controls {
    display: flex;
    align-items: center;
    gap: 18px;
    color: #fff;
    margin-top: 8px;
}

.player-btn-play {
    width: 56px; height: 56px;
    background: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.player-btn-play svg { fill: #000; width: 24px; height: 24px; }

.player-time {
    font-size: 13px;
    color: rgba(255,255,255,0.8);
    font-variant-numeric: tabular-nums;
}

/* ============= ADMIN ============= */
.admin-layout {
    min-height: 100vh;
    padding: 100px 0 60px;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: border-color 0.2s;
}
.stat-card:hover { border-color: var(--border-strong); }

.stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-value {
    font-family: 'Fraunces', serif;
    font-size: 36px;
    font-weight: 400;
    letter-spacing: -0.02em;
    line-height: 1;
}

.stat-sub {
    font-size: 13px;
    color: var(--text-dim);
    margin-top: 6px;
}

.admin-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-bottom: 24px;
}

.admin-section h2 {
    font-family: 'Fraunces', serif;
    font-weight: 500;
    font-size: 26px;
    margin-bottom: 20px;
    letter-spacing: -0.02em;
}

.table {
    width: 100%;
    border-collapse: collapse;
}
.table th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    color: var(--text-dim);
}
.table tr:last-child td { border-bottom: none; }
.table td strong { color: var(--text); font-weight: 500; }

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}
.tab {
    padding: 12px 20px;
    color: var(--text-dim);
    font-size: 14px;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    cursor: pointer;
}
.tab.active { color: var(--text); border-bottom-color: var(--text); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.movie-row {
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 16px;
    background: var(--surface);
    border-radius: 12px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
}
.movie-row-poster {
    width: 80px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
    background: #222;
    flex-shrink: 0;
}
.movie-row-info { flex: 1; min-width: 0; }
.movie-row-info .t { font-weight: 500; color: var(--text); margin-bottom: 2px; }
.movie-row-info .m { font-size: 13px; color: var(--text-muted); }
.movie-row-actions { display: flex; gap: 8px; flex-shrink: 0; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    background: var(--surface-strong);
    border-radius: 100px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.02em;
}
.badge-success { background: rgba(48,209,88,0.15); color: #5cd97e; }
.badge-warn { background: rgba(255,159,10,0.15); color: #ffae3b; }

/* ============= ACCOUNT ============= */
.account-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
@media (max-width: 768px) {
    .account-grid { grid-template-columns: 1fr; }
}

/* ============= UTILS ============= */
.text-center { text-align: center; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.hidden { display: none; }