/* ===== ОБЩИЕ СТИЛИ ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

#app {
    width: 100%;
    max-width: 1400px;
    height: 90vh;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#header {
    background: #f8f9fa;
    padding: 15px 20px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

#connection-status {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 14px;
}

.connected { background: #d4edda; color: #155724; }
.disconnected { background: #f8d7da; color: #721c24; }

#main-container {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* ===== САЙДБАР ===== */
#sidebar {
    width: 260px;
    background: #2c3e50;
    color: white;
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
}

#sidebar h3 {
    margin-bottom: 15px;
    color: #ecf0f1;
}

#user-list, #room-list {
    list-style: none;
    margin-bottom: 20px;
}

#user-list li, #room-list li {
    padding: 8px 10px;
    margin: 5px 0;
    background: #34495e;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
    font-size: 14px;
    word-break: break-word;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#user-list li:hover, #room-list li:hover {
    background: #3d566e;
}

#user-list li.online {
    border-left: 4px solid #2ecc71;
}

.call-btn {
    background: #27ae60;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}

.call-btn:hover {
    background: #2ecc71;
}

.room-actions {
    display: flex;
    margin-top: 10px;
    gap: 5px;
}

.btn-sm {
    padding: 5px 8px;
    font-size: 12px;
    border-radius: 4px;
    border: none;
    background: #27ae60;
    color: white;
    cursor: pointer;
    transition: 0.2s;
}

.btn-sm.danger {
    background: #e74c3c;
}

.btn-sm:hover {
    opacity: 0.9;
}

/* ===== ОСНОВНОЙ КОНТЕНТ ===== */
#content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    min-width: 0;
    padding: 20px;
    overflow-y: auto;
}

/* Стили для звонков */
#videos {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.video-container {
    position: relative;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 16/9;
    display: flex;
    justify-content: center;
    align-items: center;
}

.avatar-placeholder {
    text-align: center;
    color: white;
    font-size: 48px;
}

.avatar-placeholder .name {
    font-size: 18px;
    margin-top: 10px;
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.video-label {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0,0,0,0.5);
    color: white;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
}

#controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    padding: 20px;
}

.control-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: #f8f9fa;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.3s;
}

.control-btn:hover {
    background: #e9ecef;
    transform: scale(1.1);
}

.control-btn.active {
    background: #28a745;
    color: white;
}

.control-btn.danger {
    background: #dc3545;
    color: white;
}

#audio-debug {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    font-size: 14px;
}

.stats-item {
    display: flex;
    justify-content: space-between;
    margin: 5px 0;
    padding: 5px;
    background: white;
    border-radius: 5px;
}

.stats-label {
    color: #6c757d;
}

.stats-value {
    font-weight: bold;
}

.good { color: #28a745; }
.warning { color: #ffc107; }
.bad { color: #dc3545; }

/* Стили для чата */
#chat-header {
    padding: 0 0 15px 0;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

#room-title {
    font-weight: bold;
    font-size: 18px;
}

#room-info {
    font-size: 14px;
    color: #6c757d;
}

#messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    display: flex;
    flex-direction: column-reverse;
    background: #fafbfc;
}

#messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    max-width: 70%;
    padding: 10px 15px;
    border-radius: 18px;
    line-height: 1.4;
    word-wrap: break-word;
}

.message.outgoing {
    align-self: flex-end;
    background: #dcf8c6;
    border-bottom-right-radius: 4px;
}

.message.incoming {
    align-self: flex-start;
    background: white;
    border: 1px solid #e9edef;
    border-bottom-left-radius: 4px;
}

.message .meta {
    font-size: 12px;
    color: #667781;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
}

.message .reply-indicator {
    font-size: 12px;
    color: #25d366;
    margin-bottom: 5px;
    padding-left: 10px;
    border-left: 3px solid #25d366;
    cursor: pointer;
}

.loader {
    text-align: center;
    padding: 10px;
    color: #6c757d;
    font-size: 14px;
}

#input-area {
    padding: 15px 0 0 0;
    background: #ffffff;
    border-top: 1px solid #dee2e6;
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-shrink: 0;
}

#reply-bar {
    padding: 5px 15px;
    background: #fff3cd;
    border-top: 1px solid #ffeeba;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

#message-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 24px;
    resize: none;
    max-height: 100px;
    font-family: inherit;
    font-size: 14px;
    outline: none;
}

#send-btn {
    background: #2c3e50;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

#send-btn:hover {
    background: #1a252f;
}

/* Модальное окно */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    width: 400px;
}

.modal-content h3 {
    margin-bottom: 20px;
}

.modal-content input, .modal-content select {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.hidden {
    display: none !important;
}