* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #000000;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: #0a0a0a;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
    border: 1px solid #1a1a1a;
    width: 100%;
    max-width: 800px;
    overflow: hidden;
}

.header {
    background: #000000;
    color: #ffffff;
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #1a1a1a;
}

.header h1 {
    font-size: 20px;
    margin: 0;
}

.room-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.room-id-container {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #1a1a1a;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #2a2a2a;
}

.copy-btn {
    background: none;
    border: none;
    color: #ffffff;
    padding: 0;
    cursor: pointer;
    font-size: 18px;
    transition: opacity 0.2s;
    opacity: 0.7;
}

.copy-btn:hover {
    opacity: 1;
}

.leave-btn {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    color: #ffffff;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.leave-btn:hover {
    background: #2a2a2a;
    border-color: #3a3a3a;
}

.content {
    padding: 25px;
}

.lobby {
    text-align: center;
}

.lobby-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

.btn {
    padding: 15px 30px;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
}

.btn-primary {
    background: #2a2a2a;
    color: #cccccc;
}

.btn-primary:hover {
    background: #3a3a3a;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #1a1a1a;
    color: #ffffff;
    border: 1px solid #3a3a3a;
}

.btn-secondary:hover {
    background: #2a2a2a;
    border-color: #4a4a4a;
    transform: translateY(-1px);
}

.btn-danger {
    background: #1a1a1a;
    color: #ffffff;
    border: 1px solid #3a3a3a;
}

.btn-danger:hover {
    background: #2a2a2a;
}

.input-group {
    margin: 20px 0;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #888888;
}

.input-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    font-size: 16px;
    transition: all 0.2s;
    background: #000000;
    color: #ffffff;
}

.input-group input:focus {
    outline: none;
    border-color: #4a4a4a;
    background: #0a0a0a;
}

.chat-container {
    display: none;
    flex-direction: column;
}

.messages {
    height: 400px;
    overflow-y: auto;
    border: 1px solid #1a1a1a;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 15px;
    background: #000000;
}

.message {
    margin-bottom: 15px;
    padding: 10px 15px;
    border-radius: 6px;
    max-width: 70%;
    word-wrap: break-word;
}

.message-sent {
    background: #2a2a2a;
    color: #cccccc;
    margin-left: auto;
    text-align: right;
    border: 1px solid #3a3a3a;
}

.message-received {
    background: #1a1a1a;
    color: #ffffff;
    border: 1px solid #2a2a2a;
}

.message-system {
    color: #666666;
    text-align: center;
    margin: 8px 0;
    font-size: 13px;
    font-style: italic;
    max-width: 100%;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 5px;
}

.input-container {
    display: flex;
    gap: 10px;
}

.input-container input {
    flex: 1;
    padding: 12px;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    font-size: 16px;
    background: #000000;
    color: #ffffff;
}

.input-container input:focus {
    outline: none;
    border-color: #4a4a4a;
    background: #0a0a0a;
}

.send-btn {
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    color: #cccccc;
    padding: 12px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover:not(:disabled) {
    background: #3a3a3a;
    transform: translateY(-1px);
}

.send-btn:disabled {
    background: #1a1a1a;
    border-color: #2a2a2a;
    color: #4a4a4a;
    cursor: not-allowed;
    opacity: 0.5;
}

.input-container input:disabled {
    background: #0a0a0a;
    color: #4a4a4a;
    cursor: not-allowed;
    border-color: #1a1a1a;
}

.status {
    text-align: center;
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 6px;
    font-weight: 600;
    border: 1px solid;
}

.status-connecting {
    background: #0a0a0a;
    color: #888888;
    border-color: #2a2a2a;
}

.status-connected {
    background: #0a0a0a;
    color: #cccccc;
    border-color: #3a3a3a;
}

.status-disconnected {
    background: #0a0a0a;
    color: #666666;
    border-color: #2a2a2a;
}

.hidden {
    display: none;
}

/* Стили для видео-звонков */
.call-button {
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    color: #ffffff;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.call-button:hover:not(:disabled) {
    background: #3a3a3a;
    border-color: #4a4a4a;
    transform: translateY(-1px);
}

.call-button:disabled {
    background: #1a1a1a;
    border-color: #2a2a2a;
    color: #4a4a4a;
    cursor: not-allowed;
    opacity: 0.5;
}

/* Модальное окно */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-overlay.active {
    display: flex;
}

/* Окно звонка */
.call-window {
    background: #0a0a0a;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    height: 80vh;
    max-height: 600px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.9);
}

.call-header {
    background: #000000;
    padding: 15px 20px;
    border-bottom: 1px solid #2a2a2a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.call-status {
    color: #cccccc;
    font-size: 14px;
    font-weight: 600;
}

.call-status.connecting {
    color: #ff9800;
}

.call-status.active {
    color: #4caf50;
}

.call-videos {
    flex: 1;
    min-height: 0;
    position: relative;
    background: #000000;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.remote-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #1a1a1a;
}

.local-video {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 150px;
    height: 112px;
    border: 2px solid #2a2a2a;
    border-radius: 8px;
    object-fit: cover;
    background: #1a1a1a;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.local-video.hidden {
    display: none;
}

.video-placeholder {
    color: #666666;
    font-size: 18px;
    text-align: center;
}

.call-controls {
    background: #000000;
    padding: 20px;
    border-top: 1px solid #2a2a2a;
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-shrink: 0;
}

.control-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    transform: scale(1.1);
}

.control-btn.mic {
    background: #2a2a2a;
    color: #ffffff;
}

.control-btn.mic.muted {
    background: #d32f2f;
}

.control-btn.video {
    background: #2a2a2a;
    color: #ffffff;
}

.control-btn.video.disabled {
    background: #d32f2f;
}

.control-btn.end-call {
    background: #d32f2f;
    color: #ffffff;
}

.control-btn.end-call:hover {
    background: #f44336;
}

/* Окно входящего звонка */
.incoming-call-window {
    background: #0a0a0a;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    min-width: 300px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.9);
}

.incoming-call-title {
    color: #ffffff;
    font-size: 20px;
    margin-bottom: 10px;
}

.incoming-call-subtitle {
    color: #cccccc;
    font-size: 14px;
    margin-bottom: 30px;
}

.incoming-call-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.incoming-call-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
}

.incoming-call-btn.accept {
    background: #4caf50;
    color: #ffffff;
}

.incoming-call-btn.accept:hover {
    background: #45a049;
}

.incoming-call-btn.reject {
    background: #d32f2f;
    color: #ffffff;
}

.incoming-call-btn.reject:hover {
    background: #f44336;
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    .call-window {
        width: 100%;
        height: 100vh;
        max-height: none;
        border-radius: 0;
    }

    .local-video {
        width: 100px;
        height: 75px;
        bottom: 10px;
        right: 10px;
    }

    .control-btn {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }

    .call-controls {
        padding: 15px;
        gap: 10px;
    }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message {
    animation: fadeIn 0.3s ease;
}

/* Адаптация для мобильных устройств */
@media (max-width: 768px) {
    html, body {
        height: 100vh; /* Fallback */
        height: calc(var(--vh, 1vh) * 100); /* Учитывает реальную высоту */
        overflow: hidden;
        position: fixed;
        width: 100%;
    }

    body {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
    }

    .container {
        max-width: 100%;
        border-radius: 0;
        box-shadow: none;
        border: none;
        height: 100vh; /* Fallback */
        height: calc(var(--vh, 1vh) * 100); /* Учитывает реальную высоту */
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .header {
        border-radius: 0;
        padding: 12px 15px;
        flex-shrink: 0;
    }

    .header h1 {
        font-size: 18px;
    }

    .room-info {
        font-size: 12px;
    }

    .room-id-container {
        padding: 6px 10px;
    }

    .leave-btn {
        padding: 6px 12px;
        font-size: 12px;
    }

    .content {
        padding: 15px;
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        min-height: 0;
    }

    .chat-container {
        flex-direction: column;
        height: 100%;
    }

    .status {
        flex-shrink: 0;
        margin-bottom: 10px;
    }

    .messages {
        flex: 1 1 auto;
        margin-bottom: 15px;
        border-radius: 8px;
        overflow-y: auto;
        overflow-x: hidden;
        min-height: 100px;
    }

    .message {
        max-width: 85%;
    }

    .message-system {
        max-width: 100%;
    }

    .input-container {
        flex-shrink: 0;
    }

    .input-container input {
        font-size: 16px; /* Предотвращает зум на iOS */
    }

    .send-btn {
        padding: 12px 15px;
    }

    .lobby {
        display: flex;
        flex-direction: column;
        justify-content: center;
        height: 100%;
    }

    .lobby-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .btn {
        width: 100%;
        padding: 12px 20px;
    }
}

/* Дополнительная оптимизация для маленьких экранов */
@media (max-width: 480px) {
    .header h1 {
        font-size: 16px;
    }

    .room-id-container {
        font-size: 11px;
    }

    .copy-btn {
        font-size: 16px;
    }
}
