/* ==========================================================
 * COMUNIK CALLS - Modal CSS (audio/video calls)
 * ==========================================================
 * Style coherent avec le reste de l'app : border-radius 12px,
 * compatibilite dark mode, boutons accessibles.
 */

/* Boutons d'appel : on s'appuie sur la classe native .sb-btn-icon de SB
   pour hériter de la taille / padding / hover. On style juste le SVG interne
   pour qu'il matche les glyphes de la font icon native (~22-24px). */
/* Reproduit l'alignement des icônes SB natives :
   .sb-btn-icon est inline-block 33×33 avec un <i> à line-height 40 / 35.
   Pour matcher visuellement, on positionne le SVG en absolute centré
   verticalement, comme le ferait un glyphe icon-font. */
.sb-board .sb-conversation > .sb-top .sb-call-btn-toolbar {
    position: relative;
}
.sb-board .sb-conversation > .sb-top .sb-call-btn-toolbar svg {
    width: 19px;
    height: 19px;
    pointer-events: none;
    color: inherit;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
/* État désactivé : canal non-web (Messenger/WA/IG/Email/SMS) */
.sb-board .sb-conversation > .sb-top .sb-call-btn-toolbar.sb-call-btn-disabled {
    opacity: 0.35 !important;
    cursor: not-allowed !important;
    pointer-events: auto !important;
}
.sb-board .sb-conversation > .sb-top .sb-call-btn-toolbar.sb-call-btn-disabled:hover {
    color: #94a3b8 !important;
    background: transparent !important;
}

/* Modal */
.sb-call-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 20, 30, 0.78);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    font-family: inherit;
}
.sb-call-modal .sb-call-box {
    width: 92%;
    max-width: 520px;
    background: #1f2630;
    color: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    position: relative;
}
.sb-call-modal.sb-call-video .sb-call-box {
    max-width: 720px;
}

.sb-call-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(135deg, #2d8cff 0%, #1d6fd6 100%);
}
.sb-call-peer-img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    background: #ffffff20;
    flex-shrink: 0;
}
.sb-call-peer-meta {
    flex: 1;
    min-width: 0;
}
.sb-call-peer-name {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sb-call-status {
    font-size: 13px;
    opacity: 0.85;
    margin-top: 2px;
}
.sb-call-mode {
    display: inline-block;
    margin-top: 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 2px 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.18);
}
.sb-call-timer {
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    opacity: 0.9;
    min-width: 50px;
    text-align: right;
}

.sb-call-video-wrap {
    position: relative;
    background: #0e1217;
    aspect-ratio: 16/9;
    overflow: hidden;
}
.sb-call-modal.sb-call-audio .sb-call-video-wrap {
    aspect-ratio: auto;
    height: 0;
    padding: 0;
    border: 0;
}
.sb-call-modal.sb-call-audio #sb-call-remote-video,
.sb-call-modal.sb-call-audio #sb-call-local-video {
    display: none;
}
#sb-call-remote-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}
#sb-call-local-video {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 22%;
    min-width: 100px;
    max-width: 160px;
    aspect-ratio: 4/3;
    border-radius: 8px;
    object-fit: cover;
    background: #2a2f37;
    border: 2px solid rgba(255, 255, 255, 0.4);
    transform: scaleX(-1);
}

.sb-call-actions {
    display: flex;
    gap: 10px;
    padding: 16px;
    justify-content: center;
    background: #232b36;
}
.sb-call-btn {
    appearance: none;
    border: none;
    cursor: pointer;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: #3a4452;
    transition: background 0.15s, transform 0.05s;
    min-width: 110px;
}
.sb-call-btn:hover { background: #485363; }
.sb-call-btn:active { transform: scale(0.97); }
.sb-call-btn-accept {
    background: #22c55e;
}
.sb-call-btn-accept:hover { background: #16a34a; }
.sb-call-btn-end {
    background: #ef4444;
}
.sb-call-btn-end:hover { background: #dc2626; }
.sb-call-btn.sb-active {
    background: #f59e0b;
}

/* Toast simple */
.sb-call-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 20, 30, 0.92);
    color: #fff;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 14px;
    z-index: 1000000;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* Dark mode (deja sombre par defaut, juste plus sombre si dark) */
.sb-dark-mode .sb-call-modal,
[data-sb-dark="true"] .sb-call-modal {
    background: rgba(0, 0, 0, 0.85);
}
.sb-dark-mode .sb-call-box,
[data-sb-dark="true"] .sb-call-box {
    background: #14181f;
}

/* Responsive */
@media (max-width: 600px) {
    .sb-call-modal .sb-call-box,
    .sb-call-modal.sb-call-video .sb-call-box {
        width: 100%;
        height: 100%;
        max-width: none;
        border-radius: 0;
    }
    .sb-call-video-wrap {
        flex: 1;
        aspect-ratio: auto;
        height: auto;
    }
    .sb-call-btn {
        min-width: 90px;
        padding: 10px 14px;
    }
}

/* Indicator pour bouton actif (mute/camera off) */
.sb-call-btn.sb-active::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fff;
    margin-right: 6px;
    vertical-align: middle;
}

/* ==========================================================
 * REC INDICATOR (pulse rouge pendant l'enregistrement)
 * ========================================================== */
.sb-call-rec-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    padding: 4px 10px;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.sb-call-rec-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    animation: sb-call-rec-pulse 1.4s ease-out infinite;
}
@keyframes sb-call-rec-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); transform: scale(1); }
    70%  { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); transform: scale(1.05); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); transform: scale(1); }
}

/* ==========================================================
 * CALL HISTORY (panel customer 360 / admin)
 * ========================================================== */
.sb-call-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}
.sb-call-history-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    background: #fafafa;
    font-size: 13px;
}
.sb-dark-mode .sb-call-history-item,
[data-sb-dark="true"] .sb-call-history-item {
    background: #1d2530;
    border-color: rgba(255, 255, 255, 0.08);
    color: #e5e7eb;
}
.sb-call-history-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    color: #6b7280;
    font-size: 12px;
}
.sb-call-history-mode {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    background: #e0e7ff;
    color: #4338ca;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}
.sb-call-history-status {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    background: #dcfce7;
    color: #166534;
}
.sb-call-history-status.sb-status-ended { background: #dcfce7; color: #166534; }
.sb-call-history-status.sb-status-active { background: #fef3c7; color: #92400e; }
.sb-call-history-status.sb-status-reject,
.sb-call-history-status.sb-status-timeout,
.sb-call-history-status.sb-status-cancel,
.sb-call-history-status.sb-status-busy { background: #fee2e2; color: #991b1b; }
.sb-call-history-listen-btn {
    cursor: pointer;
    align-self: flex-start;
    padding: 5px 12px;
    border-radius: 6px;
    background: #2d8cff;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    border: none;
}
.sb-call-history-listen-btn:hover { background: #1d6fd6; }
.sb-call-history-player {
    margin-top: 6px;
    width: 100%;
}
.sb-call-history-player audio {
    width: 100%;
    height: 36px;
    border-radius: 6px;
}
.sb-call-history-empty {
    padding: 10px 12px;
    color: #6b7280;
    font-size: 13px;
    font-style: italic;
}
