/* ============================================================
   Wero MX — call.css
   Estilos del modulo de LLAMADAS (audio/video, WebRTC). Tematizado con las variables .px-skin
   (nunca hex crudo salvo el backdrop oscuro estandar, como el lightbox del chat). Cubre la ventana
   de llamada activa (overlay + grid de videos + controles) y el modal de llamada entrante.
   ============================================================ */

/* ===================== VENTANA DE LLAMADA ACTIVA ===================== */

.call-overlay {
    position: fixed;
    right: 24px;
    bottom: 84px;              /* por encima de la barra de tareas */
    z-index: 4000;
    width: 420px;
    max-width: calc(100vw - 48px);
    display: flex;
    flex-direction: column;
}

/* Maximizada: cubre TODO el viewport del navegador (sin margenes, sin backdrop). */
.call-overlay.call-max {
    inset: 0;
    right: 0; bottom: 0;
    width: 100vw; max-width: 100vw;
    align-items: stretch;
    justify-content: stretch;
    background: var(--bg-body);
    padding: 0;
}

/* Minimizada: tarjeta compacta con preview del que habla. */
.call-overlay.call-min {
    width: 300px;
}

.call-window {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 18px 48px rgba(0, 0, 0, .45);
    overflow: hidden;
    width: 100%;
}
/* Maximizada: la ventana llena el navegador completo (sin borde ni redondeo). */
.call-overlay.call-max .call-window {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    border: none;
    box-shadow: none;
}

.call-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
}
.call-title {
    display: inline-flex; align-items: center; gap: 8px;
    font-weight: 600; color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.call-title i { color: var(--primary); }
.call-status { font-size: .8rem; color: var(--text-muted); }
.call-status-live { color: var(--success); animation: callBlink 1.2s ease-in-out infinite; }
@keyframes callBlink { 50% { opacity: .35; } }
.call-header-spacer { flex: 1; }

.call-hbtn {
    width: 30px; height: 30px;
    display: inline-grid; place-items: center;
    background: transparent; border: none; border-radius: var(--radius);
    color: var(--text-muted); cursor: pointer; transition: all .15s ease;
}
.call-hbtn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ---- Escenario (spotlight) + Filmstrip, estilo Google Meet ---- */
.call-stagewrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    background: var(--bg-body);
    flex: 1;
    min-height: 240px;
    min-width: 0;
}

/* ESCENARIO: el <video> grande (pantalla o camara del destacado). */
.call-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 170px;
    background: #0c0e12;        /* letterbox oscuro estandar para el video */
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border-color);
    display: grid;
    place-items: center;
}
.call-stage-video {
    width: 100%; height: 100%;
    display: block;
    object-fit: contain;        /* cuadro COMPLETO, centrado (letterbox): no recortar la camara/pantalla */
    background: #0c0e12;
}
/* Pantalla compartida: tambien contenida COMPLETA (sin recortar) para apreciarla toda. */
.call-stage-screen .call-stage-video { object-fit: contain; }

.call-stage-bar {
    position: absolute; left: 0; right: 0; bottom: 0;
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px;
    background: linear-gradient(to top, rgba(0,0,0,.7), transparent);
}
.call-stage-bar i { color: #fff; font-size: .85rem; }
.call-stage-bar .call-name { font-size: .95rem; }

/* FILMSTRIP: fila horizontal de miniaturas clicables. */
.call-filmstrip {
    display: flex;
    gap: 8px;
    flex: none;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
    scrollbar-width: thin;
}
.call-thumb {
    position: relative;
    flex: 0 0 auto;
    width: 128px;
    aspect-ratio: 4 / 3;
    background: #0c0e12;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: transform .15s ease, outline-color .15s ease;
}
.call-thumb:hover { transform: translateY(-2px); }
/* Miniatura actualmente en el escenario: anillo azul. */
.call-thumb-on { outline: 3px solid var(--primary); outline-offset: -3px; }
/* Miniatura de pantalla: object-fit contain para no recortar. */
.call-thumb-screen .call-video { object-fit: contain; background: #0c0e12; }

/* En la ventana expandida: escenario mas alto y miniaturas mas grandes. */
.call-overlay.call-max .call-stagewrap { padding: 14px; gap: 12px; }
.call-overlay.call-max .call-thumb { width: 168px; }

/* Indicador "quien habla": anillo verde animado en la miniatura del participante activo. */
.call-thumb.call-speaking {
    outline: 3px solid var(--success);
    outline-offset: -3px;
    box-shadow: 0 0 0 1px var(--success), 0 0 14px 1px rgba(5, 150, 105, .55);
    animation: callSpeak 1.4s ease-in-out infinite;
}
@keyframes callSpeak {
    0%, 100% { box-shadow: 0 0 0 1px var(--success), 0 0 10px 0 rgba(5, 150, 105, .40); }
    50%      { box-shadow: 0 0 0 1px var(--success), 0 0 18px 3px rgba(5, 150, 105, .70); }
}

/* Cronometro de duracion en la cabecera. */
.call-timer {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: .78rem; color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}
.call-timer i { color: var(--primary); font-size: .72rem; }

.call-video {
    width: 100%; height: 100%;
    object-fit: contain;   /* cuadro COMPLETO (vertical y horizontal): no recortar la camara en los tiles */
    display: block;
    background: #0c0e12;
}
.call-video-off { display: none; }   /* sin video: mostramos avatar */

.call-avatar-wrap {
    position: absolute; inset: 0;
    display: grid; place-items: center;
    background: radial-gradient(circle at 50% 40%, rgba(255,255,255,.06), transparent 70%);
}
.call-avatar {
    width: 72px; height: 72px; border-radius: 50%;
    display: grid; place-items: center;
    font-size: 1.9rem; font-weight: 700; color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    box-shadow: 0 4px 16px rgba(0,0,0,.35);
}
.call-avatar-sm { width: 46px; height: 46px; font-size: 1.15rem; }
/* Avatar grande del ESCENARIO (cuando no hay video en el spotlight). */
.call-avatar-xl { width: 120px; height: 120px; font-size: 3rem; }
.call-avatar-img {
    position: absolute; width: 72px; height: 72px; border-radius: 50%;
    object-fit: cover; z-index: 1; box-shadow: 0 4px 16px rgba(0,0,0,.35);
}
.call-avatar-img.call-avatar-lg { width: 120px; height: 120px; }

.call-connecting {
    position: absolute; top: 8px; left: 8px;
    display: inline-flex; align-items: center; gap: 6px;
    font-size: .74rem; color: #fff;
    background: rgba(0,0,0,.5); padding: 3px 8px; border-radius: 99px;
}

.call-tile-bar {
    position: absolute; left: 0; right: 0; bottom: 0;
    display: flex; align-items: center; gap: 8px;
    padding: 5px 9px;
    background: linear-gradient(to top, rgba(0,0,0,.65), transparent);
}
.call-name {
    color: #fff; font-size: .82rem; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.call-ico-muted { color: var(--danger-light); margin-left: auto; }
.call-ico-screen { color: var(--info-light); }

/* ---- Aviso transitorio ---- */
.call-aviso {
    display: flex; align-items: center; gap: 8px;
    margin: 0 10px 8px; padding: 8px 12px;
    background: var(--warning-soft); color: var(--warning);
    border-radius: var(--radius); font-size: .82rem; cursor: pointer;
}

/* ---- Panel invitar ---- */
.call-invite {
    margin: 0 10px 8px;
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius); overflow: hidden;
}
.call-invite-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px; font-weight: 600; color: var(--text-primary);
    background: var(--bg-header); border-bottom: 1px solid var(--border-color);
}
.call-invite-list { max-height: 200px; overflow-y: auto; }
.call-invite-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 8px 12px; background: transparent; border: none;
    color: var(--text-primary); cursor: pointer; text-align: left;
}
.call-invite-item:hover { background: var(--bg-hover); }
.call-invite-item span { flex: 1; }
.call-invite-item i { color: var(--primary); }
.call-invite-empty { padding: 12px; color: var(--text-muted); font-size: .82rem; text-align: center; }

/* ---- Controles ---- */
.call-controls {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    padding: 12px;
    background: var(--bg-header);
    border-top: 1px solid var(--border-color);
}
.call-ctrl {
    width: 48px; height: 48px; border-radius: 50%;
    display: inline-grid; place-items: center;
    font-size: 1.1rem; cursor: pointer; transition: all .16s ease;
    background: var(--bg-card); color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.call-ctrl:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,.25); }
/* Deshabilitado (p.ej. compartir pantalla en movil): apagado y sin interaccion. */
.call-ctrl:disabled { opacity: .4; cursor: not-allowed; }
.call-ctrl:disabled:hover { transform: none; box-shadow: none; }
.call-ctrl-off { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.call-ctrl-on  { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.call-ctrl-hangup {
    background: linear-gradient(135deg, var(--danger), var(--danger-light));
    color: #fff; border: none; width: 56px; height: 56px;
    box-shadow: 0 4px 14px rgba(220,38,38,.4);
}
.call-ctrl-hangup:hover { color: #fff; }
.call-ctrl-sm { width: 40px; height: 40px; font-size: 1rem; }

/* ---- Vista minimizada: preview del que habla + barra compacta ---- */
.call-mini { display: flex; flex-direction: column; }

/* Preview: <video> del active speaker (o avatar si no hay camara). */
.call-mini-preview {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    background: #0c0e12;
    overflow: hidden;
}
.call-mini-vid {
    width: 100%; height: 100%;
    object-fit: contain; display: block; background: #0c0e12;   /* cuadro COMPLETO, centrado: no recortar */
}
/* Nombre del que habla (overlay inferior del preview) + cronometro. */
.call-mini-name {
    position: absolute; left: 0; right: 0; bottom: 0;
    display: flex; align-items: center; gap: 6px;
    padding: 5px 9px;
    background: linear-gradient(to top, rgba(0,0,0,.72), transparent);
}
.call-mini-live {
    color: var(--success); font-size: .78rem;
    animation: callBlink 1.2s ease-in-out infinite;
}
.call-mini-timer {
    margin-left: auto; color: #fff; font-size: .72rem;
    font-variant-numeric: tabular-nums;
}

.call-mini-bar {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; background: var(--bg-header);
    border-top: 1px solid var(--border-color);
}
.call-mini-info {
    flex: 1; display: inline-flex; align-items: center; gap: 8px; min-width: 0;
    color: var(--text-primary); font-weight: 500; font-size: .86rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.call-mini-info i { color: var(--primary); }
/* Boton "restaurar" de la vista minimizada: mismo look neutro que los .call-hbtn. */
.call-mini-restore { background: var(--bg-card); color: var(--text-muted); }
.call-mini-restore:hover { color: var(--text-primary); }

/* ===================== TOAST GLOBAL DE LLAMADAS ===================== */
/* Aviso tematizado independiente de la ventana (errores pre-llamada, ocupado, cámara). */
.call-toast {
    position: fixed;
    right: 24px; bottom: 24px;
    z-index: 4500;
    max-width: min(360px, calc(100vw - 48px));
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--warning);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .38);
    color: var(--text-primary);
    cursor: pointer;
    animation: callToastIn .22s cubic-bezier(.2,.8,.2,1);
}
@keyframes callToastIn { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.call-toast-ico { color: var(--warning); font-size: 1.05rem; flex: none; }
.call-toast-msg { flex: 1; font-size: .84rem; line-height: 1.3; }
.call-toast-close { color: var(--text-muted); font-size: .82rem; flex: none; }
.call-toast:hover .call-toast-close { color: var(--text-primary); }

/* ===================== PANEL DE HISTORIAL DE LLAMADAS ===================== */
.call-hist-empty { padding: 24px 12px; text-align: center; color: var(--text-muted); }
.call-hist-empty i { display: block; font-size: 1.6rem; margin-bottom: 8px; opacity: .7; }

.call-hist-item {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 10px 14px; background: transparent; border: none;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary); cursor: pointer; text-align: left;
    transition: background .14s ease;
}
.call-hist-item:hover { background: var(--bg-hover); }
.call-hist-dir {
    width: 34px; height: 34px; border-radius: 50%; flex: none;
    display: grid; place-items: center; font-size: .9rem;
    background: var(--bg-body); border: 1px solid var(--border-color);
}
.call-hist-dir.call-hist-in  { color: var(--success); }
.call-hist-dir.call-hist-out { color: var(--primary); }
.call-hist-dir.call-hist-missed { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.call-hist-info { flex: 1; min-width: 0; }
.call-hist-top { display: flex; align-items: center; gap: 6px; }
.call-hist-name {
    font-weight: 500; font-size: .9rem; flex: 1;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.call-hist-name.call-hist-missed-txt { color: var(--danger); }
.call-hist-time { font-size: .72rem; color: var(--text-muted); flex: none; }
.call-hist-sub {
    display: flex; align-items: center; gap: 7px;
    font-size: .76rem; color: var(--text-muted); margin-top: 2px;
}
.call-hist-sub i { font-size: .72rem; }
.call-hist-recall { color: var(--primary); font-size: .85rem; flex: none; opacity: 0; transition: opacity .14s ease; }
.call-hist-item:hover .call-hist-recall { opacity: 1; }

/* ===================== MODAL DE LLAMADA ENTRANTE ===================== */

.call-in-backdrop {
    position: fixed; inset: 0; z-index: 4200;
    display: grid; place-items: center;
    background: rgba(10, 12, 16, .82);
    animation: callFade .18s ease;
}
@keyframes callFade { from { opacity: 0; } to { opacity: 1; } }

.call-in-modal {
    width: 340px; max-width: calc(100vw - 32px);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0,0,0,.55);
    padding: 28px 24px 24px;
    text-align: center;
    animation: callPop .22s cubic-bezier(.2,.8,.2,1);
}
@keyframes callPop { from { transform: translateY(14px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }

.call-in-avatar-wrap {
    position: relative;
    width: 96px; height: 96px;
    margin: 0 auto 16px;
    display: grid; place-items: center;
}
.call-in-avatar {
    width: 96px; height: 96px; border-radius: 50%;
    display: grid; place-items: center;
    font-size: 2.4rem; font-weight: 700; color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
}
.call-in-avatar-img {
    position: absolute; width: 96px; height: 96px; border-radius: 50%;
    object-fit: cover; z-index: 1;
}
/* Pulso animado alrededor del avatar (indica que esta timbrando). */
.call-in-pulse {
    position: absolute; width: 96px; height: 96px; border-radius: 50%;
    box-shadow: 0 0 0 0 var(--primary-soft);
    animation: callPulse 1.5s ease-out infinite;
}
@keyframes callPulse {
    0%   { box-shadow: 0 0 0 0 rgba(37,99,235,.45); }
    100% { box-shadow: 0 0 0 26px rgba(37,99,235,0); }
}

.call-in-name { font-size: 1.25rem; font-weight: 700; color: var(--text-primary); }
.call-in-sub {
    margin-top: 4px; color: var(--text-muted); font-size: .9rem;
    display: inline-flex; align-items: center; gap: 6px;
}
.call-in-sub i { color: var(--primary); }

.call-in-actions {
    display: flex; justify-content: center; gap: 40px;
    margin-top: 26px;
}
.call-in-btn {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    background: transparent; border: none; cursor: pointer;
    color: var(--text-secondary); font-size: .8rem; font-weight: 500;
}
.call-in-btn i {
    width: 58px; height: 58px; border-radius: 50%;
    display: grid; place-items: center; font-size: 1.35rem; color: #fff;
    transition: transform .16s ease, box-shadow .16s ease;
}
.call-in-btn:hover i { transform: translateY(-3px); }
.call-in-accept i {
    background: linear-gradient(135deg, var(--success), var(--success-light));
    box-shadow: 0 6px 18px rgba(5,150,105,.45);
    animation: callWobble 1.1s ease-in-out infinite;
}
.call-in-reject i {
    background: linear-gradient(135deg, var(--danger), var(--danger-light));
    box-shadow: 0 6px 18px rgba(220,38,38,.45);
}
@keyframes callWobble { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }

@media (prefers-reduced-motion: reduce) {
    .call-status-live, .call-in-pulse, .call-in-accept i, .call-connecting,
    .call-thumb.call-speaking, .call-toast { animation: none !important; }
}
