/**
 * Enhanced WebRTC Styles
 * Styles for captions, bandwidth monitoring, screen sharing, group calls
 */

/* ===== Call Quality Indicator ===== */
#quality-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #ccc;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    z-index: 100;
    transition: background-color 0.3s ease;
}

#quality-indicator.excellent {
    background-color: #00ff00;
}

#quality-indicator.good {
    background-color: #90ee90;
}

#quality-indicator.fair {
    background-color: #ffa500;
}

#quality-indicator.poor {
    background-color: #ff0000;
    animation: pulse-red 1s infinite;
}

@keyframes pulse-red {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== Stats Display ===== */
#stats-display {
    position: absolute;
    top: 40px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 12px;
    z-index: 99;
    min-width: 180px;
    backdrop-filter: blur(10px);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.stat-item:last-child {
    margin-bottom: 0;
}

.stat-label {
    color: #aaa;
    margin-right: 10px;
}

.stat-value {
    font-weight: bold;
}

.stat-value.excellent {
    color: #00ff00;
}

.stat-value.good {
    color: #90ee90;
}

.stat-value.fair {
    color: #ffa500;
}

.stat-value.poor {
    color: #ff0000;
}

/* ===== Real-time Captions ===== */
.captions-overlay {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    max-width: 80%;
    text-align: center;
    font-size: 16px;
    line-height: 1.4;
    z-index: 98;
    pointer-events: none;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.4);
}

.caption-text {
    font-family: 'Arial', sans-serif;
    font-weight: 500;
}

.caption-text.interim {
    opacity: 0.7;
    font-style: italic;
}

/* Caption toggle button */
.captions-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid #fff;
    color: #fff;
    padding: 10px 15px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0 5px;
}

.captions-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.captions-btn.active {
    background: #007bff;
    border-color: #007bff;
}

.captions-btn svg {
    width: 20px;
    height: 20px;
}

/* ===== Screen Sharing Indicator ===== */
.screen-share-indicator {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #ff5722;
    color: #fff;
    padding: 8px 15px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: pulse-screen-share 1.5s infinite;
}

@keyframes pulse-screen-share {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.screen-share-indicator::before {
    content: '●';
    font-size: 20px;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50%, 100% { opacity: 1; }
    25%, 75% { opacity: 0.3; }
}

/* Screen share button */
.screen-share-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid #fff;
    color: #fff;
    padding: 10px 15px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0 5px;
}

.screen-share-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.screen-share-btn.active {
    background: #ff5722;
    border-color: #ff5722;
}

/* ===== Group Call Grid ===== */
#group-participants {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
    padding: 15px;
    height: 100%;
    overflow-y: auto;
}

.participant-video {
    position: relative;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

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

.participant-name {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10;
}

.participant-video.speaking {
    border: 3px solid #00ff00;
}

.participant-video.muted .participant-name::after {
    content: ' 🔇';
}

/* ===== Group Call Controls ===== */
.group-call-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    background: rgba(0, 0, 0, 0.7);
    padding: 15px 20px;
    border-radius: 50px;
    backdrop-filter: blur(10px);
    z-index: 100;
}

.group-call-controls button {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid #fff;
    color: #fff;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.group-call-controls button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.group-call-controls button.active {
    background: #007bff;
    border-color: #007bff;
}

.group-call-controls button.danger {
    background: #dc3545;
    border-color: #dc3545;
}

.group-call-controls button.danger:hover {
    background: #c82333;
}

/* ===== Recording Indicator ===== */
.recording-indicator {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: #dc3545;
    color: #fff;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    z-index: 101;
    display: flex;
    align-items: center;
    gap: 10px;
}

.recording-indicator::before {
    content: '●';
    font-size: 16px;
    color: #fff;
    animation: blink 1s infinite;
}

/* ===== Call Modal Enhancements ===== */
.call-modal-content {
    position: relative;
}

.video-container {
    position: relative;
    background: #000;
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

#remote-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#local-video {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 200px;
    height: 150px;
    object-fit: cover;
    border-radius: 10px;
    border: 3px solid #fff;
    box-shadow: 0 4px 8px rgba(0,0,0,0.5);
    z-index: 10;
}

/* ===== Call Controls Toolbar ===== */
.call-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    background: rgba(0, 0, 0, 0.8);
    padding: 15px 25px;
    border-radius: 50px;
    backdrop-filter: blur(10px);
    z-index: 100;
}

.call-controls button {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid #fff;
    color: #fff;
    width: 55px;
    height: 55px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.call-controls button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.call-controls button.active {
    background: #007bff;
    border-color: #007bff;
}

.call-controls button.muted {
    background: #ffc107;
    border-color: #ffc107;
}

.call-controls .end-call-btn {
    background: #dc3545;
    border-color: #dc3545;
    width: 65px;
    height: 65px;
}

.call-controls .end-call-btn:hover {
    background: #c82333;
    transform: scale(1.05);
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    #group-participants {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 10px;
    }

    #local-video {
        width: 120px;
        height: 90px;
        bottom: 80px;
        right: 10px;
    }

    #stats-display {
        font-size: 10px;
        padding: 8px 10px;
        min-width: 140px;
    }

    .captions-overlay {
        font-size: 14px;
        padding: 10px 15px;
        bottom: 80px;
    }

    .call-controls,
    .group-call-controls {
        gap: 8px;
        padding: 12px 15px;
    }

    .call-controls button,
    .group-call-controls button {
        width: 45px;
        height: 45px;
        font-size: 16px;
    }

    .call-controls .end-call-btn {
        width: 55px;
        height: 55px;
    }
}

/* ===== Notification Styles ===== */
.webrtc-notification {
    position: fixed;
    top: 80px;
    right: 20px;
    background: #fff;
    border-radius: 8px;
    padding: 15px 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 1000;
    animation: slideIn 0.3s ease;
    max-width: 300px;
}

.webrtc-notification.success {
    border-left: 4px solid #28a745;
}

.webrtc-notification.error {
    border-left: 4px solid #dc3545;
}

.webrtc-notification.warning {
    border-left: 4px solid #ffc107;
}

.webrtc-notification.info {
    border-left: 4px solid #17a2b8;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ===== Loading Indicator ===== */
.webrtc-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 50;
}

.webrtc-loading::after {
    content: '';
    display: block;
    width: 60px;
    height: 60px;
    border: 6px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
