* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* ===== ГЛАВНАЯ СТРАНИЦА ===== */

.container {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 1200px;
    width: 100%;
    padding: 40px;
}

header {
    text-align: center;
    margin-bottom: 40px;
}

header h1 {
    font-size: 2.5em;
    color: #333;
    margin-bottom: 10px;
}

header p {
    font-size: 1.1em;
    color: #666;
}

/* Создание комнаты */

.create-room-section {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 40px;
}

.create-room-section h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5em;
}

#createRoomForm {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

#roomName {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s;
}

#roomName:focus {
    outline: none;
    border-color: #667eea;
}

#createMessage {
    margin-top: 15px;
    font-weight: 500;
}

.success {
    color: #28a745;
    background: #d4edda;
    padding: 10px 15px;
    border-radius: 5px;
}

.error {
    color: #dc3545;
    background: #f8d7da;
    padding: 10px 15px;
    border-radius: 5px;
}

/* Список комнат */

.rooms-section h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.rooms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.room-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 20px;
    transition: all 0.3s ease;
}

.room-card:hover {
    border-color: #667eea;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.2);
    transform: translateY(-5px);
}

.room-card h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.3em;
}

.room-code {
    color: #666;
    margin: 8px 0;
    font-size: 0.95em;
}

.room-code strong {
    color: #667eea;
    font-family: monospace;
}

.room-date {
    color: #999;
    margin-bottom: 15px;
    font-size: 0.9em;
}

.no-rooms {
    text-align: center;
    color: #999;
    padding: 40px;
    font-size: 1.1em;
}

.loading {
    text-align: center;
    color: #666;
    padding: 40px;
}

/* Кнопки */

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #28a745;
    color: white;
    width: 100%;
    margin-top: 10px;
}

.btn-secondary:hover {
    background: #218838;
}

.btn-danger {
    background: #dc3545;
    color: white;
    width: 100%;
    margin-top: 5px;
    padding: 8px 15px;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-small {
    padding: 8px 15px;
    font-size: 0.9em;
}

/* ===== СТРАНИЦА ВИДЕОЗВОНКА ===== */

.video-container {
    width: 100%;
    height: 100vh;
    background: #0a0a0a;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.video-header {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #667eea;
    flex-shrink: 0;
}

.video-header h2 {
    font-size: 1.5em;
    margin: 0;
}

.room-code {
    color: #a78bfa;
    font-family: monospace;
    font-weight: bold;
    margin-left: 10px;
}

.controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Основная область: видео + чат рядом */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: row;
    overflow: hidden;
    min-height: 0;
}

/* Видео сетка */
.video-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 10px;
    padding: 10px;
    overflow: auto;
    background: #1a1a1a;
    align-content: start;
}

.video-box {
    background: #111;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    aspect-ratio: 16 / 9;
}

.video-box video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.my-video {
    border: 3px solid #667eea;
}

.video-label {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.9em;
    margin: 0;
}

/* Чат панель */

.chat-panel {
    width: 320px;
    flex-shrink: 0;
    background: #111;
    border-left: 2px solid #667eea;
    display: flex;
    flex-direction: column;
    padding: 10px;
}

.btn-control {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-control:hover {
    background: rgba(102, 126, 234, 0.5);
    border-color: #667eea;
}

.btn-exit {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 8px;
}

.btn-exit:hover {
    background: #c82333;
}

.messages {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 5px;
}

.message {
    color: white;
    margin-bottom: 10px;
    padding: 8px;
    border-radius: 5px;
    word-wrap: break-word;
}

.message.local {
    background: rgba(102, 126, 234, 0.5);
    text-align: right;
}

.message.remote {
    background: rgba(102, 126, 234, 0.2);
}

.input-area {
    display: flex;
    gap: 5px;
}

#messageInput {
    flex: 1;
    padding: 10px;
    border: 1px solid rgba(102, 126, 234, 0.5);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 0.95em;
}

#messageInput::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

#messageInput:focus {
    outline: none;
    border-color: #667eea;
    background: rgba(255, 255, 255, 0.2);
}

#sendBtn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
}

#sendBtn:hover {
    opacity: 0.9;
}

/* Респонсив */

@media (max-width: 1024px) {
    .chat-panel { width: 260px; }
    .video-grid { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
}

@media (max-width: 768px) {
    .main-area { flex-direction: column; }
    .chat-panel {
        width: 100%;
        height: 220px;
        border-left: none;
        border-top: 2px solid #667eea;
    }
    .video-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
    .video-header { flex-wrap: wrap; }
    .controls { width: 100%; margin-top: 10px; }
    .container { padding: 20px; }
    header h1 { font-size: 1.8em; }
    .rooms-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .btn-control { width: 40px; height: 40px; font-size: 1em; }
    .video-header h2 { font-size: 1.2em; }
    .video-grid { grid-template-columns: 1fr; }
}

/* Скролл */

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}
