/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #000000 0%, #4a6695 100%);
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    overflow: hidden;
}

/* This old chat-container definition is replaced by the main one below */
/* Keeping for reference but will be overridden */

.chat-header {
    background: #2c3e50;
    backdrop-filter: blur(10px);
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    border-radius: 0;
}

.chat-header h2 {
    margin-right: 20px;
}

@media (min-width: 768px) {
    .chat-header {
        background: #2c3e50;
        color: white;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 20px 20px 0 0;
        padding: 20px;
    }
}

.room-info {
    font-size: 0.9rem;
    opacity: 0.9;
    font-weight: 500;
}

.chat-header h2 {
    font-size: 1.2rem;
    font-weight: 500;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: 0.9rem;
}

.online-count {
    opacity: 0.8;
    font-size: 0.8rem;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.modal h2 {
    margin-bottom: 10px;
    color: #075e54;
}

.modal p {
    margin-bottom: 20px;
    color: #666;
}

.modal input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 20px;
    outline: none;
    transition: border-color 0.3s;
}

.modal input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.modal button {
    background: linear-gradient(135deg, #000000 0%, #465e7d 100%);
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: 12px;
    font-size: 16px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.modal button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.modal button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.chat-messages {
    flex: 1;
    padding: 24px;
    padding-bottom: 150px; /* Increased space for fixed input */
    overflow-y: auto;
    overflow-x: hidden;
    background: #fafafa;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    min-height: 0; /* Allow flex shrinking */
    max-height: calc(100vh - 140px); /* Ensure scrollable height */
}

.message {
    max-width: 75%;
    padding: 12px 18px;
    border-radius: 20px;
    word-wrap: break-word;
    position: relative;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
    background: white;
    align-self: flex-start;
}

.message.own-message {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    align-self: flex-end;
}

.message:hover .message-actions {
    opacity: 1;
}

.message-actions {
    position: absolute;
    top: -10px;
    right: 10px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.message-action-btn {
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-action-btn .material-icons {
    font-size: 14px;
}

.message-action-btn:hover {
    background: rgba(0, 0, 0, 0.9);
}

.reply-indicator {
    background: rgba(128, 140, 126, 0.1);
    border-left: 3px solid #128c7e;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    font-size: 12px;
    color: #666;
}

.reply-preview, .edit-preview {
    background: #e3f2fd;
    border: 1px solid #90caf9;
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 8px;
    font-size: 12px;
    color: #1976d2;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.edit-preview {
    background: #fff3e0;
    border-color: #ffb74d;
    color: #f57c00;
}

.reply-cancel, .edit-cancel {
    background: none;
    border: none;
    color: #1976d2;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    margin-left: 8px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.edit-cancel {
    color: #f57c00;
}

.reply-cancel:hover {
    background-color: rgba(25, 118, 210, 0.1);
}

.edit-cancel:hover {
    background-color: rgba(245, 124, 0, 0.1);
}

.message.editing .message-content {
    display: none;
}

.message.editing .edit-input {
    display: block;
}

.edit-input {
    display: none;
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    font-size: 14px;
    font-family: inherit;
    color: inherit;
}

.message.deleted {
    opacity: 0.5;
    font-style: italic;
}

.message.received {
    background: white;
    align-self: flex-start;
    border: 1px solid #e8eaed;
}

.message.sent {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    align-self: flex-end;
    margin-left: auto;
}

.message.system {
    background: #f8f9fa;
    align-self: center;
    font-style: italic;
    color: #5f6368;
    text-align: center;
    max-width: 70%;
    border-radius: 16px;
    font-size: 13px;
    padding: 8px 16px;
    border: 1px solid #e8eaed;
}

.username {
    font-weight: 600;
    color: #cbcbcb;
    font-size: 13px;
}

.chat-input {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-top: 1px solid #e0e0e0;
    min-height: 60px;
    flex-shrink: 0;
    box-sizing: border-box;
    z-index: 10;
    /* Ensure proper positioning on iOS Safari */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.chat-input .input-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

@media (min-width: 768px) {
    .chat-input {
        padding: 16px 20px;
        gap: 10px;
        min-height: 70px;
    }
}

.chat-input textarea {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #e1e5e9;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    background: white;
    font-weight: 400;
    min-width: 0;
    resize: none;
    font-family: inherit;
    line-height: 1.4;
    min-height: 36px;
    max-height: 120px;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* Internet Explorer 10+ */
    }
        
    .chat-input textarea::-webkit-scrollbar {
        display: none; /* WebKit */
}

@media (min-width: 768px) {
    .chat-input textarea {
        padding: 14px 18px;
        border-radius: 25px;
        min-height: 44px;
    }
}

.chat-input textarea:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-input button {
    background: linear-gradient(135deg, #000 0%, #4774a9 100%);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 8px 12px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .chat-input button {
        border-radius: 25px;
        padding: 10px 16px;
        min-width: 44px;
        height: 44px;
    }
}

.chat-input button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.file-upload-button, .image-upload-button, .video-call-button {
    cursor: pointer;
    font-size: 1em;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s ease;
    background: #f1f3f4;
    border: none;
    color: #5f6368;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .file-upload-button, .image-upload-button, .video-call-button {
        font-size: 1.1em;
        padding: 10px;
        width: 44px;
        height: 44px;
    }
}

.file-upload-button:hover, .image-upload-button:hover, .video-call-button:hover {
    background-color: #e8eaed;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.drop-zone {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(18, 140, 126, 0.9);
    z-index: 10;
    border: 4px dashed #fff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: white;
    font-size: 0.8em;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* Image Message Styles */
.image-message {
    max-width: 70%;
    margin: 10px 0;
    display: flex;
    flex-direction: column;
}

.image-message.received {
    align-self: flex-start;
    align-items: flex-start;
}

.image-message.sent {
    align-self: flex-end;
    align-items: flex-end;
}

.image-container {
    border-radius: 15px;
    overflow: hidden;
    background: #f0f0f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chat-image {
    max-width: 100%;
    max-height: 300px;
    width: auto;
    height: auto;
    display: block;
    cursor: pointer;
    transition: transform 0.2s;
}

.chat-image:hover {
    transform: scale(1.02);
}

.image-info {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.9);
    font-size: 0.8em;
}

.image-info .file-name {
    font-weight: 500;
    color: #333;
}

.image-info .file-size {
    color: #666;
    margin-top: 2px;
}

.drop-zone.active {
    opacity: 1;
    pointer-events: all;
}

/* File and Image Action Styles */
.image-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.image-message:hover .image-actions {
    opacity: 1;
}

.image-actions .delete-btn {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.image-actions .delete-btn:hover {
    background: #ff4444;
    color: white;
    transform: scale(1.1);
}

.image-actions .delete-btn .material-icons {
    font-size: 18px;
}

.file-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.file-actions .delete-btn {
    background: #ff4444;
    border: none;
    border-radius: 4px;
    color: white;
    padding: 6px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    transition: all 0.2s ease;
}

.file-actions .delete-btn:hover {
    background: #cc3333;
    transform: translateY(-1px);
}

.file-actions .delete-btn .material-icons {
    font-size: 16px;
}

/* User List Sidebar Styles */
.user-list-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 280px;
    height: 100vh;
    background: #2c3e50;
    border-right: 1px solid #34495e;
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

.user-list-header {
    padding: 20px;
    border-bottom: 1px solid #34495e;
    background: #34495e;
    color: white;
}

.user-list-header h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
}

.user-count {
    font-size: 12px;
    color: #bdc3c7;
}

.chat-container {
    width: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    background: white;
    border-radius: 0;
    box-shadow: none;
    border: none;
    overflow: hidden;
    position: relative;
}

.chat-container.sidebar-hidden {
    margin-left: 0;
}

/* When video is not active, remove right margin */
.chat-container.no-video {
    margin-right: 0;
}

/* Desktop styles */
@media (min-width: 768px) {
    body {
        padding: 0;
        display: block;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }
    
    .chat-container {
        width: auto !important;
        margin: 40px 420px 40px 300px !important;
        height: calc(100vh - 80px) !important;
        border-radius: 20px !important;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15) !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
        background: white;
    }
    
    .chat-container.no-video {
        margin-right: 60px !important;
    }
}

.user-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.user-item {
    display: flex;
    align-items: center;
    padding: 12px;
    margin-bottom: 8px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e1e5e9;
    transition: all 0.2s ease;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
    margin-right: 12px;
    text-transform: uppercase;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.user-info {
    flex: 1;
}

.user-name {
    font-weight: 500;
    color: #333;
    font-size: 14px;
    margin-bottom: 2px;
    margin-right: 12px;
}

.user-status {
    font-size: 12px;
    color: #666;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-right: 12px;
}

.user-connection-time {
    font-size: 11px;
    color: #999;
}

.video-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #28a745;
    margin-left: auto;
    position: relative;
}

.video-indicator.active {
    background: #dc3545;
    animation: pulse 2s infinite;
}

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

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    background: transparent;
}

/* Mobile User List Button */
.mobile-user-list-btn {
    display: none;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    padding: 8px;
    margin-right: 16px;
    color: white;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.mobile-user-list-btn:hover {
    background-color: #e8eaed;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.user-count-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #007bff;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 600;
    min-width: 16px;
    text-align: center;
}

/* Mobile User List Overlay */
.mobile-user-list-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 2000;
}

.mobile-user-list {
    position: absolute;
    left: 0;
    top: 0;
    width: 320px;
    height: 100%;
    background: white;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.mobile-user-list-overlay.active .mobile-user-list {
    transform: translateX(0);
}

.mobile-user-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e1e5e9;
    background: #f8f9fa;
}

.mobile-user-list-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.mobile-user-list-close {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}

.mobile-user-list-close:hover {
    background: #e9ecef;
    color: #333;
}

.mobile-user-list-content {
    padding: 16px;
    height: calc(100% - 80px);
    overflow-y: auto;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        /* Enhanced iOS Safari support */
        height: 100vh;
        height: 100dvh;
        min-height: -webkit-fill-available;
    }
    
    .user-list-sidebar {
        display: none !important;
    }
    
    .chat-container {
        margin-left: 0;
        margin-right: 160px; /* Account for mobile video container */
        height: 100vh;
        height: 100dvh;
        min-height: -webkit-fill-available;
    }
    
    .chat-container.no-video {
        margin-right: 0;
    }
    
    .mobile-user-list-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .mobile-user-list-overlay.active {
        display: block;
    }
    
    .chat-container {
        flex-direction: column;
    }
    
    .chat-main {
        width: 100%;
        height: 100%;
        position: relative;
    }
    
    .chat-messages {
        padding-bottom: calc(80px + env(safe-area-inset-bottom));
    }
    
    .chat-input {
        /* Enhanced mobile positioning */
        position: fixed;
        bottom: env(safe-area-inset-bottom, 0);
        left: env(safe-area-inset-left, 0);
        right: env(safe-area-inset-right, 0);
        padding: 12px 16px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
        background: #f8f9fa;
        border-top: 1px solid #e0e0e0;
        z-index: 1000;
        /* Prevent iOS Safari bounce */
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: none;
        /* Force hardware acceleration */
        will-change: transform;
        backface-visibility: hidden;
    }
}

/* Image Message Styles */
.image-message {
    max-width: 70%;
    margin: 10px 0;
    display: flex;
    flex-direction: column;
}

.image-message.received {
    align-self: flex-start;
    align-items: flex-start;
}

.image-message.sent {
    align-self: flex-end;
    align-items: flex-end;
}

.image-container {
    border-radius: 15px;
    overflow: hidden;
    background: #f0f0f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chat-image {
    max-width: 100%;
    max-height: 300px;
    width: auto;
    height: auto;
    display: block;
    cursor: pointer;
    transition: transform 0.2s;
}

.chat-image:hover {
    transform: scale(1.02);
}

.image-info {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.9);
    font-size: 0.8em;
}

.image-info .file-name {
    font-weight: 500;
    color: #333;
}

.image-info .file-size {
    color: #666;
    margin-top: 2px;
}

.file-message {
    background: #f0f0f0;
    padding: 10px 15px;
    border-radius: 15px;
    margin: 5px 0;
    max-width: 70%;
    word-break: break-all;
}

.file-message.received {
    align-self: flex-start;
}

.file-message.sent {
    background: #128c7e;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 5px;
}

.file-message .file-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-message .file-icon {
    font-size: 1.5em;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Video Chat Styles */
.video-container {
    position: fixed;
    top: 10px;
    right: 10px;
    width: 280px;
    min-height: 200px;
    max-height: 80vh;
    background: rgba(0, 0, 0, 0.95);
    border-radius: 12px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.video-container.fullscreen {
    top: 0;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
    z-index: 2000;
    display: none;
}

/* Zoom-style fullscreen modal */
.video-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 2000;
    display: none;
    backdrop-filter: blur(10px);
}

.video-modal-overlay.active {
    display: flex;
    flex-direction: column;
}

.video-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.video-modal-title {
    font-size: 16px;
    font-weight: 600;
    color: #00ff00;
}

.video-modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.video-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.video-modal-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
}

.video-modal-grid {
    flex: 1;
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    grid-auto-rows: minmax(200px, 1fr);
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.video-modal-participant {
    position: relative;
    background: #1a1a1a;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.video-modal-participant.speaking {
    border-color: #00ff00;
}

.video-modal-participant.local {
    border-color: #4CAF50;
}

.video-modal-participant video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #2a2a2a;
}

.video-modal-participant-name {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.video-modal-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.8);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.video-modal-control-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 20px;
    color: white;
}

.video-modal-control-btn.video-on {
    background: rgba(255, 255, 255, 0.1);
}

.video-modal-control-btn.video-off {
    background: #f44336;
}

.video-modal-control-btn.audio-on {
    background: rgba(255, 255, 255, 0.1);
}

.video-modal-control-btn.audio-off {
    background: #f44336;
}

.video-modal-control-btn.hangup {
    background: #f44336;
}

.video-modal-control-btn:hover {
    transform: scale(1.05);
}

@media (min-width: 768px) {
    .video-container {
        top: 20px;
        right: 20px;
        width: 320px;
        min-height: 200px;
    }
    
    .video-element {
        height: 180px;
    }
    
    .remote-video {
        height: 180px;
    }
    
    .video-modal-grid {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
        grid-auto-rows: minmax(240px, 1fr);
    }
}

.video-grid {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 5px;
    flex: 1;
    overflow: hidden;
}

.video-container.fullscreen .video-grid {
    gap: 10px;
    padding: 20px;
}

.video-element {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: 6px;
    background: #333;
}

.video-container.fullscreen .video-element {
    height: 200px;
    border-radius: 8px;
}

.remote-videos {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    overflow-y: auto;
    padding: 5px;
}

.video-container.fullscreen .remote-videos {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    grid-auto-rows: minmax(150px, auto);
    gap: 10px;
}

/* Vertical layout for all user counts - no horizontal squeezing */
.remote-videos[data-user-count="1"],
.remote-videos[data-user-count="2"],
.remote-videos[data-user-count="3"],
.remote-videos[data-user-count="4"],
.remote-videos[data-user-count="5"],
.remote-videos[data-user-count="6"] {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.remote-video-wrapper {
    position: relative;
    display: inline-block;
    margin: 5px;
}

.remote-video {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: 8px;
    background: #333;
    aspect-ratio: 16/9;
}

/* Fix button overflow on smaller screens */
@media (max-width: 480px) {
    .chat-input {
        padding: 10px 12px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
        gap: 6px;
        min-height: 56px;
        position: fixed;
        bottom: env(safe-area-inset-bottom, 0);
        left: env(safe-area-inset-left, 0);
        right: env(safe-area-inset-right, 0);
        z-index: 1001;
    }
    
    .chat-input textarea {
        padding: 8px 12px;
        font-size: 14px;
        min-height: 36px;
    }
    
    .chat-input button {
        min-width: 36px;
        height: 36px;
        font-size: 18px;
        padding: 6px;
    }
    
    .chat-messages {
        padding-bottom: calc(70px + env(safe-area-inset-bottom));
    }
}

.file-upload-button, .image-upload-button, .video-call-button {
    width: 32px;
    height: 32px;
    font-size: 0.9em;
    padding: 6px;
}

.video-controls {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 0 0 12px 12px;
    backdrop-filter: blur(10px);
}

.video-container.fullscreen .video-controls {
    gap: 12px;
    padding: 16px;
    border-radius: 0;
}

.video-control-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.video-container.fullscreen .video-control-btn {
    width: 48px;
    height: 48px;
    font-size: 20px;
}

.video-control-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.video-control-btn.hangup {
    background: linear-gradient(135deg, #ff5722 0%, #f44336 100%);
    box-shadow: 0 4px 15px rgba(244, 67, 54, 0.3);
}

.video-control-btn.hangup:hover {
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(244, 67, 54, 0.4);
}

.video-control-btn.disabled {
    background: rgba(255, 255, 255, 0.1);
    opacity: 0.5;
    cursor: not-allowed;
}

.remote-video-wrapper {
    position: relative;
}

.video-label {
    position: absolute;
    bottom: 5px;
    left: 5px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.8em;
    font-weight: 500;
}

/* Mobile-specific video styles */
@media (max-width: 768px) {
    .video-container {
        position: fixed;
        top: 10px;
        right: 10px;
        width: 140px;
        height: auto;
        max-height: 60vh;
        z-index: 1000;
        border-radius: 12px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
        backdrop-filter: blur(20px);
        background: rgba(0, 0, 0, 0.95);
    }
    
    .video-container.fullscreen {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        z-index: 1001;
    }
    
    .video-grid {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 8px;
    }
    
    .video-container.fullscreen .video-grid {
        height: 100%;
        display: grid;
        grid-template-columns: 1fr;
        grid-auto-rows: minmax(100px, auto);
        gap: 5px;
        padding: 0;
    }
    
    #localVideo {
        width: 100%;
        height: 100px;
        object-fit: cover;
        border-radius: 8px;
        background: #333;
    }
    
    .video-container.fullscreen #localVideo {
        height: auto;
        min-height: 120px;
    }
    
    .remote-videos {
        display: flex;
        flex-direction: column;
        gap: 6px;
        padding: 4px;
    }
    
    .video-container.fullscreen .remote-videos {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 8px;
    }
    
    /* Keep vertical layout for all user counts on mobile */
    .remote-videos[data-user-count="1"],
    .remote-videos[data-user-count="2"],
    .remote-videos[data-user-count="3"],
    .remote-videos[data-user-count="4"],
    .remote-videos[data-user-count="5"],
    .remote-videos[data-user-count="6"] {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }
    
    .remote-video {
        width: 100%;
        height: 100px;
        object-fit: cover;
        border-radius: 8px;
        background: #333;
        aspect-ratio: 16/9;
    }
    
    .video-container.fullscreen .remote-video {
        height: 140px;
        min-height: 120px;
    }
    
    .video-controls {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        padding: 6px;
        gap: 4px;
    }
    
    .video-control-btn {
        width: 24px;
        height: 24px;
        font-size: 0.8em;
    }
    
    /* Ensure chat container doesn't overlap with floating video */
    /* .chat-container {
        padding-right: 140px;
    } */
}
