/* Chat Widget Styles */
#chat-widget-root {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

#chat-button {
    width: 60px;
    height: 60px;
    background: #25D366;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

#chat-button:hover {
    transform: scale(1.05);
}

#chat-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #e5ddd5;
}

#chat-messages::-webkit-scrollbar {
    width: 6px;
}

#chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    #chat-widget-root {
        bottom: 15px;
        right: 15px;
    }
    
    #chat-button {
        width: 55px;
        height: 55px;
    }
    
    #chat-button svg {
        width: 28px;
        height: 28px;
    }
    
    #chat-window {
        position: absolute;
        bottom: 70px;
        right: 0;
        width: calc(100vw - 30px);
        max-width: 400px;
        height: calc(100vh - 100px);
        min-height: 400px;
        max-height: 650px;
        border-radius: 16px;
    }
    
    #chat-messages {
        padding: 12px;
    }
    
    .message img,
    .message video {
        max-width: 180px !important;
    }
    
    #message-input {
        font-size: 16px !important;
    }
}

/* Маленькие телефоны (до 480px) */
@media (max-width: 480px) {
    #chat-widget-root {
        bottom: 10px;
        right: 10px;
    }
    
    #chat-button {
        width: 50px;
        height: 50px;
    }
    
    #chat-button svg {
        width: 26px;
        height: 26px;
    }
    
    #chat-window {
        position: absolute;
        bottom: 65px;
        right: 0;
        width: calc(100vw - 20px);
        max-width: 350px;
        height: calc(100vh - 80px);
        min-height: 350px;
        max-height: 550px;
        border-radius: 12px;
    }
    
    #chat-messages {
        padding: 10px;
    }
    
    .message {
        margin: 8px !important;
        padding: 6px 10px !important;
    }
    
    .message img,
    .message video {
        max-width: 140px !important;
    }
    
    .message-time {
        font-size: 9px !important;
    }
    
    #message-input {
        padding: 8px 12px !important;
        font-size: 15px !important;
    }
    
    #send-btn {
        padding: 8px 16px !important;
        font-size: 14px !important;
    }
    
    #attach-btn {
        font-size: 18px !important;
        width: 36px;
        height: 36px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    #chat-header {
        padding: 10px 12px !important;
        font-size: 13px !important;
    }
    
    #close-chat-btn,
    #edit-id-btn {
        font-size: 18px !important;
        width: 32px;
        height: 32px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* Очень маленькие телефоны (до 380px) */
@media (max-width: 380px) {
    #chat-window {
        width: calc(100vw - 16px);
        max-width: 320px;
        height: calc(100vh - 70px);
        min-height: 300px;
        max-height: 500px;
    }
    
    .message img,
    .message video {
        max-width: 120px !important;
    }
    
    #chat-header span {
        font-size: 11px !important;
    }
    
    #user-id-display {
        font-size: 11px !important;
    }
}

/* Альбомная ориентация */
@media (max-width: 768px) and (orientation: landscape) {
    #chat-window {
        height: calc(100vh - 80px);
        max-height: 400px;
    }
    
    #chat-messages {
        max-height: calc(100vh - 140px);
    }
}

/* Touch-friendly увеличенные области нажатия */
@media (max-width: 768px) {
    #close-chat-btn,
    #edit-id-btn,
    #attach-btn,
    #send-btn {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    #message-input {
        min-height: 40px;
    }
    
    .message-actions button {
        min-width: 32px;
        min-height: 32px;
    }
}

/* Темная тема */
@media (prefers-color-scheme: dark) {
    #chat-window {
        background: #1a1a1a;
    }
    
    #chat-messages {
        background: #2c2c2c;
    }
    
    .message.user .message-content {
        background: #2e7d32;
        color: #fff;
    }
    
    .message.admin .message-content {
        background: #3c3c3c;
        color: #fff;
    }
    
    .message-time {
        color: #aaa;
    }
    
    #message-input {
        background: #3c3c3c;
        border-color: #555;
        color: #fff;
    }
    
    #message-input::placeholder {
        color: #aaa;
    }
    
    #password-form-container {
        background: #4a4a4a;
    }
    
    #password-form-container div {
        color: #ffc107;
    }
    
    #chat-header {
        background: #0a5a44;
    }
}
