/* ================================================
   PROLEX Live Chat Panel - Main Styles
   ================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --success-color: #4caf50;
    --danger-color: #f44336;
    --warning-color: #ff9800;
    --text-color: #333;
    --text-secondary: #666;
    --text-light: #999;
    --border-color: #e0e0e0;
    --bg-light: #f5f5f5;
    --bg-white: #ffffff;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', Arial, sans-serif;
    background: var(--bg-light);
    color: var(--text-color);
    line-height: 1.6;
}

/* ================================================
   LOGIN PAGE
   ================================================ */

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 420px;
    animation: slideIn 0.4s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-logo h1 {
    font-size: 32px;
    color: #667eea;
    text-align: center;
    margin-bottom: 5px;
    font-weight: 700;
}

.login-logo .subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.login-description {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 30px;
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-color);
    font-weight: 500;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 15px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
}

.btn-login:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

.error-message {
    margin: 15px 0;
    padding: 12px;
    background: #fee;
    color: #c33;
    border-radius: 6px;
    text-align: center;
    font-size: 14px;
    border: 1px solid #fcc;
}

.login-footer {
    margin-top: 30px;
    text-align: center;
    color: var(--text-light);
    font-size: 12px;
}

/* ================================================
   DASHBOARD
   ================================================ */

.dashboard-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Header */
.dashboard-header {
    background: var(--bg-white);
    padding: 15px 25px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    z-index: 100;
}

.dashboard-header h1 {
    font-size: 22px;
    color: var(--primary-color);
    font-weight: 700;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.manager-name {
    font-weight: 500;
    color: var(--text-color);
}

.btn-sound {
    padding: 8px 12px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 36px;
}

.btn-sound:hover {
    background: var(--bg-light);
    border-color: var(--text-secondary);
    transform: scale(1.05);
}

.btn-sound.sound-disabled {
    color: var(--text-light);
    opacity: 0.6;
}

.btn-sound.sound-disabled .sound-icon {
    opacity: 0.5;
}

.sound-icon {
    font-size: 16px;
    transition: all 0.2s;
}

/* 🔒 Кнопка смены пароля */
.btn-change-password {
    padding: 8px 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 36px;
    margin-right: 8px;
}

.btn-change-password:hover {
    background: var(--bg-light);
    border-color: var(--text-secondary);
    transform: scale(1.05);
}

/* 🔒 Модальное окно смены пароля */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-white);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 18px;
}

.modal-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1);
}

.modal-actions {
    display: flex;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid var(--border-color);
    justify-content: flex-end;
}

.btn-save {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-save:hover {
    background: #2980b9;
}

.btn-save:disabled {
    background: var(--text-light);
    cursor: not-allowed;
}

.btn-cancel {
    background: var(--bg-light);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

/* 🔔 Анимация колокольчика */
@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

.chat-notification {
    animation: pulse 1s infinite;
}

.btn-logout {
    padding: 8px 16px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: var(--bg-light);
    border-color: var(--text-secondary);
}

/* Main content area */
.dashboard-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ================================================
   ЛЕВАЯ КОЛОНКА - СПИСОК ДИАЛОГОВ
   ================================================ */

.chat-list {
    width: 380px;
    background: var(--bg-white);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.chat-list-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.chat-list-header h2 {
    font-size: 18px;
    margin-bottom: 15px;
    color: var(--text-color);
}

/* 🆕 Переключатель Активные/Архив */
.chat-filter-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.filter-tab {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-white);
    color: var(--text-secondary);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-tab:hover {
    background: var(--bg-light);
    border-color: var(--primary-color);
}

.filter-tab.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* 🆕 Разделитель архивации */
.archive-divider {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 25px 0;
    padding: 0 20px;
}

.archive-divider-line {
    flex: 1;
    height: 2px;
    background: linear-gradient(90deg, 
        transparent, 
        #ff9800 20%, 
        #ff9800 80%, 
        transparent
    );
    opacity: 0.5;
}

.archive-divider-text {
    padding: 10px 20px;
    background: #fff3e0;
    border: 2px solid #ff9800;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #e65100;
    text-align: center;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.2);
}

.archive-divider-text small {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    font-weight: 500;
    color: #f57c00;
    opacity: 0.9;
}

.archive-icon {
    font-size: 16px;
    margin-right: 5px;
}

.search-box input {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.chat-list-items {
    flex: 1;
    overflow-y: auto;
}

/* Элемент списка чата */
.chat-item {
    padding: 15px 20px;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.chat-item:hover {
    background: #f9f9f9;
}

.chat-item.active {
    background: #e8eaf6;
    border-left: 3px solid var(--primary-color);
}

/* 🆕 Архивный чат */
.chat-item.archived {
    opacity: 0.7;
    background: #f9f9f9;
}

.chat-item.archived:hover {
    opacity: 1;
    background: #f5f5f5;
}

.chat-item.archived .chat-username::after {
    content: " 📦";
    font-size: 12px;
}

.chat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.chat-item-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-online {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--success-color);
    display: inline-block;
}

.chat-item-time {
    font-size: 12px;
    color: var(--text-light);
}

.chat-item-preview {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 5px;
}

.chat-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.unread-badge {
    background: var(--primary-color);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

/* ================================================
   ПРАВАЯ КОЛОНКА - ОКНО ЧАТА
   ================================================ */

.chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fafafa;
}

/* Пустое состояние */
.chat-window-empty {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.empty-state {
    text-align: center;
    color: var(--text-light);
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 24px;
    margin-bottom: 10px;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 14px;
}

/* Активный чат */
.chat-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    background: var(--bg-white);
    padding: 15px 25px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-info h3 {
    font-size: 18px;
    margin-bottom: 5px;
    color: var(--text-color);
}

.chat-user-id {
    font-size: 13px;
    color: var(--text-light);
}

.chat-header-actions {
    display: flex;
    gap: 10px;
}

.btn-action {
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-takeover {
    background: var(--primary-color);
    color: white;
}

.btn-takeover:hover {
    background: var(--primary-dark);
}

.btn-close {
    background: var(--danger-color);
    color: white;
}

.btn-close:hover {
    background: #d32f2f;
}

/* Контейнер сообщений */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #fafafa;
}

/* Сообщение */
.message {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease-out;
}

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

.message.user {
    align-items: flex-start;
}

.message.ai,
.message.manager {
    align-items: flex-end;
}

.message-sender {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 5px;
    padding: 0 5px;
}

.message-bubble {
    max-width: 65%;
    padding: 12px 16px;
    border-radius: 12px;
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.message.user .message-bubble {
    background: white;
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.message.ai .message-bubble {
    background: #e3f2fd;
    border: 1px solid #90caf9;
    border-bottom-right-radius: 4px;
}

.message.manager .message-bubble {
    background: #e8f5e9;
    border: 1px solid #81c784;
    border-bottom-right-radius: 4px;
}

.message-text {
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message-time {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 5px;
}

/* Поле ввода */
.message-input-container {
    background: var(--bg-white);
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#message-input {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    transition: border-color 0.2s;
}

#message-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-send {
    padding: 12px 30px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-send:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

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

.btn-send:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* ================================================
   LOADING STATES
   ================================================ */

.loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ================================================
   SCROLLBAR STYLING
   ================================================ */

.chat-list-items::-webkit-scrollbar,
.messages-container::-webkit-scrollbar {
    width: 6px;
}

.chat-list-items::-webkit-scrollbar-track,
.messages-container::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.chat-list-items::-webkit-scrollbar-thumb,
.messages-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.chat-list-items::-webkit-scrollbar-thumb:hover,
.messages-container::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* ================================================
   RESPONSIVE
   ================================================ */

@media (max-width: 768px) {
    .chat-list {
        width: 100%;
        position: absolute;
        left: 0;
        top: 60px;
        bottom: 0;
        z-index: 10;
        transition: transform 0.3s;
    }
    
    .chat-list.hidden {
        transform: translateX(-100%);
    }
    
    .message-bubble {
        max-width: 85%;
    }
}

/* ================================================
   UTILITIES
   ================================================ */

.text-center {
    text-align: center;
}

.mt-10 {
    margin-top: 10px;
}

.mb-10 {
    margin-bottom: 10px;
}

.hidden {
    display: none !important;
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.badge-primary {
    background: var(--primary-color);
    color: white;
}

.badge-success {
    background: var(--success-color);
    color: white;
}

.badge-danger {
    background: var(--danger-color);
    color: white;
}

/* ==================== AI MODERATION ==================== */

.moderation-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.moderation-modal.show {
    opacity: 1;
    visibility: visible;
}

.moderation-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.moderation-modal.show .moderation-content {
    transform: scale(1);
}

.moderation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
    border-radius: 12px 12px 0 0;
}

.moderation-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
}

.close-modal {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.close-modal:hover {
    background: #e0e0e0;
}

.moderation-body {
    padding: 20px;
}

.user-info {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.user-avatar {
    font-size: 24px;
    margin-right: 12px;
}

.user-details {
    flex: 1;
}

.user-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.user-id {
    font-size: 12px;
    color: #666;
    background: #e9ecef;
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-block;
}

.user-message, .ai-response {
    margin-bottom: 20px;
}

.message-label, .response-label {
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    font-size: 14px;
}

.message-content, .response-content {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid #007bff;
    line-height: 1.5;
    white-space: pre-wrap;
}

.response-content {
    border-left-color: #28a745;
    background: #f0f8ff;
}

.moderation-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-approve, .btn-edit, .btn-reject {
    flex: 1;
    min-width: 140px;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.btn-approve {
    background: #28a745;
    color: white;
}

.btn-approve:hover {
    background: #218838;
    transform: translateY(-1px);
}

.btn-edit {
    background: #ffc107;
    color: #333;
}

.btn-edit:hover {
    background: #e0a800;
    transform: translateY(-1px);
}

.btn-reject {
    background: #dc3545;
    color: white;
}

.btn-reject:hover {
    background: #c82333;
    transform: translateY(-1px);
}

/* AI Pending Indicator */
.ai-pending-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #ffc107;
    color: #333;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    z-index: 1001;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.notification.show {
    transform: translateX(0);
}

.notification-success {
    background: #28a745;
}

.notification-info {
    background: #17a2b8;
}

.notification-warning {
    background: #ffc107;
    color: #333;
}

/* AI Draft Badge */
.draft-badge {
    display: inline-block;
    background: #fff3cd;
    color: #856404;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
    border: 1px solid #ffc107;
}

.ai-draft {
    opacity: 0.7;
    background: #fff8e1 !important;
    border-left: 4px solid #ffc107 !important;
}

.ai-draft .message-bubble {
    background: #fffbf0 !important;
}

