/* ============================================
   MINI CHAT WIDGET - iOS STYLE
   Версия: 4.0
   ============================================ */

:root {
    --ios-bg-page: #000000;
    --ios-bg-header: #1c1c1e;
    --ios-bg-input: #1c1c1e;
    --ios-bg-message-incoming: #0a84ff;
    --ios-bg-message-outgoing: #1c1c1e;
    --ios-text-primary: #ffffff;
    --ios-text-secondary: #8e8e93;
    --ios-text-message-incoming: #ffffff;
    --ios-text-message-outgoing: #ffffff;
    --ios-border: rgba(255, 255, 255, 0.1);
    --ios-shadow: rgba(0, 0, 0, 0.3);
    --ios-accent: #0a84ff;
    --ios-danger: #ff3b30;
    --ios-success: #34c759;
    --ios-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --widget-width: 380px;
    --widget-height: 600px;
    --border-radius-lg: 24px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;
}

body.day-theme {
    --ios-bg-page: #ffffff;
    --ios-bg-header: #f8f8f8;
    --ios-bg-input: #f8f8f8;
    --ios-bg-message-incoming: #0a84ff;
    --ios-bg-message-outgoing: #e5e5ea;
    --ios-text-primary: #000000;
    --ios-text-secondary: #8e8e93;
    --ios-text-message-incoming: #ffffff;
    --ios-text-message-outgoing: #000000;
    --ios-border: rgba(0, 0, 0, 0.05);
    --ios-shadow: rgba(0, 0, 0, 0.1);
}

/* Кнопка открытия чата */
#mini-chat-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10000;
    background: var(--ios-accent);
    box-shadow: 0 4px 16px var(--ios-shadow);
    transition: all var(--transition-normal);
}

#mini-chat-button i {
    color: white;
    font-size: 24px;
}

/* Виджет - фиксированная структура */
#mini-chat-widget {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: var(--widget-width);
    height: var(--widget-height);
    background: var(--ios-bg-page);
    border-radius: var(--border-radius-lg);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    box-shadow: 0 20px 60px var(--ios-shadow);
    overflow: hidden;
    transform: translateY(100%) scale(0.95);
    opacity: 0;
    transition: all var(--transition-slow);
    border: 1px solid var(--ios-border);
}

#mini-chat-widget.open {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Шапка - ВСЕГДА ВИДИМА, НЕ ПРОКРУЧИВАЕТСЯ */
#mini-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: var(--ios-bg-header);
    height: 56px;
    min-height: 56px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--ios-border);
    position: relative;
    z-index: 10;
}

#mini-chat-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: transparent;
    color: var(--ios-text-secondary);
    flex-shrink: 0;
}

#mini-chat-close:hover {
    background: rgba(128, 128, 128, 0.2);
}

#mini-chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    max-width: 140px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-text {
    font-size: 12px;
    font-weight: 500;
    font-family: var(--ios-font);
    color: var(--ios-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#mini-chat-status.status-online .status-dot {
    background: var(--ios-success);
}

#mini-chat-status.status-online .status-text {
    color: var(--ios-success);
}

#mini-chat-status.status-offline .status-dot {
    background: var(--ios-text-secondary);
}

#mini-chat-header-buttons {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

#mini-chat-header-buttons button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    cursor: pointer;
    border: none;
    color: var(--ios-text-secondary);
    font-size: 18px;
}

#mini-chat-header-buttons button:hover {
    background: rgba(128, 128, 128, 0.2);
}

/* Контейнер сообщений - ТОЛЬКО ОН ПРОКРУЧИВАЕТСЯ */
#mini-chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--ios-bg-page);
    min-height: 0;
}

/* Сообщения - цвета поменяны местами */
.incoming-msg,
.outgoing-msg {
    max-width: 78%;
    padding: 10px 14px;
    font-size: 16px;
    line-height: 1.45;
    word-break: break-word;
    font-family: var(--ios-font);
    border-radius: 20px !important;
}

/* Входящие сообщения (слева) - теперь синие */
.incoming-msg {
    align-self: flex-start;
    background: var(--ios-bg-message-incoming);
    color: var(--ios-text-message-incoming);
}

/* Исходящие сообщения (справа) - теперь серые */
.outgoing-msg {
    align-self: flex-end;
    background: var(--ios-bg-message-outgoing);
    color: var(--ios-text-message-outgoing);
}

/* Эмодзи */
.emoji-msg {
    background: transparent !important;
    padding: 4px 0 !important;
}

.emoji-msg .msg-text {
    font-size: 44px !important;
    line-height: 1.2 !important;
    background: transparent !important;
}

.emoji-msg.single-emoji .msg-text {
    font-size: 64px !important;
}

.incoming-msg.emoji-msg,
.outgoing-msg.emoji-msg {
    background: transparent !important;
}

/* Разделитель времени */
.msg-time-divider {
    text-align: center;
    font-size: 11px;
    font-weight: 500;
    font-family: var(--ios-font);
    color: var(--ios-text-secondary);
    margin: 8px 0;
    padding: 4px 12px;
    background: rgba(128, 128, 128, 0.15);
    border-radius: 50px;
    align-self: center;
}

/* Ссылки */
.msg-text a {
    color: var(--ios-accent);
    text-decoration: none;
}

/* Блок ввода - ФИКСИРОВАННЫЙ ВНИЗУ, ВСЕ ЭЛЕМЕНТЫ В ОДНОЙ СТРОКЕ */
#mini-chat-input-block {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--ios-bg-header);
    border-top: 1px solid var(--ios-border);
    min-height: 56px;
    flex-shrink: 0;
    box-sizing: border-box;
}

/* Кнопка прикрепления */
#mini-chat-add-file {
    width: 40px;
    height: 40px;
    min-width: 40px;
    max-width: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    cursor: pointer;
    border: none;
    color: var(--ios-text-secondary);
    font-size: 20px;
    flex-shrink: 0;
    margin: 0;
    padding: 0;
}

#mini-chat-add-file:hover {
    background: rgba(128, 128, 128, 0.15);
}

/* Обертка поля ввода */
.input-wrapper {
    flex: 1;
    background: var(--ios-bg-input);
    border-radius: 28px;
    padding: 4px 12px;
    border: 0.5px solid var(--ios-border);
    min-width: 0;
    box-sizing: border-box;
}

/* Поле ввода */
#mini-chat-message {
    width: 100%;
    padding: 8px 0;
    border: none;
    background: transparent;
    color: var(--ios-text-primary);
    font-size: 16px;
    font-family: var(--ios-font);
    line-height: 1.4;
    resize: none;
    outline: none;
    overflow-y: auto;
    min-height: 24px;
    max-height: 100px;
    box-sizing: border-box;
}

#mini-chat-message::placeholder {
    color: var(--ios-text-secondary);
}

/* Кнопка отправки */
#mini-chat-send {
    width: 40px;
    height: 40px;
    min-width: 40px;
    max-width: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    cursor: pointer;
    border: none;
    color: var(--ios-text-secondary);
    font-size: 20px;
    flex-shrink: 0;
    margin: 0;
    padding: 0;
}

#mini-chat-send:hover {
    background: rgba(128, 128, 128, 0.15);
}

/* ============================================
   ОВЕРЛЕЙ ЗВОНКА - iOS 26 STYLE (как на iPhone)
   ============================================ */

#call-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000000;
    z-index: 1000;
    transition: all var(--transition-normal);
    border-radius: var(--border-radius-lg);
}

#call-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.call-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 60px 20px 40px;
    position: relative;
    box-sizing: border-box;
}

/* Верхняя панель с кнопкой три точки */
.call-top-bar {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 20;
}

/* Кнопка три точки в правом верхнем углу */
.call-more-btn-top {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(128, 128, 128, 0.3);
    backdrop-filter: blur(10px);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.2s ease;
}

.call-more-btn-top:active {
    transform: scale(0.95);
}

/* Аватар (круг с инициалами) */
.call-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
}

.call-avatar .initials {
    font-size: 48px;
    font-weight: 500;
    font-family: var(--ios-font);
    color: white;
}

/* Имя */
.call-name {
    font-size: 34px;
    font-weight: 600;
    font-family: var(--ios-font);
    color: white;
    margin-bottom: 8px;
    text-align: center;
}

/* Статус */
.call-status {
    font-size: 17px;
    font-family: var(--ios-font);
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
}

/* Таймер звонка */
.call-timer {
    font-size: 48px;
    font-weight: 300;
    font-family: monospace;
    color: white;
    letter-spacing: 2px;
    margin: 10px 0;
}

/* Контейнер для кнопок */
.call-buttons-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    z-index: 10;
    position: relative;
    margin-top: auto;
    margin-bottom: 40px;
}

/* Ряд кнопок */
.call-buttons-row {
    display: flex;
    justify-content: center;
    gap: 35px;
    width: 100%;
}

/* Кнопка звонка */
.call-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.call-btn:active {
    transform: scale(0.95);
}

.call-btn-icon {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(128, 128, 128, 0.3);
    backdrop-filter: blur(10px);
}

.call-btn-label {
    font-size: 11px;
    font-family: var(--ios-font);
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    margin-top: 8px;
}

/* Кнопка принятия звонка */
.call-btn-accept .call-btn-icon {
    background: #34c759;
    box-shadow: 0 4px 16px rgba(52, 199, 89, 0.4);
}

.call-btn-accept .call-btn-label {
    color: #34c759;
}

/* Кнопка отклонения/завершения звонка - без текста */
.call-btn-decline .call-btn-icon,
.call-btn-end .call-btn-icon {
    background: #ff3b30;
    box-shadow: 0 4px 16px rgba(255, 59, 48, 0.4);
}

.call-btn-decline .call-btn-label,
.call-btn-end .call-btn-label {
    display: none;
}

/* Меню дополнительных опций */
.call-extra-menu {
    position: absolute;
    top: 70px;
    right: 20px;
    left: auto;
    transform: none;
    width: 280px;
    background: rgba(30, 30, 35, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 14px;
    padding: 12px 0;
    z-index: 15;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 0.5px solid rgba(255, 255, 255, 0.1);
}

.call-extra-menu.hidden {
    display: none;
}

.call-extra-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.call-extra-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.call-extra-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.call-extra-left i {
    width: 24px;
    color: white;
    font-size: 18px;
}

.call-extra-left span {
    color: white;
    font-size: 16px;
    font-family: var(--ios-font);
}

.call-extra-toggle {
    width: 44px;
    height: 24px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.2);
    position: relative;
    cursor: pointer;
}

.call-extra-toggle.on {
    background: #34c759;
}

.call-extra-toggle .toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    transition: all 0.2s ease;
}

.call-extra-toggle.on .toggle-slider {
    left: calc(100% - 22px);
}

/* Видео контейнер */
#video-call-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 2000;
    overflow: hidden;
    border-radius: var(--border-radius-lg);
}

#video-call-container.hidden {
    display: none;
}

.remote-video-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    overflow: hidden;
}

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

.remote-video-status {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: white;
    background: rgba(0, 0, 0, 0.5);
    padding: 16px 24px;
    border-radius: 50px;
    backdrop-filter: blur(10px);
    font-family: var(--ios-font);
}

.remote-video-status.hidden {
    opacity: 0;
    visibility: hidden;
}

.local-video-container {
    position: absolute;
    bottom: 100px;
    right: 20px;
    width: 120px;
    height: 160px;
    border-radius: 20px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    z-index: 3;
    background: #2a2a2a;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.local-video-container:hover {
    transform: scale(1.05);
}

#local-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.local-video-label {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-family: var(--ios-font);
    backdrop-filter: blur(5px);
}

.video-controls {
    position: absolute;
    bottom: 30px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 16px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    z-index: 5;
}

.video-control-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.video-control-btn.end-call {
    background: #ff3b30;
}

.video-call-info {
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 5;
    pointer-events: none;
}

.video-call-timer {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    color: white;
    padding: 6px 16px;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    font-family: monospace;
}

.video-call-peer {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    color: rgba(255, 255, 255, 0.9);
    padding: 4px 14px;
    border-radius: 50px;
    font-size: 13px;
    font-family: var(--ios-font);
}

/* Адаптивность для iPhone */
@media only screen and (max-width: 428px) {
    #mini-chat-widget {
        width: calc(100vw - 20px) !important;
        height: 80vh !important;
        bottom: 70px !important;
        right: 10px !important;
    }
    
    #mini-chat-header {
        height: 52px !important;
        padding: 6px 12px !important;
    }
    
    #mini-chat-button {
        bottom: 20px !important;
        right: 20px !important;
        width: 52px !important;
        height: 52px !important;
    }
    
    #mini-chat-messages {
        padding: 10px 12px !important;
    }
    
    .incoming-msg,
    .outgoing-msg {
        max-width: 85% !important;
        font-size: 15px !important;
        padding: 8px 12px !important;
    }
    
    .emoji-msg .msg-text {
        font-size: 40px !important;
    }
    
    .emoji-msg.single-emoji .msg-text {
        font-size: 56px !important;
    }
    
    #mini-chat-input-block {
        padding: 8px 12px !important;
        min-height: 52px !important;
        gap: 6px !important;
    }
    
    #mini-chat-add-file,
    #mini-chat-send {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        max-width: 36px !important;
        font-size: 18px !important;
    }
    
    .input-wrapper {
        padding: 3px 10px !important;
    }
    
    #mini-chat-message {
        font-size: 15px !important;
        padding: 6px 0 !important;
        min-height: 22px !important;
    }
    
    .call-more-btn-top {
        width: 36px;
        height: 36px;
    }
    
    .call-avatar {
        width: 100px !important;
        height: 100px !important;
        margin: 15px 0 !important;
    }
    
    .call-avatar .initials {
        font-size: 40px !important;
    }
    
    .call-name {
        font-size: 28px !important;
    }
    
    .call-status {
        font-size: 15px !important;
    }
    
    .call-timer {
        font-size: 40px !important;
    }
    
    .call-btn-icon {
        width: 58px !important;
        height: 58px !important;
    }
    
    .call-buttons-row {
        gap: 25px !important;
    }
    
    .call-extra-menu {
        width: 260px;
        top: 65px;
        right: 15px;
    }
    
    .local-video-container {
        width: 100px !important;
        height: 133px !important;
        bottom: 90px !important;
        right: 12px !important;
    }
    
    .video-control-btn {
        width: 45px !important;
        height: 45px !important;
        font-size: 18px !important;
    }
}

@media only screen and (max-width: 375px) {
    #mini-chat-header {
        height: 48px !important;
        padding: 4px 10px !important;
    }
    
    #mini-chat-status {
        max-width: 100px !important;
    }
    
    .status-text {
        font-size: 10px !important;
    }
    
    .incoming-msg,
    .outgoing-msg {
        font-size: 14px !important;
        padding: 6px 10px !important;
    }
    
    .emoji-msg .msg-text {
        font-size: 36px !important;
    }
    
    .emoji-msg.single-emoji .msg-text {
        font-size: 48px !important;
    }
    
    #mini-chat-input-block {
        padding: 6px 10px !important;
        min-height: 48px !important;
        gap: 5px !important;
    }
    
    #mini-chat-add-file,
    #mini-chat-send {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        max-width: 32px !important;
        font-size: 16px !important;
    }
    
    .input-wrapper {
        padding: 2px 8px !important;
    }
    
    #mini-chat-message {
        font-size: 14px !important;
        padding: 5px 0 !important;
        min-height: 20px !important;
    }
    
    .call-more-btn-top {
        width: 32px;
        height: 32px;
    }
    
    .call-avatar {
        width: 85px !important;
        height: 85px !important;
    }
    
    .call-avatar .initials {
        font-size: 34px !important;
    }
    
    .call-name {
        font-size: 24px !important;
    }
    
    .call-timer {
        font-size: 36px !important;
    }
    
    .call-btn-icon {
        width: 52px !important;
        height: 52px !important;
    }
    
    .call-buttons-row {
        gap: 20px !important;
    }
    
    .call-extra-menu {
        width: 240px;
        top: 60px;
        right: 12px;
    }
    
    .local-video-container {
        width: 85px !important;
        height: 113px !important;
        bottom: 80px !important;
    }
    
    .video-control-btn {
        width: 42px !important;
        height: 42px !important;
        font-size: 16px !important;
    }
}

/* Убираем скроллбар */
#mini-chat-messages::-webkit-scrollbar {
    display: none;
}

#mini-chat-messages {
    scrollbar-width: none;
}
/* ============================================
   АНИМАЦИЯ ПОЯВЛЕНИЯ СООБЩЕНИЙ
   ============================================ */

.incoming-msg,
.outgoing-msg {
    animation: messageSlideIn 0.3s cubic-bezier(0.2, 0.9, 0.4, 1.1) forwards;
}

@keyframes messageSlideIn {
    0% {
        opacity: 0;
        transform: translateY(15px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Для эмодзи сообщений - более быстрая анимация */
.emoji-msg {
    animation: messagePopIn 0.2s ease-out forwards !important;
}

@keyframes messagePopIn {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    80% {
        transform: scale(1.05);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}