/* ==========================================
   CHATBOT FLOATING WIDGET STYLES
   ========================================== */

:root {
    --chat-primary: #0F6BF1;
    --chat-primary-light: #1e7bff;
    --chat-bg: #0a0f1e;
    --chat-card: #0f1729;
    --chat-border: rgba(255, 255, 255, 0.08);
    --chat-text: #ffffff;
    --chat-text-muted: #b0b9d4;
    --chat-success: #009331;
    --chat-purple: #a855f7;
    --transition: all 0.25s ease;
}

/* ===== FLOATING CHAT WIDGET ===== */

#chatWidget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: 'Inter', sans-serif;
}

/* Chat Toggle Button */
.chat-toggle-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-light) 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(15, 107, 241, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    animation: chatPulse 2s ease-in-out infinite;
}

.chat-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 35px rgba(15, 107, 241, 0.5);
}

.chat-toggle-btn svg {
    width: 24px;
    height: 24px;
    color: white;
}

@keyframes chatPulse {
    0%, 100% { box-shadow: 0 8px 25px rgba(15, 107, 241, 0.4); }
    50% { box-shadow: 0 8px 35px rgba(15, 107, 241, 0.6); }
}

/* Chat Panel */
.chat-panel {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    background: var(--chat-card);
    border: 1px solid var(--chat-border);
    border-radius: 16px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: scale(0.8) translateY(20px);
    pointer-events: none;
    transition: var(--transition);
}

.chat-panel.active {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}

/* Chat Header */
.chat-header {
    padding: 16px;
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-light) 100%);
    border-radius: 16px 16px 0 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.chat-header-info {
    flex: 1;
}

.chat-header-title {
    font-weight: 600;
    color: white;
    margin: 0;
    font-size: 14px;
}

.chat-header-status {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
}

/* Messages Container */
.chat-messages {
    flex: 1;
    min-height: 200px;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Message Bubbles */
.message {
    display: flex;
    gap: 8px;
    animation: messageSlideIn 0.3s ease-out;
}

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

.message.user {
    justify-content: flex-end;
}

.message.bot {
    justify-content: flex-start;
}

.message-content {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
}

.message.user .message-content {
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-light) 100%);
    color: white;
    border: 1px solid rgba(15, 107, 241, 0.3);
}

.message.bot .message-content {
    background: rgba(168, 85, 247, 0.1);
    color: var(--chat-text-muted);
    border: 1px solid rgba(168, 85, 247, 0.2);
}

.message.admin .message-content {
    background: rgba(0, 147, 49, 0.1);
    color: #4ade80;
    border: 1px solid rgba(0, 147, 49, 0.2);
}

.message-time {
    font-size: 11px;
    color: var(--chat-text-muted);
    align-self: flex-end;
    margin-top: 4px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid rgba(168, 85, 247, 0.2);
    border-radius: 12px;
    width: fit-content;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--chat-text-muted);
    animation: typingBounce 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% { opacity: 0.5; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-8px); }
}

/* Suggestions */
.chat-suggestions {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
    border-top: 1px solid var(--chat-border);
}

.suggestion-chip {
    padding: 8px 12px;
    background: rgba(15, 107, 241, 0.1);
    border: 1px solid rgba(15, 107, 241, 0.3);
    border-radius: 20px;
    color: var(--chat-primary-light);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.suggestion-chip:hover {
    background: rgba(15, 107, 241, 0.2);
    border-color: var(--chat-primary);
}

/* Input Area */
.chat-input-area {
    padding: 12px;
    border-top: 1px solid var(--chat-border);
    display: flex;
    gap: 8px;
    background: var(--chat-card);
    border-radius: 0 0 16px 16px;
}

#chatInput {
    flex: 1;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--chat-border);
    border-radius: 8px;
    color: var(--chat-text);
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    transition: var(--transition);
}

#chatInput::placeholder {
    color: var(--chat-text-muted);
}

#chatInput:focus {
    outline: none;
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 3px rgba(15, 107, 241, 0.1);
    background: rgba(255, 255, 255, 0.08);
}

#chatSendBtn {
    width: 36px;
    height: 36px;
    padding: 0;
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-light) 100%);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

#chatSendBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(15, 107, 241, 0.3);
}

#chatSendBtn:active {
    transform: translateY(0);
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .chat-panel {
        width: calc(100vw - 32px);
        height: calc(100vh - 120px);
        bottom: 80px;
        right: 16px;
    }

    .message-content {
        max-width: 85%;
    }
}

/* ==========================================
   ADMIN CHATBOT DASHBOARD STYLES
   ========================================== */

.chatbot-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #0f1729;
    border: 1px solid #1e2d4a;
    border-radius: 12px;
    padding: 20px;
    border-left: 4px solid transparent;
    transition: all 0.3s ease;
}

.stat-card:hover {
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 1px rgba(15, 107, 241, 0.25);
}

.stat-card.total {
    border-left-color: #0F6BF1;
}

.stat-card.active {
    border-left-color: #00d4ff;
}

.stat-card.resolved {
    border-left-color: var(--chat-success);
}

.stat-card.escalated {
    border-left-color: #ff9f1c;
}

.stat-label {
    font-size: 12px;
    color: #8899b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: #e2e8f0;
}

.stat-subtext {
    font-size: 11px;
    color: #8899b8;
    margin-top: 6px;
}

/* Chat Sessions Table */
.chat-sessions-section {
    background: #0f1729;
    border: 1px solid #1e2d4a;
    border-radius: 12px;
    overflow: hidden;
}

.chat-controls {
    padding: 16px;
    border-bottom: 1px solid #1e2d4a;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.chat-search-input {
    flex: 1;
    min-width: 250px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #1e2d4a;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 13px;
}

.chat-search-input::placeholder {
    color: #8899b8;
}

.chat-search-input:focus {
    outline: none;
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 3px rgba(15, 107, 241, 0.1);
}

.chat-filter-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.chat-filter-tab {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid #1e2d4a;
    border-radius: 6px;
    color: #8899b8;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

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

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

/* Sessions Table */
.chat-sessions-table {
    width: 100%;
    border-collapse: collapse;
}

.chat-sessions-table thead {
    background: #0d1526;
}

.chat-sessions-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: #8899b8;
    border-bottom: 1px solid #1e2d4a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-sessions-table tr {
    border-bottom: 1px solid #1e2d4a;
    transition: var(--transition);
}

.chat-sessions-table tr:hover {
    background: rgba(15, 107, 241, 0.05);
}

.chat-sessions-table td {
    padding: 12px 16px;
    color: #e2e8f0;
    font-size: 13px;
}

.chat-session-row {
    cursor: pointer;
}

.session-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-purple) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 12px;
}

.session-info-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.session-info {
    display: flex;
    flex-direction: column;
}

.session-name {
    font-weight: 500;
    color: #e2e8f0;
}

.session-email {
    font-size: 11px;
    color: #8899b8;
}

.unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--chat-primary);
    flex-shrink: 0;
}

.session-service {
    display: inline-block;
    padding: 4px 8px;
    background: rgba(15, 107, 241, 0.1);
    border: 1px solid rgba(15, 107, 241, 0.2);
    border-radius: 4px;
    font-size: 11px;
    color: var(--chat-primary-light);
}

.session-status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.session-status-active {
    background: rgba(0, 212, 255, 0.15);
    color: #00d4ff;
}

.session-status-resolved {
    background: rgba(0, 147, 49, 0.15);
    color: #4ade80;
}

.session-status-escalated {
    background: rgba(255, 159, 28, 0.15);
    color: #ffb84d;
}

.session-actions {
    display: flex;
    gap: 8px;
}

.session-action-btn {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid #1e2d4a;
    border-radius: 6px;
    color: #8899b8;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.session-action-btn:hover {
    border-color: var(--chat-primary);
    color: var(--chat-primary-light);
}

/* Empty State */
.chat-empty-state {
    padding: 48px 24px;
    text-align: center;
    color: #8899b8;
}

.chat-empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* Session Detail View */
.chat-session-detail {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    padding: 20px;
}

.chat-session-info {
    background: #0f1729;
    border: 1px solid #1e2d4a;
    border-radius: 12px;
    padding: 16px;
    height: fit-content;
    position: sticky;
    top: 100px;
}

.chat-session-info-title {
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 12px;
    font-size: 14px;
}

.chat-session-info-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 0;
    border-bottom: 1px solid #1e2d4a;
}

.chat-session-info-row:last-child {
    border-bottom: none;
}

.chat-session-info-label {
    font-size: 11px;
    color: #8899b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-session-info-value {
    color: #e2e8f0;
    font-size: 13px;
    word-break: break-all;
}

/* Message Thread */
.chat-messages-thread {
    background: #0f1729;
    border: 1px solid #1e2d4a;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    height: 600px;
}

.chat-thread-header {
    padding: 16px;
    border-bottom: 1px solid #1e2d4a;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-thread-title {
    font-weight: 600;
    color: #e2e8f0;
}

.chat-status-selector {
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #1e2d4a;
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 12px;
    cursor: pointer;
}

.chat-thread-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-thread-message {
    display: flex;
    gap: 8px;
}

.chat-thread-message.user {
    justify-content: flex-end;
}

.chat-thread-message.admin {
    justify-content: flex-end;
}

.chat-thread-message.bot {
    justify-content: flex-start;
}

.chat-thread-message-bubble {
    max-width: 60%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
}

.chat-thread-message.user .chat-thread-message-bubble {
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-light) 100%);
    color: white;
}

.chat-thread-message.bot .chat-thread-message-bubble {
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid rgba(168, 85, 247, 0.2);
    color: var(--chat-text-muted);
}

.chat-thread-message.admin .chat-thread-message-bubble {
    background: rgba(0, 147, 49, 0.1);
    border: 1px solid rgba(0, 147, 49, 0.2);
    color: #4ade80;
}

.chat-thread-reply-form {
    padding: 16px;
    border-top: 1px solid #1e2d4a;
    display: flex;
    gap: 8px;
}

.chat-thread-textarea {
    flex: 1;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #1e2d4a;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    resize: none;
    min-height: 40px;
}

.chat-thread-textarea::placeholder {
    color: #8899b8;
}

.chat-thread-textarea:focus {
    outline: none;
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 3px rgba(15, 107, 241, 0.1);
}

.chat-thread-send-btn {
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-light) 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.chat-thread-send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(15, 107, 241, 0.3);
}

/* Pagination */
.chat-pagination {
    padding: 16px;
    border-top: 1px solid #1e2d4a;
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.chat-page-btn {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid #1e2d4a;
    border-radius: 6px;
    color: #8899b8;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.chat-page-btn:hover {
    border-color: var(--chat-primary);
    color: var(--chat-primary-light);
}

.chat-page-btn.active {
    background: var(--chat-primary);
    border-color: var(--chat-primary);
    color: white;
}

.chat-page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
