/* =============================================================================
   AGENT SMITH CHAT WIDGET - AI Matric Professional Chat Interface
   ============================================================================= */

:root {
    --smith-primary: var(--teal-700, #0E6E7C);
    --smith-primary-dark: var(--teal-900, #0A4A54);
    --smith-accent: var(--orange-500, #F97316);
    --smith-accent-hover: var(--orange-600, #EA580C);
    --smith-bg: #ffffff;
    --smith-text: var(--gray-900, #111827);
    --smith-text-light: var(--gray-600, #4B5563);
    --smith-border: var(--gray-200, #E5E7EB);
    --smith-shadow: 0 20px 60px rgba(10, 74, 84, 0.25);
    --smith-radius: 20px;
    --smith-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Chat Toggle Button */
.smith-chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--smith-primary) 0%, var(--smith-primary-dark) 100%);
    border: none;
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(10, 74, 84, 0.35);
    transition: var(--smith-transition);
    overflow: visible;
}

.smith-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 40px rgba(10, 74, 84, 0.45);
}

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

.smith-chat-toggle.active {
    background: linear-gradient(135deg, var(--smith-accent) 0%, var(--smith-accent-hover) 100%);
}

.smith-toggle-icon {
    width: 32px;
    height: 32px;
    color: white;
    position: relative;
}

.smith-toggle-icon svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: var(--smith-transition);
}

.smith-icon-chat { opacity: 1; transform: scale(1) rotate(0deg); }
.smith-icon-close { opacity: 0; transform: scale(0.5) rotate(-90deg); }
.smith-chat-toggle.active .smith-icon-chat { opacity: 0; transform: scale(0.5) rotate(90deg); }
.smith-chat-toggle.active .smith-icon-close { opacity: 1; transform: scale(1) rotate(0deg); }

/* Pulse Animation */
.smith-toggle-pulse {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 50%;
    background: var(--smith-primary);
    opacity: 0;
    z-index: -1;
    animation: smithPulse 2s ease-in-out infinite;
}

@keyframes smithPulse {
    0%, 100% { transform: scale(1); opacity: 0; }
    50% { transform: scale(1.3); opacity: 0.3; }
}

.smith-chat-toggle.active .smith-toggle-pulse { animation: none; opacity: 0; }

/* Unread Badge */
.smith-toggle-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    background: var(--smith-accent);
    border-radius: 50%;
    color: white;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.4);
    transition: var(--smith-transition);
    animation: smithBadgeBounce 0.5s ease;
}

.smith-toggle-badge.hidden { transform: scale(0); opacity: 0; }

@keyframes smithBadgeBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Chat Window */
.smith-chat-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 400px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 140px);
    background: var(--smith-bg);
    border-radius: var(--smith-radius);
    box-shadow: var(--smith-shadow);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: var(--smith-transition);
}

.smith-chat-window.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Chat Header */
.smith-chat-header {
    background: linear-gradient(135deg, var(--smith-primary-dark) 0%, var(--smith-primary) 100%);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.smith-chat-header::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.5;
}

.smith-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.smith-avatar {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    backdrop-filter: blur(4px);
}

.smith-avatar svg { width: 28px; height: 28px; }

.smith-status-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    background: #10B981;
    border-radius: 50%;
    border: 2px solid var(--smith-primary-dark);
    animation: smithStatusPulse 2s ease-in-out infinite;
}

@keyframes smithStatusPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

.smith-header-text h4 {
    color: white;
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.02em;
}

.smith-header-text p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    margin: 2px 0 0;
}

.smith-header-actions {
    display: flex;
    gap: 8px;
    position: relative;
    z-index: 1;
}

.smith-header-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--smith-transition);
}

.smith-header-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.smith-header-btn svg {
    width: 18px;
    height: 18px;
    color: white;
}

/* Chat Messages */
.smith-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
    scroll-behavior: smooth;
}

.smith-chat-messages::-webkit-scrollbar { width: 6px; }
.smith-chat-messages::-webkit-scrollbar-track { background: transparent; }
.smith-chat-messages::-webkit-scrollbar-thumb {
    background: var(--smith-border);
    border-radius: 3px;
}

/* Message Bubbles */
.smith-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: smithMessageIn 0.3s ease-out;
}

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

.smith-message.user {
    flex-direction: row-reverse;
    margin-left: auto;
}

.smith-message.bot { margin-right: auto; }

.smith-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.smith-message.bot .smith-message-avatar {
    background: linear-gradient(135deg, var(--smith-primary) 0%, var(--smith-primary-dark) 100%);
    color: white;
}

.smith-message.user .smith-message-avatar {
    background: linear-gradient(135deg, var(--smith-accent) 0%, var(--smith-accent-hover) 100%);
    color: white;
}

.smith-message-avatar svg { width: 18px; height: 18px; }

.smith-message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.smith-message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.smith-message.bot .smith-message-bubble {
    background: white;
    color: var(--smith-text);
    border: 1px solid var(--smith-border);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.smith-message.user .smith-message-bubble {
    background: linear-gradient(135deg, var(--smith-primary) 0%, var(--smith-primary-dark) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.smith-message-time {
    font-size: 11px;
    color: var(--smith-text-light);
    padding: 0 4px;
}

.smith-message.user .smith-message-time { text-align: right; }

/* Typing Indicator */
.smith-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.smith-typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--smith-primary);
    border-radius: 50%;
    animation: smithTypingBounce 1.4s ease-in-out infinite;
}

.smith-typing-indicator span:nth-child(1) { animation-delay: 0s; }
.smith-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.smith-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

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

/* Quick Actions */
.smith-quick-actions {
    padding: 12px 20px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    background: white;
    border-top: 1px solid var(--smith-border);
    flex-shrink: 0;
}

.smith-quick-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #F9FAFB;
    border: 1px solid var(--smith-border);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--smith-text);
    cursor: pointer;
    transition: var(--smith-transition);
    white-space: nowrap;
}

.smith-quick-btn:hover {
    background: var(--smith-primary);
    color: white;
    border-color: var(--smith-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(14, 110, 124, 0.25);
}

.smith-quick-btn svg { width: 14px; height: 14px; }
.smith-quick-actions.hidden { display: none; }

/* Chat Input */
.smith-chat-input-container {
    padding: 16px 20px 12px;
    background: white;
    border-top: 1px solid var(--smith-border);
    flex-shrink: 0;
}

.smith-chat-form { margin: 0; }

.smith-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: #F9FAFB;
    border: 2px solid var(--smith-border);
    border-radius: 16px;
    padding: 8px 8px 8px 16px;
    transition: var(--smith-transition);
}

.smith-input-wrapper:focus-within {
    border-color: var(--smith-primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(14, 110, 124, 0.1);
}

.smith-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    color: var(--smith-text);
    resize: none;
    max-height: 120px;
    line-height: 1.5;
    padding: 6px 0;
    font-family: inherit;
}

.smith-chat-input:focus { outline: none; }
.smith-chat-input::placeholder { color: var(--smith-text-light); }

.smith-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--smith-primary) 0%, var(--smith-primary-dark) 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--smith-transition);
    flex-shrink: 0;
}

.smith-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(14, 110, 124, 0.35);
}

.smith-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.smith-send-btn svg { width: 18px; height: 18px; color: white; }

.smith-powered-by {
    text-align: center;
    font-size: 11px;
    color: var(--smith-text-light);
    margin: 10px 0 0;
}

.smith-powered-by strong { color: var(--smith-primary); }

/* Sources */
.smith-sources {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--smith-border);
}

.smith-sources-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--smith-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.smith-source-item {
    font-size: 12px;
    color: var(--smith-primary);
    padding: 4px 8px;
    background: rgba(14, 110, 124, 0.08);
    border-radius: 6px;
    margin-bottom: 4px;
    display: inline-block;
    margin-right: 4px;
}

.smith-source-item .smith-source-score {
    color: var(--smith-text-light);
    font-size: 10px;
    margin-left: 4px;
}

/* Error State */
.smith-error {
    background: #FEF2F2;
    border: 1px solid #FECACA;
    color: #DC2626;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.smith-error svg { width: 18px; height: 18px; flex-shrink: 0; }

/* Mobile Responsive */
@media (max-width: 480px) {
    .smith-chat-toggle {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }

    .smith-toggle-icon { width: 28px; height: 28px; }

    .smith-chat-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: calc(100vh - 60px);
        max-height: none;
        border-radius: var(--smith-radius) var(--smith-radius) 0 0;
        transform-origin: bottom center;
    }

    .smith-quick-actions {
        padding: 10px 16px;
        gap: 6px;
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .smith-quick-btn { padding: 6px 12px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
    .smith-chat-toggle, .smith-chat-window, .smith-message, .smith-quick-btn, .smith-send-btn {
        transition: none;
    }
    .smith-toggle-pulse, .smith-status-dot, .smith-typing-indicator span { animation: none; }
    .smith-message { animation: none; }
}
