/**
 * Communication Room — Telegram UI Styles
 * SCF Platform Component
 * 
 * Capacitor Ready: Safe Areas + CSS Variables
 */

/* ============================================
   CAPACITOR CSS VARIABLES
   ============================================ */
:root {
    /* Safe Area Insets */
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
    
    /* Theme Colors */
    --bg-primary: #0f1e2b;
    --bg-secondary: #1e2d3b;
    --bg-tertiary: #2c3d4e;
    --text-primary: #ffffff;
    --text-secondary: #8a9aa8;
    --accent-color: #34b7f1;
    --accent-hover: #2e9de6;
    --danger-color: #ef4444;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    
    /* Spacing */
    --header-height: 56px;
    --tab-bar-height: 60px;
    --input-height: 68px;
    
    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 50%;
}

/* Capacitor/PWA specific overrides */
@supports (padding: env(safe-area-inset-top)) {
    .communication-room {
        padding-left: var(--safe-area-left);
        padding-right: var(--safe-area-right);
    }
}

/* ============================================
   RESET & BASE
   ============================================ */
.communication-room * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

.communication-room {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    overflow: hidden;
    /* Prevent pull-to-refresh on mobile */
    overscroll-behavior: none;
}

/* ============================================
   APP CONTAINER
   ============================================ */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

/* ============================================
   CONTENT AREA
   ============================================ */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
}

/* ============================================
   HEADER
   ============================================ */
.header {
    background: #1e2d3b;
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top, 12px));
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #2c3d4e;
    min-height: 56px;
    flex-shrink: 0;
    z-index: 100;
    position: relative;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* ============================================
   BUTTONS
   ============================================ */
.icon-button {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
    border-radius: 50%;
    transition: background-color 0.2s;
    user-select: none;
    flex-shrink: 0;
}

.icon-button:active {
    background-color: rgba(255, 255, 255, 0.1);
    transform: scale(0.95);
}

.chat-title {
    font-weight: 600;
    font-size: 17px;
    margin-left: 8px;
}

.chat-status {
    font-size: 14px;
    color: #8a9aa8;
    margin-left: 8px;
}

/* ============================================
   MAIN CONTENT (Scrollable)
   ============================================ */
.main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

/* ============================================
   CHATS LIST
   ============================================ */
.chats-list {
    padding-bottom: 60px;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    min-height: 72px;
    border-bottom: 1px solid #1e2d3b;
    transition: background-color 0.2s;
    cursor: pointer;
    user-select: none;
}

.chat-item:active {
    background-color: rgba(255, 255, 255, 0.05);
}

.chat-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #34b7f1, #2e9de6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    color: white;
    margin-right: 16px;
    flex-shrink: 0;
}

.chat-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.chat-name {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-last-message {
    font-size: 14px;
    color: #8a9aa8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    margin-left: 12px;
    flex-shrink: 0;
}

.chat-time {
    font-size: 12px;
    color: #8a9aa8;
}

.unread-badge {
    background: #34b7f1;
    color: white;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 12px;
    min-width: 24px;
    text-align: center;
}

/* ============================================
   TAB BAR
   ============================================ */
.tab-bar-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1e2d3b;
    border-top: 1px solid #2c3d4e;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: 100;
}

.tab-bar {
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    max-width: 100%;
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: none;
    border: none;
    color: #8a9aa8;
    font-size: 22px;
    padding: 8px 12px;
    min-width: 64px;
    min-height: 50px;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 8px;
    user-select: none;
}

.tab-item:active {
    background-color: rgba(255, 255, 255, 0.1);
    transform: scale(0.95);
}

.tab-item.active {
    color: #34b7f1;
}

.tab-label {
    font-size: 10px;
    margin-top: 4px;
    font-weight: 500;
}

/* ============================================
   CHAT WINDOW
   ============================================ */
.chat-window {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background: #0f1e2b;
    display: none;
    flex-direction: column;
    z-index: 1000;
}

.chat-header {
    background: #1e2d3b;
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top, 12px));
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #2c3d4e;
    min-height: 56px;
    flex-shrink: 0;
}

.back-button {
    background: none;
    border: none;
    color: #34b7f1;
    font-size: 20px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    flex-shrink: 0;
}

.back-button:active {
    background-color: rgba(52, 183, 241, 0.1);
}

/* Кнопки звонков в хедере чата */
.call-header-btn {
    font-size: 20px !important;
    width: 40px;
    height: 40px;
}

.chat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* ============================================
   MESSAGES
   ============================================ */
.messages-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    padding-bottom: 80px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #0f1e2b;
}

.message {
    max-width: 80%;
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 18px;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

.message-incoming {
    background: #1e2d3b;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message-outgoing {
    background: #2b5278;
    align-self: flex-end;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 4px;
    text-align: right;
}

/* ============================================
   INPUT CONTAINER
   ============================================ */
.input-container {
    background: #1e2d3b;
    padding: 12px 16px;
    border-top: 1px solid #2c3d4e;
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-shrink: 0;
}

.message-input {
    flex: 1;
    background: #2c3d4e;
    border: none;
    border-radius: 20px;
    padding: 12px 16px;
    color: white;
    font-size: 16px;
    outline: none;
    min-height: 44px;
    max-height: 120px;
    resize: none;
    font-family: inherit;
    line-height: 1.4;
    overflow-y: hidden !important;
    overflow-x: hidden !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
}

.message-input::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

.message-input:focus {
    background: #3a4d5f;
}

.send-button {
    background: #34b7f1;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: background-color 0.2s;
    flex-shrink: 0;
    margin-bottom: 4px;
}

.send-button:active {
    background: #2e9de6;
    transform: scale(0.95);
}

/* ============================================
   CONNECTION STATUS
   ============================================ */
.connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    margin-right: 6px;
    display: inline-block;
    animation: pulse 2s infinite;
}

.connection-dot.disconnected {
    background: #ef4444;
    animation: none;
}

.connection-dot.connecting {
    background: #f59e0b;
}

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

/* ============================================
   WEBRTC VIDEO MODAL
   ============================================ */
.video-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-modal.hidden {
    display: none;
}

.video-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.video-header {
    padding: 20px;
    text-align: center;
    background: rgba(0, 0, 0, 0.5);
}

.video-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.video-status {
    font-size: 14px;
    color: #8a9aa8;
}

.video-streams {
    flex: 1;
    position: relative;
    background: #000;
}

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

.local-video {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 120px;
    height: 160px;
    border-radius: 12px;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.video-controls {
    padding: 30px 20px;
    padding-bottom: max(30px, env(safe-area-inset-bottom, 30px));
    display: flex;
    justify-content: center;
    gap: 20px;
    background: rgba(0, 0, 0, 0.5);
}

.control-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-button:active {
    transform: scale(0.95);
}

.control-button.end-call {
    background: #ef4444;
}

.control-button.muted {
    background: #ef4444;
}

/* ============================================
   INCOMING CALL MODAL (Telegram/WhatsApp style)
   ============================================ */
.call-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    animation: fadeIn 0.3s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.call-modal.hidden {
    display: none;
}

.call-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.call-modal-content {
    position: relative;
    text-align: center;
    padding: 60px 40px 40px;
    z-index: 1;
    width: 100%;
    max-width: 400px;
}

/* Аватар с анимацией пульсации (как в Telegram) */
.call-avatar-container {
    position: relative;
    display: inline-block;
    margin-bottom: 32px;
}

.call-avatar {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: linear-gradient(135deg, #34b7f1, #2e9de6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 64px;
    font-weight: 600;
    color: white;
    margin: 0 auto;
    position: relative;
    z-index: 2;
    border: 4px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: avatarPulse 2s ease-in-out infinite;
}

.call-avatar-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 3px solid rgba(52, 183, 241, 0.5);
    animation: pulseRing 2s ease-out infinite;
}

@keyframes avatarPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.03);
    }
}

@keyframes pulseRing {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.4);
        opacity: 0;
    }
}

/* Имя звонящего (крупный шрифт) */
.caller-name {
    font-size: 32px;
    font-weight: 700;
    color: white;
    margin-bottom: 12px;
    line-height: 1.2;
}

/* Тип звонка */
.call-type-text {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 40px;
    font-weight: 400;
}

/* Статус подключения */
.call-status {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 40px;
    min-height: 24px;
}

.call-status.connecting {
    color: rgba(255, 255, 255, 0.9);
    animation: blink 1.5s ease-in-out infinite;
}

.call-status.error {
    color: #ef4444;
}

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

/* Spinner */
.call-spinner {
    display: none;
    width: 40px;
    height: 40px;
    margin: 20px auto;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.call-spinner[style*="block"] {
    display: block;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Кнопки (большие круглые, как в Telegram) */
.call-buttons {
    display: flex;
    gap: 32px;
    justify-content: center;
    align-items: center;
    margin-top: 60px;
}

.call-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
    transition: all 0.2s ease;
}

.call-button:active {
    transform: scale(0.92);
}

.call-button-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: white;
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.call-button.accept .call-button-icon {
    background: #22c55e;
}

.call-button.accept .call-button-icon:hover {
    background: #16a34a;
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.4);
}

.call-button.reject .call-button-icon {
    background: #ef4444;
}

.call-button.reject .call-button-icon:hover {
    background: #dc2626;
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.call-button-text {
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   CONTEXT MENU
   ============================================ */
.context-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1e2d3b;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    padding: 20px;
    padding-bottom: max(20px, env(safe-area-inset-bottom, 20px));
    z-index: 10000;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
}

.context-menu.hidden {
    display: none;
}

.context-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 0.2s;
    text-align: left;
}

.context-menu-item:active {
    background: rgba(255, 255, 255, 0.1);
}

.context-menu-item.delete {
    color: #ef4444;
}

.context-menu-item i {
    font-size: 20px;
}

/* ============================================
   EDIT MODAL
   ============================================ */
.edit-modal {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.edit-modal.hidden {
    display: none;
}

.edit-modal-content {
    background: #1e2d3b;
    border-radius: 16px;
    padding: 24px;
        width: 100%;
    max-width: 500px;
}

.edit-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.edit-modal-header h3 {
    font-size: 20px;
    font-weight: 600;
}

.close-button {
    background: none;
    border: none;
    color: #8a9aa8;
    font-size: 32px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.close-button:active {
    background: rgba(255, 255, 255, 0.1);
}

.edit-input {
        width: 100%;
    background: #2c3d4e;
    border: none;
    border-radius: 12px;
    padding: 12px 16px;
    color: white;
    font-size: 16px;
    outline: none;
    min-height: 100px;
    resize: vertical;
    font-family: inherit;
    margin-bottom: 20px;
}

.edit-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-button.cancel {
    background: #2c3d4e;
    color: white;
}

.modal-button.save {
    background: #34b7f1;
    color: white;
}

.modal-button:active {
    transform: scale(0.95);
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   UTILITIES
   ============================================ */
.hidden {
    display: none !important;
}

/* ============================================
   SCROLLBAR
   ============================================ */
.main-content::-webkit-scrollbar,
.messages-container::-webkit-scrollbar {
    display: none;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (min-width: 768px) {
    body {
        display: flex;
        justify-content: center;
        align-items: center;
        background: #000;
        margin: 0;
        padding: 0;
        min-height: 100vh;
    }
    
    .communication-room.app-container {
        width: 420px;
        min-width: 320px;
        max-width: 420px;
        height: 90vh;
        max-height: 800px;
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
        position: relative;
    }
    
    .chat-window {
        position: absolute;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        right: auto;
        bottom: auto;
        border-radius: 12px;
    }
}

/* ============================================
   ПАНЕЛЬ ПОИСКА
   ============================================ */

.search-panel {
    padding: 8px 16px 12px;
    background: var(--bg-color, #17212b);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.search-panel.hidden {
    display: none;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 10px 14px;
    gap: 10px;
}

.search-icon {
    font-size: 16px;
    opacity: 0.6;
}

.search-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: #fff;
    font-size: 15px;
    font-family: inherit;
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.clear-search-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 4px;
    font-size: 14px;
    line-height: 1;
}

.clear-search-btn:hover {
    color: #fff;
}

/* Стиль для элемента контакта */
.contact-item {
    cursor: pointer;
    transition: background 0.2s;
}

.contact-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.contact-item .start-chat-btn {
    transition: transform 0.2s, background 0.2s;
}

.contact-item .start-chat-btn:hover {
    background: #5a6fd6 !important;
    transform: scale(1.05);
}

/* ============================================
   БОКОВОЕ МЕНЮ (SIDEBAR) - Telegram Style
   ============================================ */

/* Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 85vw;
    height: 100%;
    background: var(--bg-color, #17212b);
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.3);
}

.sidebar.open {
    transform: translateX(0);
}

/* Шапка sidebar с профилем */
.sidebar-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px 16px;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.sidebar-profile {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.sidebar-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
    padding-top: 8px;
}

.sidebar-user-name {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.sidebar-user-login {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-theme-toggle {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
    margin-top: 4px;
}

.sidebar-theme-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Меню */
.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.sidebar-menu-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 12px 20px;
    background: none;
    border: none;
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
    text-align: left;
    gap: 20px;
}

.sidebar-menu-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-menu-item:active {
    background: rgba(255, 255, 255, 0.12);
}

.sidebar-menu-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-menu-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 8px 0;
}

/* Footer */
.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 0;
}

.logout-item {
    color: #ef4444;
}

.logout-item:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Адаптивность sidebar */
@media (max-width: 320px) {
    .sidebar {
        width: 260px;
    }
    
    .sidebar-avatar {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }
    
    .sidebar-user-name {
        font-size: 15px;
    }
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.8;
}

.empty-text {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-hint {
    font-size: 14px;
    opacity: 0.7;
}

/* ============================================
   SETTINGS
   ============================================ */

.settings-container {
    padding: 20px;
}

.settings-profile {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
}

.settings-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 600;
    color: white;
}

.settings-info {
    flex: 1;
}

.settings-name {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.settings-id {
    font-size: 14px;
    color: var(--text-secondary);
}

.settings-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.settings-item:last-child {
    border-bottom: none;
}

.settings-item span:first-child {
    color: var(--text-primary);
}

.settings-item span:last-child {
    color: var(--text-secondary);
}

/* ============================================
   TOAST ANIMATIONS
   ============================================ */

@keyframes fadeInDown {
    from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes fadeOutUp {
    from { opacity: 1; transform: translateX(-50%) translateY(0); }
    to { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* ============================================
   START CHAT BUTTON
   ============================================ */

.start-chat-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.start-chat-btn:active {
    background: var(--accent-hover);
    transform: scale(0.95);
}

/* ============================================
   CALL STATES & SPINNER (Hybrid Offline Calls)
   ============================================ */

/* Spinner для состояния "Подключение..." */
.call-spinner {
    display: none;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Текст статуса звонка */
.call-status {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin: 10px 0;
    min-height: 20px;
    transition: color 0.3s;
}

.call-status.connecting {
    color: var(--accent-color);
    animation: pulse 1.5s ease-in-out infinite;
}

.call-status.error {
    color: var(--danger-color);
}

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

/* Скрыть кнопки звонка при подключении */
.call-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
    transition: opacity 0.3s;
}

.call-buttons.hidden {
    display: none !important;
}
