/**
 * CSS стилі для системи чату
 */

/* Контейнер кнопки чату */
.chat-button-container {
    position: fixed;
    top: calc(60% + 3px + 70px);
    right: 0;
    transform: translateY(-50%) rotate(90deg);
    transform-origin: right center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 5px 10px;
    box-shadow: -2px 0 5px rgba(102, 126, 234, 0.4);
    border-radius: 0 0 5px 5px;
    font-family: Arial, sans-serif;
    z-index: 9998;
    text-align: center;
    white-space: nowrap;
    margin-right: 20px;
    color: white;
}

/* Кнопка чату */
.chat-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    font-size: 24px;
}

.chat-toggle-btn:hover {
    transform: scale(1.2);
}

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

.chat-icon {
    font-size: 24px;
}

/* Модальне вікно чату */
.chat-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.chat-modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.chat-modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: bold;
}

.chat-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chat-modal-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Бічна панель кімнат */
.chat-sidebar {
    width: 250px;
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
}

.chat-rooms-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.chat-room-item {
    padding: 12px 15px;
    margin-bottom: 8px;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #e9ecef;
}

.chat-room-item:hover {
    background: #e9ecef;
    transform: translateX(2px);
}

.chat-room-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

.chat-room-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.chat-room-icon {
    font-size: 18px;
}

.chat-room-name {
    flex: 1;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-room-members {
    font-size: 12px;
    opacity: 0.7;
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
}

.chat-room-controls {
    display: flex;
    gap: 5px;
}

.chat-room-control-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 4px 6px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.chat-room-control-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

.chat-invite-btn {
    color: #28a745;
}

.chat-delete-btn {
    color: #dc3545;
}

.chat-sidebar-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    flex-shrink: 0;
}

.chat-action-btn,
.chat-create-room-btn {
    margin: 0;
    width: 40px;
    height: 40px;
    padding: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    font-size: 18px;
    line-height: 1;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
}

.chat-action-btn:hover,
.chat-create-room-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chat-trash-btn {
    background: linear-gradient(135deg, #78909c 0%, #546e7a 100%) !important;
}

.chat-trash-btn.is-active {
    background: linear-gradient(135deg, #ef6c00 0%, #e65100 100%) !important;
    box-shadow: 0 4px 12px rgba(230, 81, 0, 0.35);
}

.chat-trash-count {
    position: absolute;
    top: -4px;
    right: -4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    margin: 0;
    border-radius: 999px;
    background: #c62828;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
}

.chat-room-item.is-trash {
    opacity: 0.92;
    background: #fafafa;
}

.chat-input-area.is-locked {
    opacity: 0.55;
    pointer-events: none;
}

/* Основна область чату */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.chat-welcome {
    text-align: center;
    color: #6c757d;
    margin-top: 50px;
    font-size: 18px;
}

.chat-loading {
    text-align: center;
    color: #6c757d;
    padding: 20px;
}

.chat-message {
    margin-bottom: 15px;
    padding: 12px 15px;
    background: white;
    border-radius: 12px;
    border-left: 3px solid #667eea;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.chat-message-admin {
    border-left-color: #dc3545;
    background: #fff5f5;
}

.chat-message-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 12px;
}

.chat-message-username {
    font-weight: bold;
    color: #667eea;
}

.chat-message-admin .chat-message-username {
    color: #dc3545;
}

.chat-message-time {
    color: #6c757d;
}

.chat-message-text {
    color: #333;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-smilie {
    max-width: 24px;
    max-height: 24px;
    vertical-align: middle;
}

/* Панель звернення в підтримку */
.chat-support-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    background: #fff8e6;
    border-bottom: 1px solid #f0e0b2;
    font-size: 13px;
}

.chat-support-bar[hidden] {
    display: none !important;
}

.chat-support-bar-label {
    color: #6b5a20;
    font-weight: 600;
}

.chat-close-ticket-btn {
    padding: 6px 12px;
    border: 1px solid #c9a227;
    border-radius: 6px;
    background: #fff;
    color: #6b5a20;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
}

.chat-close-ticket-btn:hover {
    background: #fff3cd;
}

.chat-message-system {
    opacity: 0.85;
    font-style: italic;
}

/* Область введення повідомлень */
.chat-input-area {
    padding: 15px;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.chat-smilies-btn {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.2s ease;
}

.chat-smilies-btn:hover {
    background: #e9ecef;
}

.chat-voice-btn {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.chat-voice-btn:hover {
    background: #e9ecef;
}

.chat-voice-file-btn {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}

.chat-voice-file-btn:hover {
    background: #e9ecef;
}

.chat-voice-btn.is-recording {
    background: #ffebee;
    border-color: #ef9a9a;
    box-shadow: 0 0 0 2px rgba(198, 40, 40, 0.25);
    animation: chat-voice-pulse 1.2s ease-in-out infinite;
}

@keyframes chat-voice-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.65; }
}

.chat-voice-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 15px 12px;
    background: #fff8e1;
    border-top: 1px solid #ffe082;
    font-size: 13px;
    color: #5d4037;
}

.chat-voice-bar[hidden] {
    display: none !important;
}

.chat-voice-cancel {
    border: none;
    background: #eee;
    border-radius: 6px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 12px;
}

.chat-voice-msg {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-voice-label {
    font-size: 12px;
    opacity: 0.8;
}

.chat-voice-player {
    width: 100%;
    max-width: 280px;
    height: 36px;
}

.chat-input {
    flex: 1;
    padding: 12px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    min-height: 44px;
    max-height: 120px;
    transition: border-color 0.2s ease;
}

.chat-input:focus {
    outline: none;
    border-color: #667eea;
}

.chat-send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.chat-send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chat-send-btn:active {
    transform: translateY(0);
}

/* Панель смайлів */
.chat-smilies-panel {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 10001;
    max-width: 400px;
    max-height: 300px;
}

.chat-smilies-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    max-height: 250px;
    overflow-y: auto;
}

.chat-smilie-item {
    font-size: 24px;
    text-align: center;
    padding: 8px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.chat-smilie-item:hover {
    background: #f8f9fa;
}

/* Адаптивність */
@media (max-width: 768px) {
    .chat-modal-content {
        width: 95%;
        height: 90vh;
    }
    
    .chat-sidebar {
        width: 200px;
    }
}

@media (max-width: 480px) {
    .chat-modal-content {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    
    .chat-sidebar {
        width: 150px;
    }
    
    .chat-smilies-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
