/* Enhanced Chatbot Styles */
.chatbot-container {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 550px;
    max-height: calc(100vh - 150px);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-2xl);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 60px rgba(249, 115, 22, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chatbot-container.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}

.chatbot-header {
    padding: var(--space-4) var(--space-5);
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.chatbot-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: shimmer 3s infinite linear;
}

@keyframes shimmer {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    position: relative;
    z-index: 1;
}

.chatbot-avatar {
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    position: relative;
    backdrop-filter: blur(4px);
}

.chatbot-avatar .status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: #22c55e;
    border: 2px solid white;
    border-radius: 50%;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.chatbot-header-title {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
}

.chatbot-header-status {
    font-size: 0.75rem;
    opacity: 0.9;
    font-weight: 500;
}

.chatbot-header-actions {
    display: flex;
    gap: var(--space-1);
    position: relative;
    z-index: 1;
}

.chatbot-header-actions button {
    color: rgba(255,255,255,0.8);
    transition: all var(--transition-fast);
}

.chatbot-header-actions button:hover {
    color: white;
    transform: scale(1.1);
}

.chatbot-messages {
    flex: 1;
    padding: var(--space-4);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    background: linear-gradient(180deg, var(--bg-tertiary) 0%, var(--bg-default) 100%);
    scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: 3px;
}

.message {
    max-width: 85%;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-xl);
    font-size: 0.9rem;
    line-height: 1.55;
    position: relative;
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-bot {
    align-self: flex-start;
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.message-bot::before {
    content: '';
    position: absolute;
    left: -6px;
    bottom: 0;
    border: 6px solid transparent;
    border-right-color: var(--bg-elevated);
    border-bottom-color: var(--bg-elevated);
}

.message-user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

.message-user::before {
    content: '';
    position: absolute;
    right: -6px;
    bottom: 0;
    border: 6px solid transparent;
    border-left-color: var(--primary-500);
    border-bottom-color: var(--primary-500);
}

/* Typing indicator */
.message.typing {
    background: var(--bg-elevated);
    padding: var(--space-3) var(--space-5);
}

.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    height: 20px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--primary-400);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Quick actions bar */
.chatbot-quick-actions {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-subtle);
    overflow-x: auto;
}

.chatbot-quick-actions::-webkit-scrollbar {
    height: 0;
}

.quick-action-btn {
    flex-shrink: 0;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-glass);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.quick-action-btn:hover {
    background: var(--primary-500);
    border-color: var(--primary-500);
    color: white;
    transform: translateY(-1px);
}

.quick-action-btn i {
    font-size: 0.7rem;
}

.chatbot-input-area {
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--border-default);
    display: flex;
    gap: var(--space-2);
    background: var(--bg-elevated);
}

.chatbot-input {
    flex: 1;
    background: var(--bg-default);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    padding: var(--space-3) var(--space-4);
    font-size: 0.9rem;
    color: var(--text-primary);
    outline: none;
    transition: all var(--transition-fast);
}

.chatbot-input::placeholder {
    color: var(--text-tertiary);
}

.chatbot-input:focus {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15);
}

.chatbot-send {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

.chatbot-send:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(249, 115, 22, 0.4);
}

.chatbot-send:active {
    transform: scale(0.95);
}

.chatbot-options {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-2);
    animation: messageSlideIn 0.3s ease-out;
}

.chatbot-option {
    background: transparent;
    border: 1px solid var(--primary-400);
    color: var(--primary-400);
    padding: 8px 14px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-weight: 500;
}

.chatbot-option:hover {
    background: var(--primary-500);
    border-color: var(--primary-500);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.25);
}

/* Chatbot trigger button */
.chatbot-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 999;
    box-shadow: 0 8px 24px rgba(249, 115, 22, 0.4);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-trigger::before {
    content: '';
    position: absolute;
    inset: -4px;
    background: linear-gradient(135deg, var(--primary-400), var(--primary-600));
    border-radius: 50%;
    z-index: -1;
    opacity: 0;
    animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
    0% { transform: scale(0.8); opacity: 0.8; }
    100% { transform: scale(1.3); opacity: 0; }
}

.chatbot-trigger:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 12px 32px rgba(249, 115, 22, 0.5);
}

/* Message formatting */
.message-bot strong {
    color: var(--primary-400);
    font-weight: 600;
}

.message-bot br + br {
    display: block;
    margin: 4px 0;
}

/* CRM Dashboard Styles (kept from original) */
.crm-dashboard {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
}

.crm-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
}

.crm-content {
    position: relative;
    width: 100%;
    max-width: 1000px;
    height: 80vh;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-2xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalZoomIn 0.3s ease-out;
}

@keyframes modalZoomIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.crm-header {
    padding: var(--space-6);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.crm-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--text-primary);
}

.crm-body {
    flex: 1;
    padding: var(--space-6);
    overflow-y: auto;
}

.crm-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.crm-stat-card {
    background: var(--bg-default);
    padding: var(--space-4);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-default);
    display: flex;
    flex-direction: column;
    transition: all var(--transition-fast);
}

.crm-stat-card:hover {
    border-color: var(--primary-500);
}

.crm-stat-card .label {
    font-size: 0.875rem;
    color: var(--text-tertiary);
}

.crm-stat-card .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-500);
}

.crm-table-wrapper {
    background: var(--bg-default);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    overflow: hidden;
    margin-bottom: var(--space-6);
}

.crm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.crm-table th {
    background: var(--bg-tertiary);
    text-align: left;
    padding: var(--space-4);
    font-weight: 600;
    color: var(--text-secondary);
}

.crm-table td {
    padding: var(--space-4);
    border-top: 1px solid var(--border-default);
    color: var(--text-primary);
}

.crm-actions {
    display: flex;
    gap: var(--space-3);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border-default);
}

/* Responsive */
@media (max-width: 768px) {
    .chatbot-container {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: calc(100vh - 60px);
        max-height: calc(100vh - 60px);
        border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    }

    .chatbot-trigger {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
        font-size: 1.3rem;
    }
}