:root {
    --bg: #0f172a;
    --surface: #ffffff;
    --ink: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --ok-bg: #ecfdf5; --ok-ink: #065f46;
    --err-bg: #fef2f2; --err-ink: #991b1b;
    --live: #dc2626;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--ink);
    background: #f1f5f9;
    line-height: 1.55;
    /* Sticky footer: el body ocupa toda la altura y empuja el pie abajo */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 960px; margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header {
    background: var(--bg);
    color: #fff;
    padding: 14px 0;
    position: sticky; top: 0; z-index: 10;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { color: #fff; font-weight: 700; font-size: 1.15rem; display: inline-flex; align-items: center; }
.brand:hover { text-decoration: none; }
.brand-logo { max-height: 36px; width: auto; display: block; }

/* Vistas previas de apariencia (panel) */
.preview { display: block; margin: 8px 0; }
.preview-logo { max-height: 48px; width: auto; background: #0f172a; padding: 6px 10px; border-radius: 8px; }
.preview-favicon { width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: .9rem; }
label.check input { width: auto; margin: 0; }
.nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.nav a { color: #cbd5e1; font-size: .95rem; }
.nav a:hover { color: #fff; text-decoration: none; }
.nav-user { color: #94a3b8; font-size: .9rem; }

/* Layout */
.site-header { flex-shrink: 0; }
main.container { padding-top: 28px; padding-bottom: 60px; flex: 1 0 auto; width: 100%; }
.hero { margin-bottom: 24px; }
.hero h1 { margin: 0 0 4px; font-size: 1.9rem; }
h1 { font-size: 1.6rem; }

/* Cards & grid */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
}
.card-narrow { max-width: 440px; margin-left: auto; margin-right: auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.webinar-card h2 { font-size: 1.15rem; margin: 6px 0 8px; }
.meta { color: var(--muted); font-size: .9rem; margin: 0 0 14px; }
.description { margin: 16px 0; }
.muted { color: var(--muted); font-size: .92rem; }

/* Buttons */
.btn {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    padding: 10px 18px;
    border: 0;
    border-radius: 8px;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; border: 1px solid #475569; }
.btn-ghost:hover { background: #1e293b; }
.btn-live { background: var(--live); }
.btn-live:hover { background: #b91c1c; }

/* Forms */
form label { display: block; margin-bottom: 14px; font-weight: 600; font-size: .92rem; }
input, textarea, select {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    font-weight: 400;
    background: #fff;
}
input:focus, textarea:focus, select:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}
.form-row { display: flex; gap: 14px; }
.form-row label { flex: 1; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: .93rem; }
.alert-ok  { background: var(--ok-bg);  color: var(--ok-ink); }
.alert-err { background: var(--err-bg); color: var(--err-ink); }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px;
    font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
    background: #e2e8f0; color: #475569; }
.badge-live { background: var(--live); color: #fff; }
.badge-scheduled { background: #dbeafe; color: #1e40af; }
.badge-draft { background: #f1f5f9; color: #64748b; }
.badge-ended { background: #e2e8f0; color: #475569; }

/* Admin */
.admin-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.table-wrap { overflow-x: auto; padding: 0; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: .92rem; }
.table th { background: #f8fafc; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.actions { display: flex; gap: 12px; align-items: center; }
.inline { display: inline; margin: 0; }
.link-danger { background: none; border: 0; color: #dc2626; cursor: pointer; font: inherit; padding: 0; }
.link-danger:hover { text-decoration: underline; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding: 20px 0; color: var(--muted); background: #fff; flex-shrink: 0; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-links a { color: var(--muted); font-size: .85rem; }
.footer-links a:hover { color: var(--ink); }

/* Puerta de código (portada) */
.code-gate { display: flex; justify-content: center; padding: 32px 0; }
.code-gate .card-narrow { width: 100%; text-align: center; }
.code-input {
    text-align: center;
    font-size: 1.6rem;
    letter-spacing: .35em;
    font-weight: 700;
    text-transform: uppercase;
    padding: 16px 12px;
    margin: 8px 0 16px;
}
.code-input::placeholder { letter-spacing: .1em; font-weight: 400; text-transform: none; }
.code-field { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; letter-spacing: .15em; text-transform: uppercase; }

/* Píldora de código en el panel admin */
.code-pill {
    background: #eef2ff; color: var(--primary-dark);
    padding: 2px 8px; border-radius: 6px; font-weight: 700;
    font-family: ui-monospace, Consolas, monospace; letter-spacing: .08em;
}

.nav-admin-link { color: #94a3b8; font-size: .85rem; }

/* Páginas legales */
.legal { max-width: 760px; margin-left: auto; margin-right: auto; }
.legal h1 { margin-bottom: 4px; }
.legal h2 { font-size: 1.1rem; margin-top: 26px; }
.legal ul { padding-left: 20px; }
.legal li { margin-bottom: 6px; }
.legal-note {
    background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
    padding: 12px 16px; border-radius: 8px; margin: 16px 0 8px; font-size: .9rem;
}
.legal-note code { background: #fef3c7; padding: 1px 5px; border-radius: 4px; }
.legal-body h2 { font-size: 1.1rem; margin-top: 26px; }
.legal-body h3 { font-size: 1rem; margin-top: 18px; }
.legal-body ul { padding-left: 20px; }
.legal-body li { margin-bottom: 6px; }
textarea.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .9rem; line-height: 1.5; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Sala del webinar */
.room-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.room-head h1 { margin: 0 0 4px; }
.video-stage { margin-bottom: 20px; }
.video-placeholder {
    aspect-ratio: 16 / 9;
    width: 100%;
    background: #0f172a;
    color: #cbd5e1;
    border-radius: var(--radius);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; gap: 6px;
    border: 1px solid #1e293b;
}
.video-placeholder p { margin: 0; font-size: 1.1rem; }
.video-placeholder small { color: #64748b; }
.video-placeholder.live { border-color: var(--live); }
.video-wrap { position: relative; }
.video-el { width: 100%; aspect-ratio: 16/9; background: #000; border-radius: var(--radius); display: block; }
.unmute-btn { position: absolute; left: 50%; bottom: 54px; transform: translateX(-50%);
    background: rgba(15,23,42,.85); color: #fff; border: 1px solid rgba(255,255,255,.25);
    padding: 10px 18px; border-radius: 999px; font-weight: 600; cursor: pointer; font-size: .95rem; }
.unmute-btn:hover { background: rgba(15,23,42,.95); }
.video-preview { width: 100%; aspect-ratio: 16/9; background: #000; border-radius: 10px; display: block; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.live-controls { display: flex; gap: 10px; }

/* Controles de micrófono (página de emisión) */
.mic-box { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin: 12px 0; background: #f8fafc; }
.mic-box > label { font-size: .85rem; font-weight: 600; }
.mic-box select { margin-top: 4px; }
.mic-meter { height: 12px; background: #e2e8f0; border-radius: 6px; overflow: hidden; margin: 12px 0; }
.mic-meter span { display: block; height: 100%; width: 0%; background: #4f46e5; transition: width .05s linear; }
.mic-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mic-gain { display: flex; align-items: center; gap: 8px; font-size: .85rem; font-weight: 400; flex: 1; min-width: 160px; margin: 0; }
.mic-gain input { flex: 1; margin: 0; width: auto; }
.btn-sm { padding: 6px 12px; font-size: .85rem; }

/* Sala con chat lateral */
.room-grid { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
.room-main { min-width: 0; }
@media (max-width: 900px){ .room-grid { grid-template-columns: 1fr; } }

/* Chat en vivo */
.chat { display: flex; flex-direction: column; height: 480px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: .92rem; background: #f8fafc; }
.chat-presence { font-size: .82rem; color: var(--primary-dark); font-weight: 700; background: #eef2ff; padding: 2px 9px; border-radius: 999px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { font-size: .88rem; line-height: 1.4; }
.chat-name { font-weight: 700; color: var(--ink); margin-right: 4px; }
.chat-badge { font-size: .66rem; background: var(--primary); color: #fff; padding: 1px 6px; border-radius: 999px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.chat-qtag { font-size: .7rem; color: #b45309; margin: 0 4px; font-weight: 600; }
.chat-body { color: #334155; word-break: break-word; }
.chat-msg-q { background: #fffbeb; border-left: 3px solid #f59e0b; padding: 6px 8px; border-radius: 6px; }
.chat-msg-admin .chat-name { color: var(--primary-dark); }
.chat-hide { background: none; border: 0; color: #cbd5e1; cursor: pointer; font-size: .85rem; padding: 0 2px; }
.chat-hide:hover { color: var(--live); }
.chat-input { border-top: 1px solid var(--border); padding: 8px 10px; }
.chat-input textarea { resize: none; margin: 0; font-size: .9rem; }
.chat-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.chat-q { font-size: .8rem; font-weight: 400; display: flex; align-items: center; gap: 5px; margin: 0; }
.chat-q input { width: auto; margin: 0; }
.chat-warn { background: var(--err-bg); color: var(--err-ink); font-size: .82rem; padding: 6px 10px; border-radius: 6px; margin: 0 0 6px; }
.chat-admin-wrap .chat { height: 360px; max-width: 560px; }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
@media (max-width: 720px){ .grid-2 { grid-template-columns: 1fr; } }
.room-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.btn-dark { background: #1e293b; border-color: #334155; color: #fff; }
.btn-dark:hover { background: #0f172a; }

@media (max-width: 520px) {
    .form-row { flex-direction: column; gap: 0; }
    .nav { gap: 12px; }
    .code-input { font-size: 1.3rem; letter-spacing: .25em; }
}
