/**
 * Cuttalo AI Chat Widget Styles
 */

:root {
    --cuttalo-primary: #2563eb;
    --cuttalo-primary-dark: #1d4ed8;
    --cuttalo-secondary: #64748b;
    --cuttalo-success: #10b981;
    --cuttalo-error: #ef4444;
    --cuttalo-bg: #ffffff;
    --cuttalo-bg-secondary: #f8fafc;
    --cuttalo-border: #e2e8f0;
    --cuttalo-text: #1e293b;
    --cuttalo-text-secondary: #64748b;
    --cuttalo-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Chat Widget Container */
.cuttalo-ai-chat-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.cuttalo-ai-chat-widget[data-position="bottom-right"] {
    bottom: 20px;
    right: 20px;
}

.cuttalo-ai-chat-widget[data-position="bottom-left"] {
    bottom: 20px;
    left: 20px;
}

/* Chat Button */
.cuttalo-ai-chat-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--cuttalo-primary);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: var(--cuttalo-shadow);
    transition: all 0.3s ease;
    position: relative;
}

.cuttalo-ai-chat-button:hover {
    background: var(--cuttalo-primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 25px 30px -5px rgba(0, 0, 0, 0.15);
}

.chat-button-icon {
    display: flex;
    align-items: center;
}

.chat-notification {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--cuttalo-error);
    color: white;
    font-size: 12px;
    font-weight: bold;
    min-width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Chat Window */
.cuttalo-ai-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    background: var(--cuttalo-bg);
    border-radius: 16px;
    box-shadow: var(--cuttalo-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.cuttalo-ai-chat-widget[data-position="bottom-left"] .cuttalo-ai-chat-window {
    right: auto;
    left: 0;
}

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

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--cuttalo-primary);
    color: white;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    padding: 2px;
}

.chat-header-text h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--cuttalo-success);
    display: inline-block;
}

.chat-close {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Messages Container */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--cuttalo-bg-secondary);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--cuttalo-border);
    border-radius: 3px;
}

/* Messages */
.chat-message {
    display: flex;
    gap: 12px;
    animation: fadeIn 0.3s ease;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
}

.message-content {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 80%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.message-content p {
    margin: 0;
    color: var(--cuttalo-text);
    font-size: 14px;
    line-height: 1.5;
}

/* Product/Service Link Cards */
.message-content .link-card {
    display: block;
    text-decoration: none;
    background: white;
    border: 1px solid var(--cuttalo-border);
    border-radius: 12px;
    padding: 16px;
    margin: 12px 0;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    position: relative;
}

.message-content .link-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(37, 99, 235, 0.15);
    border-color: var(--cuttalo-primary);
}

.link-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.link-card-info {
    flex: 1;
    min-width: 0;
}

.link-card-subtitle {
    display: block;
    font-size: 12px;
    color: var(--cuttalo-text-secondary);
    font-weight: 400;
    margin-top: 2px;
}

.link-card-image {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--cuttalo-bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.link-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.link-card-icon {
    width: 60px;
    height: 60px;
    background: var(--cuttalo-primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    flex-shrink: 0;
}

.link-card-title {
    font-weight: 600;
    color: var(--cuttalo-text);
    font-size: 16px;
    margin: 0;
}

.link-card-description {
    color: var(--cuttalo-text-secondary);
    font-size: 14px;
    margin: 0;
    line-height: 1.4;
}

.link-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--cuttalo-border);
}

.link-card-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.link-card-stock {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.link-card-stock.in-stock {
    background: #dcfce7;
    color: #166534;
}

.link-card-stock.out-of-stock {
    background: #fee2e2;
    color: #dc2626;
}

.link-card-stock.limited-stock {
    background: #fef3c7;
    color: #d97706;
}

.link-card-price {
    background: var(--cuttalo-success);
    color: white;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
}

.link-card-cta {
    background: var(--cuttalo-primary);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    display: inline-block;
    text-decoration: none;
}

.link-card-cta:hover {
    background: var(--cuttalo-primary-dark);
    transform: scale(1.05);
}

/* Simple text links (fallback) */
.message-content a:not(.link-card) {
    color: var(--cuttalo-primary);
    text-decoration: none;
    font-weight: 600;
    padding: 2px 4px;
    border-radius: 4px;
    background: rgba(37, 99, 235, 0.1);
    transition: all 0.2s ease;
}

.message-content a:not(.link-card):hover {
    background: var(--cuttalo-primary);
    color: white;
}

/* Call-to-action buttons styling */
.message-content strong {
    color: var(--cuttalo-primary);
    font-weight: 700;
}

/* Lists in messages */
.message-content ul,
.message-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.message-content li {
    margin: 4px 0;
    line-height: 1.4;
}

/* Code and technical info */
.message-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

/* Price highlighting */
.message-content .price {
    background: var(--cuttalo-success);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

/* Sections in responses */
.message-content br + strong {
    display: block;
    margin-top: 12px;
    margin-bottom: 4px;
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .message-content {
    background: var(--cuttalo-primary);
    color: white;
}

.user-message .message-avatar {
    display: none;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.quick-action {
    padding: 8px 16px;
    background: white;
    border: 1px solid var(--cuttalo-border);
    border-radius: 20px;
    font-size: 13px;
    color: var(--cuttalo-text);
    cursor: pointer;
    transition: all 0.2s;
}

.quick-action:hover {
    background: var(--cuttalo-primary);
    color: white;
    border-color: var(--cuttalo-primary);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 12px;
    padding: 0 20px 20px;
    background: var(--cuttalo-bg-secondary);
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--cuttalo-secondary);
    animation: typing 1.4s infinite;
}

.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% {
        opacity: 0.3;
    }
    30% {
        opacity: 1;
    }
}

/* Input Area */
.chat-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid var(--cuttalo-border);
}

.chat-form {
    margin: 0;
}

.input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.message-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--cuttalo-border);
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.message-input:focus {
    border-color: var(--cuttalo-primary);
}

.send-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--cuttalo-primary);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.send-button:hover {
    background: var(--cuttalo-primary-dark);
    transform: scale(1.05);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-button svg {
    transform: rotate(-90deg);
}

/* Footer */
.chat-footer {
    text-align: center;
    padding: 8px;
}

.chat-footer p {
    margin: 0;
    font-size: 11px;
    color: var(--cuttalo-text-secondary);
}

/* Responsive */
@media (max-width: 480px) {
    .cuttalo-ai-chat-widget {
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
    }
    
    .cuttalo-ai-chat-window {
        width: 100% !important;
        height: 100vh !important;
        bottom: 0;
        border-radius: 0;
    }
    
    .cuttalo-ai-chat-button {
        width: calc(100% - 40px);
        margin: 0 20px 20px;
        justify-content: center;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --cuttalo-bg: #1e293b;
        --cuttalo-bg-secondary: #0f172a;
        --cuttalo-border: #334155;
        --cuttalo-text: #e2e8f0;
        --cuttalo-text-secondary: #94a3b8;
    }
    
    .message-content {
        background: #334155;
    }
    
    .quick-action {
        background: #334155;
        border-color: #475569;
    }
}