/* iptlive — cinema theme
 * deep navy + soft gold + vignette
 */

:root {
    --bg-deepest: #04060c;
    --bg-deep: #0a0e1a;
    --bg-soft: #11172a;
    --bg-card: rgba(17, 23, 42, 0.85);
    --bg-card-hover: rgba(20, 28, 50, 0.95);

    --border: rgba(201, 169, 97, 0.18);
    --border-strong: rgba(201, 169, 97, 0.4);

    --gold: #c9a961;
    --gold-bright: #e6c478;
    --gold-dark: #8a7138;

    --text: #ece9df;
    --text-soft: #a8a59a;
    --text-dim: #6e6c63;

    --danger: #d44848;
    --danger-soft: #ff7575;
    --success: #5fa15f;

    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 30px 90px rgba(0, 0, 0, 0.7);

    --radius-sm: 6px;
    --radius: 12px;
    --radius-lg: 18px;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-deepest);
    background-image:
        radial-gradient(ellipse at 15% 20%, rgba(201, 169, 97, 0.06), transparent 50%),
        radial-gradient(ellipse at 85% 80%, rgba(34, 56, 102, 0.12), transparent 50%);
    background-attachment: fixed;
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--gold-bright); text-decoration: none; }
a:hover { color: var(--gold); }

h1, h2, h3, h4 {
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

h1 { font-size: 2rem; line-height: 1.2; }
h2 { font-size: 1.5rem; line-height: 1.3; }
h3 { font-size: 1.15rem; }

.muted { color: var(--text-soft); }
.dim   { color: var(--text-dim); }
.gold  { color: var(--gold); }

/* ======= cards ======= */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
}

.card-flat {
    background: rgba(11, 16, 30, 0.7);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

/* ======= forms ======= */
label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-soft);
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="url"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.15s, background 0.15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--gold);
    background: rgba(0, 0, 0, 0.4);
}

input::placeholder { color: var(--text-dim); }

/* ======= buttons ======= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: linear-gradient(180deg, rgba(201, 169, 97, 0.1), rgba(201, 169, 97, 0.04));
    color: var(--gold-bright);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    user-select: none;
}

.btn:hover {
    background: linear-gradient(180deg, rgba(201, 169, 97, 0.18), rgba(201, 169, 97, 0.08));
    border-color: var(--gold);
    color: var(--gold-bright);
}

.btn-primary {
    background: linear-gradient(180deg, #d6b66e, #a88e48);
    color: #0a0e1a;
    border-color: var(--gold-bright);
}
.btn-primary:hover {
    background: linear-gradient(180deg, #e6c478, #b89856);
    color: #0a0e1a;
}

.btn-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text-soft);
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-soft); }

.btn-danger {
    background: linear-gradient(180deg, rgba(212, 72, 72, 0.2), rgba(212, 72, 72, 0.08));
    border-color: var(--danger);
    color: var(--danger-soft);
}

.btn-block { display: flex; width: 100%; }

/* ======= alerts ======= */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    margin-bottom: 18px;
    border-left: 3px solid;
}
.alert-danger {
    background: rgba(212, 72, 72, 0.1);
    border-color: var(--danger);
    color: var(--danger-soft);
}
.alert-success {
    background: rgba(95, 161, 95, 0.1);
    border-color: var(--success);
    color: #95d195;
}
.alert-warning {
    background: rgba(201, 169, 97, 0.08);
    border-color: var(--gold);
    color: var(--gold-bright);
}

/* ======= layout helpers ======= */
.container { max-width: 1280px; margin: 0 auto; padding: 0 20px; }
.center-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 40px 20px; }

.row { display: flex; gap: 16px; }
.col { flex: 1; }
.stack > * + * { margin-top: 16px; }
.stack-sm > * + * { margin-top: 8px; }
.stack-lg > * + * { margin-top: 28px; }

.brand {
    font-size: 1.4rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--gold-bright), var(--gold-dark));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: -0.02em;
}

/* "LIVE" pill — indicador rojo pulsante junto a la marca */
.brand-wrap {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}
.brand-live {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px 3px 7px;
    background: linear-gradient(180deg, #d44848, #a83333);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    border-radius: 4px;
    text-transform: uppercase;
    box-shadow: 0 2px 8px rgba(212, 72, 72, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.12);
    line-height: 1;
}
.brand-live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7);
    animation: brand-live-pulse 1.6s ease-in-out infinite;
}
@keyframes brand-live-pulse {
    0%   { box-shadow: 0 0 0 0   rgba(255, 255, 255, 0.7); }
    70%  { box-shadow: 0 0 0 5px rgba(255, 255, 255, 0); }
    100% { box-shadow: 0 0 0 0   rgba(255, 255, 255, 0); }
}

/* ======= header ======= */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 28px;
    background: linear-gradient(180deg, rgba(4, 6, 12, 0.95), rgba(10, 14, 26, 0.7));
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

/* ======= overlays / modals ======= */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(2, 4, 8, 0.85);
    backdrop-filter: blur(6px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px;
    max-width: 520px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform 0.2s;
}
.modal-backdrop.open .modal { transform: scale(1); }

/* ======= channel grid ======= */
.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}

.channel-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s, background 0.15s;
    aspect-ratio: 16 / 11;
    display: flex;
    flex-direction: column;
}
.channel-card:hover {
    border-color: var(--gold);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
}
.channel-card-logo {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
    background: rgba(0, 0, 0, 0.3);
}
.channel-card-logo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}
.channel-card-logo .placeholder {
    font-size: 2rem;
    color: var(--text-dim);
}
.channel-card-info {
    padding: 8px 12px;
    background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,0.45));
}
.channel-card-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.channel-card-epg {
    font-size: 0.72rem;
    color: var(--text-soft);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 2px;
}

/* ======= utility ======= */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(201, 169, 97, 0.25);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.fade-in { animation: fadein 0.3s ease-out; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ======= mobile ======= */
@media (max-width: 640px) {
    h1 { font-size: 1.5rem; }
    .card { padding: 22px; }
    .channel-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
}

/* ======= performance ======= */
/* content-visibility: auto evita que el browser paginé/renderice cards
   off-screen. Para 2345 channel-cards en el dashboard, esto baja el costo
   de scroll y layout de O(N) a O(visible). El contain-intrinsic-size es la
   altura aproximada que el browser reserva mientras la card está skipeada. */
.channel-card {
    content-visibility: auto;
    contain-intrinsic-size: 200px 240px;
}
@media (max-width: 640px) {
    .channel-card { contain-intrinsic-size: 200px 200px; }
}

/* En móvil, backdrop-filter (blur) es muy caro en GPU y produce stutter al
   scrollear. Se reemplaza por background opaco. La diferencia visual es
   mínima vs el costo de performance. */
@media (max-width: 768px) {
    .modal-backdrop,
    .overlay,
    .zap-panel,
    .epg-panel,
    .buffer-pill,
    .share-indicator,
    .expired-overlay,
    .owner-card { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
}
