/**
 * WebRTC Chat Styles
 * Version: 1.0.5 - Mobile Button Fix
 * Date: June 4, 2025
 */

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f5f5f5;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Login Container */
.login-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.login-form {
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.login-form h2 {
    margin-bottom: 1.5rem;
    color: #4a6da7;
    text-align: center;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.btn {
    display: block;
    width: 100%;
    padding: 0.75rem;
    background-color: #4a6da7;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn:hover {
    background-color: #3a5a8f;
}

.btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* Chat Container */
.chat-container {
    display: none;
    height: 100vh;
    grid-template-rows: auto 1fr auto;
    grid-template-columns: 1fr 300px;
    grid-template-areas:
        "header header"
        "messages info"
        "input input";
}

/* Header */
.header {
    grid-area: header;
    background-color: #4a6da7;
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.5rem;
    margin: 0;
}

.status {
    display: flex;
    align-items: center;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.status-online {
    background-color: #4CAF50;
}

.status-offline {
    background-color: #F44336;
}

.status-connecting {
    background-color: #FFC107;
}

/* Messages */
.messages-container {
    grid-area: messages;
    padding: 1rem;
    overflow-y: auto;
    background-color: white;
    border-right: 1px solid #eee;
    display: flex;
    flex-direction: column;
}

.message {
    margin-bottom: 1rem;
    padding: 0.75rem;
    border-radius: 8px;
    max-width: 80%;
}

.message.sent {
    align-self: flex-end;
    background-color: #e3f2fd;
}

.message.received {
    align-self: flex-start;
    background-color: #f5f5f5;
}

.message.system {
    align-self: center;
    background-color: #f1f1f1;
    color: #666;
    font-style: italic;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.message.error {
    align-self: center;
    background-color: #ffebee;
    color: #d32f2f;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.message.private {
    background-color: #f3e5f5;
}

.message .sender {
    font-weight: bold;
    margin-bottom: 0.25rem;
}

.message .time {
    font-size: 0.8rem;
    color: #999;
    text-align: right;
    margin-top: 0.25rem;
}

/* Room Info */
.room-info-container {
    grid-area: info;
    padding: 1rem;
    background-color: #f9f9f9;
    border-left: 1px solid #eee;
    overflow-y: auto;
}

.room-info h2 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
    color: #4a6da7;
}

.room-info p {
    margin-bottom: 0.5rem;
}

.room-users {
    margin-top: 1rem;
}

.room-users h3 {
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.room-users ul {
    list-style: none;
}

.room-users li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
}

/* Input */
.input-container {
    grid-area: input;
    padding: 1rem;
    background-color: #f9f9f9;
    border-top: 1px solid #eee;
    display: flex;
}

.input-container input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    margin-right: 0.5rem;
}

.input-container button {
    padding: 0.75rem 1.5rem;
    background-color: #4a6da7;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.input-container button:hover {
    background-color: #3a5a8f;
}

.input-container button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* WebRTC Controls */
.webrtc-controls {
    display: none;
    margin-top: 1rem;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.webrtc-controls button {
    padding: 0.5rem 1rem;
    background-color: #4a6da7;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    flex: 1;
    min-width: 120px;
}

.webrtc-controls button:hover {
    background-color: #3a5a8f;
}

.webrtc-controls button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* Video Container */
.video-container {
    display: none;
    grid-area: messages;
    position: relative;
    background-color: #000;
    overflow: hidden;
    z-index: 10;
}

.video-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    height: 100%;
    width: 100%;
}

.local-video-container, .remote-video-container {
    position: relative;
    overflow: hidden;
}

.local-video-container {
    border-right: 1px solid #333;
}

.remote-video-container {
    border-left: 1px solid #333;
}

.video-label {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.9rem;
}

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

/* Media Controls */
.media-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 1rem;
    z-index: 20;
}

.media-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.9);
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    color: #333;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Fix for mobile button visibility */
.media-btn {
    opacity: 1 !important;
    background-color: rgba(255, 255, 255, 0.95) !important;
    border: 2px solid rgba(0, 0, 0, 0.1) !important;
}

.media-btn:hover {
    background-color: rgba(255, 255, 255, 1);
    transform: scale(1.1);
}

.media-btn.muted {
    background-color: #f44336;
    color: white;
}

.media-btn.end-call {
    background-color: #f44336;
    color: white;
}

/* Toggle Room Info Button (Mobile) */
.toggle-room-info {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #4a6da7;
    color: white;
    border: none;
    cursor: pointer;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    z-index: 100;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Mobile Styles */
@media (max-width: 768px) {
    .chat-container {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "messages"
            "input";
        height: 100vh;
        max-height: 100vh;
        overflow: hidden;
    }
    
    .room-info-container {
        position: fixed;
        top: 0;
        right: -300px;
        width: 300px;
        height: 100%;
        z-index: 200;
        transition: right 0.3s ease;
        box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
    }
    
    .room-info-container.active {
        right: 0;
    }
    
    .toggle-room-info {
        display: flex;
    }
    
    .message {
        max-width: 90%;
    }
    
    .video-wrapper {
        grid-template-columns: 1fr;
        grid-template-rows: 30% 70%;
    }
    
    .local-video-container {
        border-right: none;
        border-bottom: 1px solid #333;
    }
    
    .remote-video-container {
        border-left: none;
        border-top: 1px solid #333;
    }
    
    /* Ensure media buttons are visible on mobile */
    .media-controls {
        bottom: 10px;
    }
    
    .media-btn {
        width: 60px;
        height: 60px;
        font-size: 1.8rem;
        opacity: 1 !important;
        background-color: rgba(255, 255, 255, 0.95) !important;
        border: 2px solid rgba(0, 0, 0, 0.1) !important;
    }
    
    /* Ensure WebRTC controls are visible */
    .webrtc-controls {
        display: flex;
        position: fixed;
        bottom: 80px;
        right: 20px;
        flex-direction: column;
        z-index: 100;
    }
    
    .webrtc-controls button {
        width: 60px;
        height: 60px;
        border-radius: 50%;
        padding: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 1.5rem;
        min-width: unset;
        margin-bottom: 10px;
        opacity: 1 !important;
        background-color: rgba(74, 109, 167, 0.95) !important;
        border: 2px solid rgba(255, 255, 255, 0.2) !important;
    }
}

/* Small Mobile Devices */
@media (max-width: 480px) {
    .header h1 {
        font-size: 1.2rem;
    }
    
    .media-btn {
        width: 55px;
        height: 55px;
        font-size: 1.6rem;
    }
    
    .webrtc-controls button {
        width: 55px;
        height: 55px;
        font-size: 1.4rem;
    }
    
    .message {
        max-width: 95%;
    }
    
    .input-container {
        padding: 0.75rem;
    }
    
    .input-container input {
        padding: 0.6rem;
    }
    
    .input-container button {
        padding: 0.6rem 1.2rem;
    }
}
