/* --- LIVE CHAT PREMIUM UI --- */

.live-chat-layout {
    display: flex;
    height: calc(100vh - 160px);
    gap: 20px;
}

.session-sidebar {
    width: 320px;
    background: white;
    border-radius: 16px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.session-sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(135deg, #0a1128 0%, #1c2541 100%);
    color: #fff;
}
.session-sidebar-header h3 { color: #cda434 !important; letter-spacing: 0.5px; }
.session-sidebar-header .badge { background: linear-gradient(135deg,#cda434,#b58e26) !important; color: #fff !important; border: none; box-shadow: 0 2px 8px rgba(205,164,52,0.3); }

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

.session-card {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    border-left: 4px solid transparent;
}

.session-card {
    background: #fff;
    border-radius: 12px;
    margin: 8px 10px;
    border: 1px solid #e2e8f0 !important;
    border-left: 4px solid transparent !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.session-card:hover {
    background: #fdfbf6;
    border-color: #fde68a !important;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(205,164,52,0.12);
}
.session-card.active {
    background: linear-gradient(135deg,#fdfbf6 0%, #fff 100%);
    border-color: #cda434 !important;
    border-left-color: #cda434 !important;
    box-shadow: 0 8px 20px rgba(205,164,52,0.15);
}
.session-card.waiting {
    border-left-color: #ef4444 !important;
    animation: pulseWaiting 2s infinite;
}
@keyframes pulseWaiting { 0%{box-shadow:0 2px 8px rgba(239,68,68,0.1)} 50%{box-shadow:0 4px 16px rgba(239,68,68,0.2)} 100%{box-shadow:0 2px 8px rgba(239,68,68,0.1)} }

.session-card .user-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
}

.session-card .meta-info {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    gap: 10px;
}

.session-card .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.dot-waiting { background: var(--danger); box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1); }
.dot-active { background: var(--success); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1); }

/* Chat Window */
.chat-window {
    flex: 1;
    background: white;
    border-radius: 16px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg,#fff 0%, #fdfbf6 100%);
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}
.chat-header h4 { color: #0a1128; }
.chat-header .badge { background: linear-gradient(135deg,#cda434,#b58e26) !important; }

.chat-display {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    background: #f8fafc;
    background-image: radial-gradient(#e2e8f0 1px, transparent 1px);
    background-size: 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.message-bubble {
    max-width: 75%;
    position: relative;
    padding: 0.875rem 1.25rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

.message-agent {
    align-self: flex-end;
    background: var(--primary);
    color: white;
    border-radius: 16px 16px 2px 16px;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
}

.message-user {
    align-self: flex-start;
    background: white;
    color: var(--text-main);
    border-radius: 16px 16px 16px 2px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.message-system {
    align-self: center;
    background: #e2e8f0;
    color: #475569;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message-meta {
    font-size: 0.7rem;
    margin-bottom: 4px;
    color: var(--text-muted);
}

.message-agent .message-meta { color: rgba(255,255,255,0.7); text-align: right; }

/* Chat Input */
.chat-input-area {
    padding: 1.25rem;
    background: white;
    border-top: 1px solid var(--border);
    position: relative; /* CRITICAL: Allows absolute child menus to position correctly */
}

.chat-input-group {
    display: flex;
    gap: 12px;
    background: #f8fafc;
    padding: 10px;
    border-radius: 16px;
    border: 1.5px solid #e2e8f0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-input-group:focus-within {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(205, 164, 52, 0.1);
    transform: translateY(-1px);
}

.chat-input-field {
    flex: 1;
    background: none;
    border: none;
    padding: 8px 12px;
    font-size: 0.95rem;
    outline: none;
    font-family: inherit;
    color: var(--text-main);
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(205, 164, 52, 0.3);
}

.chat-send-btn:hover {
    transform: scale(1.05) translateY(-1px);
    box-shadow: 0 6px 15px rgba(205, 164, 52, 0.4);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    transform: none;
    cursor: not-allowed;
}

/* AI Rephrase Button */
.ai-rephrase-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: white;
    color: #6366f1;
    border: 1.5px solid #eef2ff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ai-rephrase-btn:hover {
    background: #eef2ff;
    border-color: #6366f1;
    transform: translateY(-2px);
}

/* AI Suggest Button */
.ai-suggest-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: white;
    color: #f59e0b;
    border: 1.5px solid #fffbeb;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ai-suggest-btn:hover {
    background: #fffbeb;
    border-color: #f59e0b;
    transform: translateY(-2px);
}

/* Spills Toggle Button */
.spills-toggle-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: white;
    color: var(--primary);
    border: 1.5px solid var(--primary-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.spills-toggle-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    transform: translateY(-2px);
}

/* Suggestions & Spills Containers - Fixed Position */
.suggestions-container, .spills-container {
    position: absolute;
    bottom: calc(100% - 5px);
    left: 1.25rem;
    right: 1.25rem;
    background: white;
    border-radius: 16px 16px 4px 4px;
    border: 1px solid var(--border);
    box-shadow: 0 -15px 35px rgba(0,0,0,0.12);
    z-index: 1000;
    overflow: hidden;
    animation: luxurySlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 280px;
    display: flex;
    flex-direction: column;
}

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

.suggestions-header, .spills-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: #faf9f6;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--primary-dark);
}

.suggestions-header button, .spills-header button {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    font-size: 14px;
    transition: color 0.2s;
}

.suggestions-header button:hover, .spills-header button:hover {
    color: var(--danger);
}

.suggestions-list, .spills-list {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
}

.suggestion-item, .spill-item {
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #f1f5f9;
    border-radius: 10px;
    text-align: left;
    font-size: 13px;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1.4;
}

.suggestion-item:hover, .spill-item:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-dark);
    transform: translateX(6px);
    box-shadow: 2px 4px 12px rgba(205, 164, 52, 0.1);
}

.extra-small { font-size: 0.7rem; }

/* User Info Panel */
.user-info-panel {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-bottom: 1px solid #bae6fd;
    padding: 16px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    animation: slideDown 0.3s ease;
}

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

.user-info-name {
    font-weight: 700;
    color: #0369a1;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(3, 105, 161, 0.1);
}

.user-info-name i {
    color: #0284c7;
}

.user-info-item {
    color: #475569;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.user-info-item i {
    color: #64748b;
    width: 16px;
}

/* ========== CHAT HISTORY STYLES ========== */
.chat-history-container {
    padding: 0;
}

.history-header {
    padding: 24px 28px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid #e2e8f0;
}

.history-header h3 {
    margin: 0 0 8px 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
}

.history-header p {
    margin: 0;
    color: #64748b;
}

.history-filters {
    padding: 20px 28px;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
}

.history-list {
    padding: 20px 28px;
    max-height: calc(100vh - 250px);
    overflow-y: auto;
}

.history-empty {
    text-align: center;
    padding: 60px 20px;
}

.history-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    margin-bottom: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    overflow: hidden;
}

.history-card:hover {
    border-color: #6366f1;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.15);
    transform: translateY(-2px);
}

.history-card-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid #f1f5f9;
}

.visitor-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.visitor-avatar {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
}

.visitor-name {
    font-weight: 700;
    font-size: 16px;
    color: #1e293b;
}

.visitor-meta {
    display: flex;
    gap: 12px;
    margin-top: 4px;
    font-size: 12px;
    color: #64748b;
}

.visitor-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.session-meta {
    text-align: right;
}

.agent-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    color: #166534;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 8px;
}

.time-info {
    display: block;
    font-size: 12px;
    color: #94a3b8;
}

.history-card-footer {
    padding: 14px 20px;
    background: #f8fafc;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #64748b;
}

.message-count {
    display: flex;
    align-items: center;
    gap: 6px;
}

.view-details {
    color: #6366f1;
    font-weight: 600;
}

/* History Modal */
.history-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.history-modal-content {
    background: #fff;
    border-radius: 20px;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    animation: slideUp 0.3s ease;
}

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

.history-modal-header {
    padding: 24px 28px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
}

.history-modal-close {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: #f1f5f9;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.history-modal-close:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.history-modal-body {
    padding: 24px 28px;
    overflow-y: auto;
    flex: 1;
}

.session-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 28px;
}

.summary-section {
    background: #f8fafc;
    border-radius: 16px;
    padding: 20px;
}

.summary-section h4 {
    margin: 0 0 16px 0;
    font-size: 14px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.summary-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.summary-item .label {
    font-size: 11px;
    color: #94a3b8;
    text-transform: uppercase;
    font-weight: 600;
}

.summary-item .value {
    font-size: 14px;
    color: #1e293b;
    font-weight: 600;
}

.summary-item .value.agent-value {
    color: #166534;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    padding: 4px 10px;
    border-radius: 6px;
    display: inline-block;
}

.conversation-thread h4 {
    margin: 0 0 16px 0;
    font-size: 14px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.messages-container {
    background: #f8fafc;
    border-radius: 16px;
    padding: 20px;
    max-height: 350px;
    overflow-y: auto;
}

.history-message {
    padding: 8px 12px;
    margin: 8px 0;
    border-radius: 12px;
    font-size: 13px;
    text-align: center;
    color: #64748b;
    background: #f1f5f9;
}

.history-message-row {
    display: flex;
    margin-bottom: 16px;
}

.history-message-row.user {
    justify-content: flex-start;
}

.history-message-row.agent {
    justify-content: flex-end;
}

.history-message-bubble {
    max-width: 70%;
    padding: 14px 18px;
    border-radius: 18px;
    position: relative;
}

.history-message-row.user .history-message-bubble {
    background: #f1f5f9 !important;
    border: 1px solid #cbd5e1 !important;
    border-bottom-left-radius: 4px;
    color: #000000 !important; /* ABSOLUTE BLACK */
}

.history-message-row.user .message-content {
    color: #000000 !important; /* ABSOLUTE BLACK */
}

.history-message-row.agent .history-message-bubble {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(205, 164, 52, 0.2);
}

.message-sender {
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 6px;
    opacity: 0.8;
}

.history-message-row.agent .message-sender {
    color: rgba(255,255,255,0.9);
}

.message-content {
    font-size: 14px;
    line-height: 1.5;
}

.message-time {
    font-size: 10px;
    margin-top: 8px;
    opacity: 0.6;
    text-align: right;
}

.history-message-row.agent .message-time {
    color: rgba(255,255,255,0.8);
}

@media (max-width: 768px) {
    .session-summary {
        grid-template-columns: 1fr;
    }
    
    .history-card-header {
        flex-direction: column;
        gap: 16px;
    }
    
    .session-meta {
        text-align: left;
    }
}

/* History Type Toggle */
.history-type-toggle {
    display: flex;
    gap: 10px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 12px;
}

.history-type-toggle .btn {
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    transition: all 0.2s;
}

.history-type-toggle .btn.active {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.bg-soft-info {
    background: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%) !important;
}

.text-info { color: #0284c7 !important; }
.border-info { border-color: #0ea5e9 !important; }

/* AI Bubble in History */
.ai-bubble {
    background: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%) !important;
    color: white !important;
}

.ai-bubble .message-sender {
    color: rgba(255, 255, 255, 0.9) !important;
}

.ai-bubble .message-time {
    color: rgba(255, 255, 255, 0.8) !important;
}

/* Luxury History Modal Enhancements */
.luxury-modal {
    border-top: 4px solid var(--primary);
    overflow: hidden;
}

.modal-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.conversation-participants {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}

.participant {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
}

.participant.user {
    background: #f1f5f9;
    color: #475569;
}

.participant.agent {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.separator {
    color: #cbd5e1;
    font-size: 0.75rem;
}

.message-time-small {
    font-weight: normal;
    opacity: 0.7;
    margin-left: 6px;
    font-size: 0.65rem;
}

.history-modal-footer {
    padding: 16px 28px;
    background: #faf9f6;
    border-top: 1px solid #e2e8f0;
}

.session-info-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.session-info-pills .pill {
    font-size: 0.75rem;
    color: #64748b;
    background: white;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.history-message-row.agent .history-message-bubble {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(205, 164, 52, 0.2);
}

.ai-bubble {
    background: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%) !important;
}
