:root {
    --an-negro: #0b0b0c;
    --an-negro-2: #161618;
    --an-negro-3: #1f1f22;
    --an-rojo: #e10600;
    --an-rojo-2: #ff2b1f;
    --an-blanco: #f5f5f5;
    --an-gris: #9a9a9f;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--an-negro);
    color: var(--an-blanco);
    font-family: 'Segoe UI', Helvetica, Arial, sans-serif;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

.an-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
    background: linear-gradient(180deg, #101012, #0b0b0c);
    border-bottom: 2px solid var(--an-rojo);
}

.an-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-size: 18px;
}

.an-brand .dot { color: var(--an-rojo); }

.an-nav { display: flex; gap: 22px; font-size: 14px; }
.an-nav a { color: var(--an-gris); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.an-nav a:hover { color: var(--an-blanco); }

.an-user { font-size: 13px; color: var(--an-gris); display: flex; align-items: center; gap: 12px; }
.an-user .pill {
    background: var(--an-negro-3);
    border: 1px solid #2a2a2e;
    padding: 6px 12px;
    border-radius: 20px;
}

.an-container { max-width: 1100px; margin: 0 auto; padding: 40px 20px; }
.an-container.wide { max-width: 1400px; }

.an-card {
    background: var(--an-negro-2);
    border: 1px solid #232326;
    border-radius: var(--radius);
    padding: 26px;
}

.an-title {
    font-size: 26px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 0 6px 0;
}
.an-title span { color: var(--an-rojo); }

.an-sub { color: var(--an-gris); margin: 0 0 26px 0; font-size: 14px; }

.an-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }

.an-room {
    background: var(--an-negro-3);
    border: 1px solid #2a2a2e;
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color .15s ease, transform .15s ease;
}
.an-room:hover { border-color: var(--an-rojo); transform: translateY(-2px); }
.an-room h3 { margin: 0; font-size: 17px; }
.an-room .meta { font-size: 12px; color: var(--an-gris); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--an-rojo);
    color: #fff;
    border: none;
    padding: 11px 18px;
    border-radius: 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    font-size: 13px;
    cursor: pointer;
    transition: background .15s ease;
}
.btn:hover { background: var(--an-rojo-2); }
.btn.secundario { background: transparent; border: 1px solid #3a3a3e; color: var(--an-blanco); }
.btn.secundario:hover { border-color: var(--an-rojo); }
.btn.peligro { background: #3a1414; color: #ff8a80; border: 1px solid #5c1f1f; }
.btn.peligro:hover { background: #5c1f1f; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

input, select {
    width: 100%;
    background: var(--an-negro);
    border: 1px solid #2f2f33;
    color: var(--an-blanco);
    padding: 11px 13px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 14px;
}
input:focus, select:focus { outline: none; border-color: var(--an-rojo); }
label { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--an-gris); display: block; margin-bottom: 6px; }

.form-box { max-width: 380px; margin: 8vh auto; }
.form-box .logo-line { text-align: center; margin-bottom: 26px; }
.form-box .logo-line .dot { color: var(--an-rojo); }

.error-msg { background: #3a1414; border: 1px solid #5c1f1f; color: #ff8a80; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.ok-msg { background: #133a1a; border: 1px solid #1f5c2c; color: #8aff9d; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #232326; }
th { color: var(--an-gris); text-transform: uppercase; font-size: 11px; letter-spacing: .5px; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.badge.admin { background: #3a1414; color: #ff8a80; }
.badge.ejecutivo { background: #14263a; color: #8ac4ff; }
.badge.on { background: #133a1a; color: #8aff9d; }
.badge.off { background: #2a2a2e; color: var(--an-gris); }

/* ---------- Sala de llamada ---------- */
.call-shell {
    position: fixed;
    inset: 0;
    background: #000;
    display: flex;
    flex-direction: column;
}
.call-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 18px;
    background: #0b0b0c;
    border-bottom: 1px solid #222;
    z-index: 5;
}
.call-header .an-brand { font-size: 15px; }
.call-header .sala-nombre { font-size: 13px; color: var(--an-gris); }
.call-body { flex: 1; display: flex; min-height: 0; }

.side-panel {
    width: 260px;
    background: #101012;
    border-left: 1px solid #222;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.side-panel h4 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--an-gris);
    margin: 0 0 10px 0;
}
.side-panel .tool-btn {
    width: 100%;
    text-align: left;
    background: var(--an-negro-3);
    border: 1px solid #2a2a2e;
    color: var(--an-blanco);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.side-panel .tool-btn:hover { border-color: var(--an-rojo); }
.side-panel .tool-btn.active { border-color: var(--an-rojo); background: #241414; }

.overlay-brand {
    position: absolute;
    left: 18px;
    bottom: 18px;
    background: rgba(11,11,12,.75);
    border-left: 3px solid var(--an-rojo);
    padding: 8px 14px;
    font-size: 13px;
    border-radius: 4px;
    z-index: 10;
    display: none;
    backdrop-filter: blur(2px);
}
.overlay-brand.show { display: block; }
.overlay-brand b { color: var(--an-rojo); }

.leave-guard-banner {
    background: #3a1414;
    color: #ff8a80;
    font-size: 12px;
    text-align: center;
    padding: 6px;
}

@media (max-width: 820px) {
    .side-panel { display: none; }
}

/* ---------- Pre-ingreso ---------- */
.prejoin-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.prejoin-card { width: 100%; max-width: 420px; }
.prejoin-card video {
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 8px;
    margin-bottom: 16px;
    object-fit: cover;
    transform: scaleX(-1);
}

/* ---------- Grid de video (WebRTC nativo) ---------- */
.video-grid {
    flex: 1;
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 8px;
    padding: 8px;
    align-content: center;
    position: relative;
}
.tile {
    position: relative;
    background: #101012;
    border: 1px solid #222;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 16/9;
    cursor: pointer;
}
.tile video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.tile[data-peer="local"] video { transform: scaleX(-1); }
.tile-label {
    position: absolute;
    left: 8px;
    bottom: 8px;
    background: rgba(0,0,0,.6);
    padding: 3px 9px;
    border-radius: 5px;
    font-size: 12px;
}

.video-grid.pinned-mode { display: flex; flex-wrap: wrap; align-content: flex-start; }
.video-grid.pinned-mode .tile { width: 150px; height: 100px; aspect-ratio: auto; }
.video-grid.pinned-mode .tile.main-tile { width: 100%; height: 72%; order: -1; }

/* ---------- Chat ---------- */
.chat-box {
    height: 140px;
    overflow-y: auto;
    background: var(--an-negro-3);
    border: 1px solid #2a2a2e;
    border-radius: 8px;
    padding: 8px;
    font-size: 13px;
    margin-bottom: 8px;
}
.chat-msg { margin-bottom: 6px; }
.chat-msg.mio { color: var(--an-blanco); }
.chat-msg b { color: var(--an-rojo); }
