/* ============================================================
   QMS Call Overlay — call-overlay.css
   Full-screen WebRTC call UI with participant grid, controls,
   and incoming call banner.
   ============================================================ */

/* Slide-down animation for incoming call banner */
@keyframes qms-slide-down {
    from { transform: translateY(-100%); opacity: 0; }
    to   { transform: translateY(0);     opacity: 1; }
}

/* ── Backdrop ── */
.qms-call-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(15, 23, 42, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
}

/* ── Timer ── */
.qms-call-timer {
    width: 100%;
    text-align: center;
    font-family: 'JetBrains Mono', monospace, ui-monospace;
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.85);
    padding: 16px 0 8px;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

/* ── Participant Grid ── */
.qms-call-grid {
    flex: 1;
    width: 100%;
    display: grid;
    gap: 8px;
    padding: 8px 16px;
    align-items: center;
    justify-items: center;
    overflow: hidden;
}

.qms-call-grid--1 {
    grid-template-columns: 1fr;
}

.qms-call-grid--2 {
    grid-template-columns: repeat(2, 1fr);
}

.qms-call-grid--3 {
    grid-template-columns: repeat(3, 1fr);
}

/* ── Participant Tile ── */
.qms-call-participant {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #1e293b;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qms-call-participant video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.qms-call-participant__name {
    position: absolute;
    bottom: 8px;
    left: 10px;
    font-size: 0.75rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.55);
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 20px);
    pointer-events: none;
}

.qms-call-participant__muted {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.625rem;
    font-weight: 600;
    color: #fff;
    background: #ef4444;
    padding: 2px 6px;
    border-radius: 4px;
    pointer-events: none;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ── Local Preview (picture-in-picture) ── */
.qms-call-local-preview {
    position: fixed;
    top: 16px;
    left: 16px;
    width: 160px;
    height: 90px;
    border-radius: 8px;
    z-index: 10001;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: #0f172a;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.qms-call-local-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.qms-call-local-preview > span {
    position: absolute;
    bottom: 4px;
    left: 6px;
    font-size: 0.625rem;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(0, 0, 0, 0.5);
    padding: 1px 5px;
    border-radius: 3px;
    pointer-events: none;
}

/* ── Controls Bar ── */
.qms-call-controls {
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 24px 28px;
    flex-shrink: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.4), transparent);
}

/* ── Control Buttons ── */
.qms-call-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #334155;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, transform 0.1s ease;
    flex-shrink: 0;
}

.qms-call-btn:hover {
    background: #475569;
}

.qms-call-btn:active {
    transform: scale(0.93);
}

.qms-call-btn--active {
    background: #ef4444;
}

.qms-call-btn--active:hover {
    background: #dc2626;
}

.qms-call-btn--end {
    background: #ef4444;
}

.qms-call-btn--end:hover {
    background: #dc2626;
}

/* ── Incoming Call Banner ── */
.qms-call-incoming {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10001;
    background: #1e293b;
    padding: 14px 20px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    animation: qms-slide-down 0.25s ease;
}

.qms-call-incoming__info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.qms-call-incoming__info strong {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #f8fafc;
}

.qms-call-incoming__info span {
    font-size: 0.8125rem;
    color: #94a3b8;
}

.qms-call-incoming__actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-shrink: 0;
}

.qms-call-incoming__accept {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #16a34a;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, transform 0.1s ease;
}

.qms-call-incoming__accept:hover {
    background: #15803d;
}

.qms-call-incoming__accept:active {
    transform: scale(0.93);
}

.qms-call-incoming__decline {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, transform 0.1s ease;
}

.qms-call-incoming__decline:hover {
    background: #dc2626;
}

.qms-call-incoming__decline:active {
    transform: scale(0.93);
}

/* ── Add Participant Modal ── */
.qms-call-add-modal {
    position: fixed;
    inset: 0;
    z-index: 10002;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
}

.qms-call-add-panel {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.qms-call-add-panel h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #0f172a;
}

.qms-call-add-panel input[type="text"] {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.875rem;
    color: #0f172a;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.qms-call-add-panel input[type="text"]:focus {
    border-color: #0072BC;
    box-shadow: 0 0 0 3px rgba(0, 114, 188, 0.12);
}

.qms-call-add-results {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 220px;
    overflow-y: auto;
}

.qms-call-add-user {
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 0.875rem;
    color: #0f172a;
    cursor: pointer;
    transition: background 0.12s;
}

.qms-call-add-user:hover {
    background: #f1f5f9;
}

/* ── Responsive tweaks ── */
@media (max-width: 600px) {
    .qms-call-grid--2,
    .qms-call-grid--3 {
        grid-template-columns: 1fr;
    }

    .qms-call-local-preview {
        width: 100px;
        height: 56px;
    }

    .qms-call-controls {
        gap: 8px;
        padding: 12px 16px 20px;
    }

    .qms-call-btn {
        width: 42px;
        height: 42px;
    }
}
