﻿/* ===== STOCK CHAT WIDGET STYLES ===== */
#stock-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    z-index: 10000;
    direction: ltr;
}

/* Chat Toggle Button */
.chat-toggle {
    position: relative;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #5f61e6, #2c2fde);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: white;
}

.chat-toggle:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 35px rgba(59, 130, 246, 0.6);
}

.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Chat Window */
.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 500px;
    height: 650px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.chat-window.open {
    display: flex;
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #5f61e6, #2c2fde);
    color: white;
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.avatar img {
    width: 24px !important;
    height: 24px !important;
}

.title {
    font-weight: 600;
    font-size: 16px;
}

.subtitle {
    font-size: 12px;
    opacity: 0.8;
}

.chat-controls {
    display: flex;
    gap: 8px;
}

.control-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8fafc;
}

.message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: messageIn 0.3s ease-out;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.bot-message .message-avatar {
    background: linear-gradient(135deg, #2c2fde, #5f61e6);
    color: white;
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.user-message .message-content {
    text-align: right;
}

/* Message content styling for Markdown */
.message-text {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    word-wrap: break-word;
    line-height: 1.4;
}

.message-text.allow-break {
    white-space: pre-line;
}

.message-text h1, .message-text h2, .message-text h3 {
    margin: 8px 0 4px 0;
    color: #1f2937;
    font-weight: 600;
}

.message-text h1 { font-size: 18px; }
.message-text h2 { font-size: 16px; }
.message-text h3 { font-size: 14px; }

.message-text p {
    margin: 8px 0 !important;
}

.message-text strong {
    font-weight: 600;
    color: #5f61e6;
}

.message-text em {
    font-style: italic;
    color: #374151;
}

.message-text ul, .message-text ol {
    margin: 8px 0;
    padding-left: 20px;
}

.message-text li {
    margin: 4px 0;
}

.message-text blockquote {
    border-left: 3px solid #2c2fde;
    padding-left: 12px;
    margin: 8px 0;
    color: #6b7280;
    font-style: italic;
}

.message-text code {
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    color: #dc2626;
}

.message-text pre {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    overflow-x: auto;
}

.message-text pre code {
    background: none;
    padding: 0;
    color: #374151;
}

.message-text a {
    color: #2c2fde;
    text-decoration: underline;
}

.message-text a:hover {
    color: #5f61e6;
}

.message-text table {
    border-collapse: collapse;
    width: 100%;
    margin: 8px 0;
    font-size: 13px;
}

.message-text th, .message-text td {
    border: 1px solid #e5e7eb;
    padding: 6px 8px;
    text-align: left;
}

.message-text th {
    background: #f9fafb;
    font-weight: 600;
}

.user-message .message-text {
    background: linear-gradient(135deg, #2c2fde, #5f61e6);
    color: white;
}

.message-time {
    font-size: 11px;
    color: #6b7280;
    margin-top: 4px;
    padding: 0 4px;
}

.user-message .message-time {
    text-align: right;
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    padding: 0 20px 20px;
    align-items: center;
    gap: 12px;
}

.typing-indicator.show {
    display: flex;
}

.typing-dots {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0px);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Quick Actions */
.quick-actions {
    padding: 0 20px 15px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.quick-action {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 20px;
    padding: 8px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.quick-action:hover {
    border-color: #2c2fde;
    background: #eff6ff;
    transform: translateY(-1px);
}

/* Chat Input */
.chat-input-container {
    padding: 20px;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 25px;
    padding: 4px 4px 4px 16px;
    transition: border-color 0.2s;
}

.chat-input-wrapper:focus-within {
    border-color: #2c2fde;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#chat-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px;
    font-size: 14px;
    outline: none;
    color: #1f2937;
}

#chat-input::placeholder {
    color: #9ca3af;
}

.send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #2c2fde;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.send-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

.send-btn:not(:disabled):hover {
    background: #5f61e6;
    transform: scale(1.05);
}

.input-footer {
    text-align: center;
    margin-top: 8px;
}

.input-footer small {
    color: #6b7280;
    font-size: 11px;
}

/* Responsive Design */
@media (max-width: 480px) {
    #stock-chat-widget {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }

    .chat-window {
        width: 100%;
        height: 70vh;
        max-height: 500px;
        bottom: 80px;
        right: 0;
        left: 0;
    }

    .quick-actions {
        overflow-x: auto;
        flex-wrap: nowrap;
    }
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Quick Actions - Horizontal Scrollable with Fade */
.quick-actions {
    padding: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: nowrap; /* Force single line */
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* Internet Explorer 10+ */
    position: relative;
    /* Add fade gradient overlay */
    mask-image: linear-gradient(
            to right,
            transparent 0px,
            black 20px,
            black calc(100% - 20px),
            transparent 100%
    );
    -webkit-mask-image: linear-gradient(
            to right,
            transparent 0px,
            black 20px,
            black calc(100% - 20px),
            transparent 100%
    );
}

/* Hide scrollbar for Chrome, Safari and Opera */
.quick-actions::-webkit-scrollbar {
    display: none;
}

/* Alternative fade-out using pseudo-elements (if mask not supported) */
.quick-actions::before,
.quick-actions::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 15px; /* Match padding-bottom */
    width: 20px;
    pointer-events: none;
    z-index: 1;
}

.quick-actions::before {
    left: 0;
    background: linear-gradient(to right, #f8fafc, transparent);
}

.quick-actions::after {
    right: 0;
    background: linear-gradient(to left, #f8fafc, transparent);
}

.quick-action {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 20px;
    padding: 8px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0; /* Prevent shrinking */
    min-width: fit-content;
}

.quick-action:hover {
    border-color: #2c2fde;
    background: #eff6ff;
    transform: translateY(-1px);
}

/* Mobile optimizations */
@media (max-width: 480px) {
    .quick-actions {
        padding: 0 15px 15px;
        gap: 6px;
        /* Adjust fade for mobile */
        mask-image: linear-gradient(
                to right,
                transparent 0px,
                black 15px,
                black calc(100% - 15px),
                transparent 100%
        );
        -webkit-mask-image: linear-gradient(
                to right,
                transparent 0px,
                black 15px,
                black calc(100% - 15px),
                transparent 100%
        );
    }

    .quick-actions::before,
    .quick-actions::after {
        width: 15px;
    }

    .quick-actions::before {
        background: linear-gradient(to right, #f8fafc, transparent);
    }

    .quick-actions::after {
        background: linear-gradient(to left, #f8fafc, transparent);
    }

    .quick-action {
        padding: 6px 10px;
        font-size: 11px;
    }
}

#chat-send:dir(rtl) svg {
    -webkit-transform: scale(-1);
    -moz-transform: scale(-1);
    -o-transform: scale(-1);
    transform: scale(-1);
}