/* Base Styles */
:root {
    --bg-primary: #202124;
    --bg-secondary: #2e2f32;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --accent-color: #8ab4f8;
    --error-color: #ff4444;
    --success-color: #00c853;
    --control-bg: #3c4043;
    --hover-bg: #484a4d;
    --control-bg-hover: #43464c;
    --border-color: rgba(255, 255, 255, 0.1);
}

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

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Google Sans', sans-serif;
    min-height: 100vh;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: var(--bg-primary);
}

.header {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

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

/* Room Controls Styling */
.room-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.control-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-radius: 4px;
    background-color: var(--control-bg);
    color: var(--text-primary);
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.control-button:hover:not(:disabled) {
    background-color: var(--control-bg-hover);
}

.control-button.red {
    background-color: #ea4335;
    color: white;
}

.control-button.red:hover:not(:disabled) {
    background-color: #dc3626;
}

.control-button .material-icons {
    font-size: 1.2rem;
}

.join-room {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.join-room input {
    padding: 0.6rem 1rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background-color: var(--control-bg);
    color: var(--text-primary);
    font-size: 0.9rem;
    width: 200px;
}

.room-id {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: var(--bg-secondary);
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
}

/* Video Grid Styling */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    padding: 1rem;
    height: calc(100vh - 160px);
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
}

.main-video {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--bg-secondary);
}

.main-video video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background-color: var(--bg-secondary);
}

.pip-video {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    width: 240px;
    height: 135px;
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--bg-secondary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

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

.video-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.5rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    color: white;
}

.main-content {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-primary);
}

/* Media Controls Bar */
.controls-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-primary);
    border-top: 1px solid var(--border-color);
}

.media-controls {
    display: flex;
    gap: 1rem;
    padding: 0.5rem;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Chat Panel */
.chat-panel {
    width: 320px;
    background-color: var(--bg-secondary);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 80px;
    z-index: 100;
}

.chat-panel.open {
    transform: translateX(0);
}

.chat-header {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-primary);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.chat-message {
    max-width: 85%;
    word-break: break-word;
    animation: messageAppear 0.3s ease;
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-content {
    padding: 0.8rem 1rem;
    border-radius: 1.2rem;
    position: relative;
}

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

.chat-message.sent .message-content {
    background-color: var(--accent-color);
    color: white;
    border-bottom-right-radius: 0.4rem;
}

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

.chat-message.received .message-content {
    background-color: var(--control-bg);
    color: var(--text-primary);
    border-bottom-left-radius: 0.4rem;
}

.message-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    margin-top: 0.4rem;
    opacity: 0.8;
}

.message-sender {
    font-weight: 500;
}

.message-time {
    margin-left: 0.5rem;
}

.chat-input-area {
    padding: 1rem;
    display: flex;
    gap: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background-color: var(--bg-primary);
    position: relative;
    bottom: 0;
    left: 0;
    right: 0;
    min-height: 64px;
}

.chat-input-area input {
    flex: 1;
    padding: 0.8rem 1rem;
    border-radius: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background-color: var(--control-bg);
    color: var(--text-primary);
    font-size: 0.9rem;
    min-height: 40px;
}

.chat-input-area button {
    padding: 0.5rem 1rem;
    border-radius: 1.5rem;
    background-color: var(--accent-color);
    color: white;
    min-width: 40px;
    min-height: 40px;
}

/* File sharing styles */
.file-upload-area {
    display: flex;
    align-items: center;
    margin-right: 10px;
}

#createPdf {
    margin-left: 5px;
    background-color: #8ab4f8;
    color: #202124;
}

#createPdf:disabled {
    background-color: #3c4043;
    color: #9aa0a6;
}

.file-upload-area input[type="file"] {
    display: none;
}

.shared-image {
    border-radius: 8px;
    margin: 5px 0;
    max-width: 200px;
    cursor: pointer;
    transition: transform 0.2s;
}

.shared-image:hover {
    transform: scale(1.05);
}

.document-preview {
    display: flex;
    align-items: center;
    background: #f5f5f5;
    padding: 10px;
    border-radius: 8px;
    margin: 5px 0;
}

.document-preview .material-icons {
    margin-right: 10px;
    color: #2196F3;
}

.document-preview .document-name {
    flex-grow: 1;
    margin-right: 10px;
}

.document-preview .edit-doc-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 5px;
}

.document-preview .edit-doc-btn:hover {
    color: #2196F3;
}

.document-editor {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
}

.editor-header button {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 5px;
}

.editor-header button:hover {
    color: #2196F3;
}

#documentContent {
    flex-grow: 1;
    width: 100%;
    padding: 10px;
    border: none;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
}

#documentContent:focus {
    outline: none;
}

/* PDF Editor Styles */
.pdf-editor {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.pdf-preview {
    background: #f8f9fa;
}

.editor-tools {
    display: flex;
    gap: 10px;
}

.editor-tools button {
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    color: #666;
    border-radius: 4px;
}

.editor-tools button:hover {
    background: #f0f0f0;
    color: #2196F3;
}

#pdfContainer {
    flex-grow: 1;
    overflow: auto;
    position: relative;
}

#annotationLayer {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

.pdf-annotation {
    position: absolute;
    z-index: 1;
}

.pdf-annotation.highlight {
    background: rgba(255, 255, 0, 0.3);
    padding: 2px;
}

.pdf-annotation.comment {
    background: #2196F3;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}

/* PDF Container Styles */
.pdf-container {
    position: relative;
    margin: 10px 0;
    background: #f5f5f5;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.pdf-toolbar {
    display: flex;
    gap: 10px;
    padding: 10px;
    background: #fff;
    border-bottom: 1px solid #ddd;
}

.tool-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.tool-btn:hover {
    background: #e0e0e0;
}

.tool-btn.active {
    background: #2196F3;
    color: white;
}

.tool-btn .material-icons {
    font-size: 20px;
}

.pdf-canvas {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
    cursor: crosshair;
}

.annotation-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.annotation-layer .highlight {
    position: absolute;
    background: rgba(255, 255, 0, 0.3);
    pointer-events: none;
}

.annotation-layer .comment {
    position: absolute;
    width: 24px;
    height: 24px;
    background: #2196F3;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    pointer-events: auto;
}

.annotation-layer .comment:hover {
    transform: scale(1.1);
}

.comment-popup {
    position: absolute;
    background: white;
    padding: 10px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-width: 200px;
}

.comment-popup .author {
    font-weight: bold;
    margin-bottom: 5px;
}

.comment-popup .timestamp {
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
}

.comment-popup .content {
    white-space: pre-wrap;
    word-break: break-word;
}

/* PDF Loading Styles */
.pdf-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #f5f5f5;
    border-radius: 8px;
    gap: 10px;
}

.pdf-loading .material-icons {
    font-size: 48px;
    color: #2196F3;
}

.pdf-loading span:last-child {
    color: #666;
    font-size: 14px;
}

/* Error Message Styles */
.error-message {
    padding: 10px;
    background: #ffebee;
    color: #c62828;
    border-radius: 4px;
    margin: 10px 0;
    font-size: 14px;
    text-align: center;
}

/* Collaborative Editor Styles */
.editor-container {
    position: relative;
    flex-grow: 1;
    display: flex;
}

.collaborative-editor {
    width: 100%;
    height: 100%;
    padding: 15px;
    font-size: 14px;
    line-height: 1.6;
    border: none;
    resize: none;
    background: #fff;
}

.collaborators-cursors {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.collaborator-cursor {
    position: absolute;
    width: 2px;
    height: 20px;
    background: #2196F3;
    animation: blink 1s infinite;
}

.collaboration-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #666;
}

.collaborator-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background: #e3f2fd;
    border-radius: 12px;
    font-size: 12px;
    color: #2196F3;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .video-grid {
        grid-template-columns: 1fr;
        height: calc(100vh - 140px);
    }

    .pip-video {
        width: 120px;
        height: 68px;
    }

    .room-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .join-room {
        flex-direction: column;
    }

    .join-room input {
        width: 100%;
    }

    .header {
        padding: 1rem;
    }

    .chat-panel {
        width: 100%;
        max-width: 100%;
        bottom: 60px;
    }

    .chat-input-area {
        padding: 0.8rem;
        min-height: 56px;
    }

    .chat-input-area input {
        padding: 0.6rem 1rem;
    }

    .media-controls {
        padding: 0.5rem;
        gap: 0.25rem;
    }

    .control-button {
        width: 36px;
        height: 36px;
    }
}

/* File sharing styles */
.file-sharing-controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    gap: 10px;
}

.pdf-viewer-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 80%;
    background: white;
    z-index: 1000;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

.pdf-header {
    padding: 10px;
    background: #f5f5f5;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#pdfRenderer {
    flex: 1;
    overflow: auto;
    padding: 20px;
    background: #f9f9f9;
}

#pdfFileName {
    font-weight: 500;
    color: #333;
}

.pdf-viewer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: none;
    flex-direction: column;
}

.pdf-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #333;
    color: white;
}

.pdf-content {
    flex: 1;
    overflow: auto;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

#pdfRenderer {
    width: 100%;
    height: 100%;
    background: white;
}

#pdfFileName {
    font-size: 16px;
    margin-right: 10px;
}

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

.modal-content {
    background-color: #333;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: flex-end;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #9aa0a6;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background-color: #202124;
    color: #e8eaed;
    font-family: inherit;
}

.form-group textarea {
    resize: vertical;
    min-height: 150px;
}

.control-button.primary {
    background-color: #8ab4f8;
    color: #000;
    padding: 10px 20px;
    border-radius: 4px;
    font-weight: 500;
}
