/* SM8-IA Chat Widget Styles */

/* ============================================
   CSS Variables - Color Customization
   Defaults can be overridden by agent config
   ============================================ */
:root {
    --chat-primary: #007bff;
    --chat-primary-dark: #0056b3;
    --chat-primary-light: #0099ff;
}

.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.chat-toggle {
    width: 60px;
    height: 60px;
    background: var(--chat-primary);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,123,255,0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center; 
}

.chat-toggle:hover {
    background: var(--chat-primary-dark);
    transform: scale(1.05);
}

.chat-window {
    display: none;
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 450px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    flex-direction: column;
    overflow: hidden;
}

.chat-window.active {
    display: flex;
    animation: slideUp 0.3s ease;
}

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

.chat-header {
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
}

.chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.chat-status-indicator {
    width: 8px;
    height: 8px;
    background: #28a745;
    border-radius: 50%;
    margin-right: 5px;
}

.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f8f9fa;
}

.message {
    margin-bottom: 15px;
    display: flex;
    align-items: flex-end;
}

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

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

.message-bubble {
    max-width: 250px;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.message.user .message-bubble {
    background: var(--chat-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.agent .message-bubble {
    background: white;
    color: #333;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: #6c757d;
    margin: 5px 10px 0;
}

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

.message.agent .message-time {
    text-align: left;
}

.chat-input {
    padding: 15px;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 10px;
}

.chat-input input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

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

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

.chat-send:hover {
    background: var(--chat-primary-dark);
}

.chat-send:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.typing-indicator {
    display: none;
    padding: 10px 14px;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 18px;
    margin-bottom: 15px;
    max-width: 60px;
}

.typing-indicator.active {
    display: block;
}

.typing-dots {
    display: flex;
    align-items: center;
    height: 16px;
}

.typing-dot {
    width: 4px;
    height: 4px;
    background: #6c757d;
    border-radius: 50%;
    margin-right: 3px;
    animation: typingDot 1.5s infinite;
}

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

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

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

.chat-error {
    background: #f8d7da;
    color: #721c24;
    padding: 10px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 10px;
    text-align: center;
}

.chat-welcome {
    text-align: center;
    color: #6c757d;
    font-size: 13px;
    margin-bottom: 15px;
    padding: 10px;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .chat-widget {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }

    .chat-window {
        width: 100%;
        height: 70vh;
        max-height: 500px;
        right: auto;
        left: 0;
    }

    .message-bubble {
        max-width: 200px;
    }
}

/* Accessibility */
.chat-toggle:focus,
.chat-send:focus,
.chat-close:focus {
    outline: 2px solid var(--chat-primary);
    outline-offset: 2px;
}

.chat-input input:focus {
    box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .chat-window {
        background: #2d3748;
        color: #e2e8f0;
    }

    .chat-messages {
        background: #1a202c;
    }

    .message.agent .message-bubble {
        background: #4a5568;
        color: #e2e8f0;
        border-color: #4a5568;
    }

    .chat-input {
        background: #2d3748;
        border-color: #4a5568;
    }

    .chat-input input {
        background: #4a5568;
        color: #e2e8f0;
        border-color: #4a5568;
    }

    .typing-indicator {
        background: #4a5568;
        border-color: #4a5568;
    }
}

/* ============================================
   Chat Cards - Glassmorphism Design (Tier 2)
   Frosted glass effect with blur and luminous borders
   Compact version optimized for 350px chat widget
   ============================================ */

.chat-card {
    /* Glassmorphism: Semi-transparent background with blur */
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);

    /* Luminous border */
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 16px;

    /* Premium shadow with glow effect */
    box-shadow:
        0 6px 24px rgba(0, 123, 255, 0.1),
        0 3px 12px rgba(0, 0, 0, 0.05),
        inset 0 -1px 3px rgba(255, 255, 255, 0.6);

    overflow: hidden;
    margin: 10px 0;
    max-width: 260px;

    /* Smooth transitions */
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-card:hover {
    /* Elevate with enhanced glow */
    transform: translateY(-3px) scale(1.015);
    box-shadow:
        0 8px 28px rgba(0, 123, 255, 0.18),
        0 5px 16px rgba(0, 0, 0, 0.07),
        inset 0 -1px 3px rgba(255, 255, 255, 0.8);

    /* Enhance border glow */
    border-color: rgba(0, 123, 255, 0.3);
}

/* Card Image - Compact for chat */
.card-image {
    width: 100%;
    height: 110px;
    overflow: hidden;
    position: relative;

    /* Gradient overlay for depth */
    background: linear-gradient(135deg, rgba(0, 123, 255, 0.05) 0%, rgba(0, 200, 255, 0.05) 100%);

    display: flex;
    align-items: center;
    justify-content: center;
}

.card-image::after {
    /* Subtle inner glow */
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.1) 100%);
    pointer-events: none;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-card:hover .card-image img {
    transform: scale(1.05);
}

/* Service Card Icon - Compact */
.card-icon {
    width: 54px;
    height: 54px;
    margin: 16px auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;

    /* Glassmorphism circle */
    background: rgba(0, 123, 255, 0.1);
    border-radius: 50%;
    border: 1px solid rgba(0, 123, 255, 0.2);
    padding: 10px;

    transition: all 0.3s ease;
}

.chat-card:hover .card-icon {
    background: rgba(0, 123, 255, 0.15);
    border-color: rgba(0, 123, 255, 0.4);
    transform: scale(1.05);
}

.card-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 123, 255, 0.2));
}

/* Intro text before cards */
.card-intro-text {
    margin: 0 0 12px 0;
    padding: 0;
    font-size: 14px;
    line-height: 1.5;
    /*color: #2d3748;*/
}

/* Error message when JSON parsing fails */
.card-error {
    background: linear-gradient(135deg, #fee 0%, #fdd 100%);
    border-left: 4px solid #f44;
    padding: 14px 16px;
    border-radius: 10px;
    color: #c33;
    font-weight: 500;
    font-size: 13px;
    line-height: 1.5;
    margin: 8px 0;
    box-shadow: 0 2px 8px rgba(255, 68, 68, 0.15);
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.card-error::before {
    content: '⚠️ ';
    font-size: 16px;
    margin-right: 6px;
}

/* Dark mode for error */
@media (prefers-color-scheme: dark) {
    .card-error {
        background: linear-gradient(135deg, rgba(255, 68, 68, 0.15) 0%, rgba(255, 68, 68, 0.20) 100%);
        border-left-color: #f66;
        color: #faa;
        box-shadow: 0 2px 8px rgba(255, 68, 68, 0.25);
    }
}

/* Card Content - Compact padding */
.card-content {
    padding: 14px 16px;
}

.card-title {
    margin: 0 0 8px 0;
    font-size: 14.5px;
    font-weight: 700;
    background: linear-gradient(135deg, #1a1a1a 0%, #333 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.3;
    letter-spacing: -0.02em;
}

.card-description {
    margin: 0 0 10px 0;
    font-size: 12.5px;
    color: rgba(0, 0, 0, 0.7);
    line-height: 1.5;
}

/* Card Features List - Compact */
.card-features {
    margin: 10px 0;
    padding-left: 0;
    list-style: none;
    font-size: 12px;
    color: rgba(0, 0, 0, 0.7);
}

.card-features li {
    margin-bottom: 6px;
    padding-left: 20px;
    position: relative;
    line-height: 1.4;
}

.card-features li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--chat-primary);
    font-weight: 700;
    font-size: 10px;
    background: rgba(0, 123, 255, 0.1);
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Card Price - Compact */
.card-price {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 10px;
    padding: 10px 12px;
    background: linear-gradient(135deg, rgba(0, 123, 255, 0.08) 0%, rgba(0, 200, 255, 0.08) 100%);
    border-radius: 10px;
    border: 1px solid rgba(0, 123, 255, 0.15);
}

.card-price .price {
    font-size: 19px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.03em;
}

.card-price .price::before {
    content: '€';
    font-size: 13px;
    margin-right: 1px;
    opacity: 0.8;
}

.card-price .old-price {
    font-size: 13px;
    color: rgba(0, 0, 0, 0.4);
    text-decoration: line-through;
    font-weight: 500;
}

.card-price .old-price::before {
    content: '€';
    font-size: 10px;
    margin-right: 1px;
}

/* Card Actions (Buttons) - Glassmorphism Style - Compact */
.card-actions {
    padding: 12px 16px 16px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.card-button {
    flex: 1;
    min-width: 95px;
    padding: 9px 16px;
    text-align: center;
    text-decoration: none;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-block;
    position: relative;
    overflow: hidden;

    /* Glassmorphism button - Primary */
    background: linear-gradient(135deg, rgba(0, 123, 255, 0.9) 0%, rgba(0, 200, 255, 0.9) 100%);
    backdrop-filter: blur(10px);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow:
        0 3px 12px rgba(0, 123, 255, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);

    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-button::before {
    /* Shine effect */
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.card-button:hover::before {
    left: 100%;
}

.card-button:hover {
    transform: translateY(-1.5px) scale(1.015);
    box-shadow:
        0 5px 18px rgba(0, 123, 255, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
    border-color: rgba(255, 255, 255, 0.5);
}

.card-button:active {
    transform: translateY(0) scale(0.98);
}

.card-button.secondary {
    /* Glassmorphism button - Secondary */
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    color: var(--chat-primary);
    border: 1px solid rgba(0, 123, 255, 0.3);
    box-shadow:
        0 3px 12px rgba(0, 0, 0, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.card-button.secondary:hover {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 123, 255, 0.5);
    box-shadow:
        0 5px 18px rgba(0, 123, 255, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 1);
}

/* Compact Product Cards (no image) - Ultra minimal like quick replies */
.chat-card.product-card:not(:has(.card-image)) {
    max-width: 100%;
    padding: 12px 14px;
    margin: 8px 0;
    border-radius: 14px;
}

.chat-card.product-card:not(:has(.card-image)) .card-content {
    padding: 0;
    margin-bottom: 10px;
}

.chat-card.product-card:not(:has(.card-image)) .card-title {
    font-size: 13.5px;
    margin: 0 0 10px 0;
    font-weight: 600;
}

/* Hide price in compact cards */
.chat-card.product-card:not(:has(.card-image)) .card-price {
    display: none;
}

/* Buttons vertical (one on top of the other) and thin */
.chat-card.product-card:not(:has(.card-image)) .card-actions {
    padding: 0;
    gap: 6px;
    flex-direction: column; /* Vertical stack */
}

.chat-card.product-card:not(:has(.card-image)) .card-button {
    padding: 7px 12px;
    font-size: 12px;
    width: 100%; /* Full width - thin buttons */
    min-width: auto;
    border-radius: 10px;
    flex: none; /* Don't grow to fill space */
}

/* Quick Replies (Chips) - Glassmorphism Pills - Compact */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 0;
    margin-top: 8px;
}

.quick-reply-chip {
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    position: relative;
    overflow: hidden;

    /* Glassmorphism chip */
    background: rgba(0, 123, 255, 0.1);
    backdrop-filter: blur(10px);
    color: var(--chat-primary);
    border: 1.5px solid rgba(0, 123, 255, 0.3);
    box-shadow:
        0 3px 10px rgba(0, 123, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);

    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.quick-reply-chip::before {
    /* Ripple effect background */
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(0, 123, 255, 0.9) 0%, rgba(0, 200, 255, 0.9) 100%);
    opacity: 0;
    transition: opacity 0.3s;
}

.quick-reply-chip:hover::before {
    opacity: 1;
}

.quick-reply-chip:hover {
    transform: translateY(-2px) scale(1.03);
    color: white;
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow:
        0 5px 16px rgba(0, 123, 255, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* Text inside needs to be above ::before */
.quick-reply-chip {
    position: relative;
    z-index: 0;
}

.quick-reply-chip::before {
    z-index: -1;
}

.quick-reply-chip:active {
    transform: translateY(0) scale(0.98);
}

/* Card text wrapper - Compact */
.card-text {
    margin-bottom: 8px;
    font-size: 12.5px;
    line-height: 1.4;
}

/* Dark mode for cards - Glassmorphism Dark */
@media (prefers-color-scheme: dark) {
    .chat-card {
        background: rgba(45, 55, 72, 0.8);
        backdrop-filter: blur(20px) saturate(180%);
        border-color: rgba(255, 255, 255, 0.1);
        box-shadow:
            0 8px 32px rgba(0, 0, 0, 0.4),
            0 4px 16px rgba(0, 0, 0, 0.2),
            inset 0 -1px 4px rgba(255, 255, 255, 0.05);
    }

    .chat-card:hover {
        border-color: rgba(0, 123, 255, 0.4);
        box-shadow:
            0 12px 40px rgba(0, 123, 255, 0.3),
            0 8px 24px rgba(0, 0, 0, 0.3),
            inset 0 -1px 4px rgba(255, 255, 255, 0.1);
    }

    .card-title {
        background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e0 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
    }

    .card-description {
        color: rgba(226, 232, 240, 0.8);
    }

    .card-features {
        color: rgba(226, 232, 240, 0.7);
    }

    .card-features li::before {
        background: rgba(0, 123, 255, 0.2);
        color: #90cdf4;
    }

    .card-price {
        background: linear-gradient(135deg, rgba(0, 123, 255, 0.15) 0%, rgba(0, 200, 255, 0.15) 100%);
        border-color: rgba(0, 123, 255, 0.25);
    }

    .card-price .price {
        background: linear-gradient(135deg, #90cdf4 0%, #00c8ff 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
    }

    .card-button.secondary {
        background: rgba(45, 55, 72, 0.8);
        color: #90cdf4;
        border-color: rgba(144, 205, 244, 0.3);
        box-shadow:
            0 4px 16px rgba(0, 0, 0, 0.2),
            inset 0 1px 0 rgba(255, 255, 255, 0.1);
    }

    .card-button.secondary:hover {
        background: rgba(45, 55, 72, 0.95);
        border-color: rgba(144, 205, 244, 0.5);
    }

    .quick-reply-chip {
        background: rgba(0, 123, 255, 0.15);
        color: #90cdf4;
        border-color: rgba(144, 205, 244, 0.3);
    }

    .quick-reply-chip::before {
        background: linear-gradient(135deg, rgba(144, 205, 244, 0.9) 0%, rgba(0, 200, 255, 0.9) 100%);
    }

    .quick-reply-chip:hover {
        color: #1a202c;
    }

    .card-image {
        background: linear-gradient(135deg, rgba(0, 123, 255, 0.08) 0%, rgba(0, 200, 255, 0.08) 100%);
    }

    .card-icon {
        background: rgba(0, 123, 255, 0.15);
        border-color: rgba(144, 205, 244, 0.3);
    }

    .chat-card:hover .card-icon {
        background: rgba(0, 123, 255, 0.25);
        border-color: rgba(144, 205, 244, 0.5);
    }
}

/* Mobile responsive for cards - Compact */
@media (max-width: 480px) {
    .chat-card {
        max-width: 100%;
    }

    .card-image {
        height: 100px;
    }

    .card-content {
        padding: 12px 14px;
    }

    .card-title {
        font-size: 14px;
    }

    .card-description {
        font-size: 12px;
    }

    .card-price {
        padding: 8px 10px;
    }

    .card-price .price {
        font-size: 17px;
    }

    .card-actions {
        flex-direction: column;
        padding: 10px 14px 14px;
    }

    .card-button {
        width: 100%;
        min-width: 0;
        /* Maintain 44px minimum touch target height */
        min-height: 44px;
        padding: 12px 16px;
    }

    .quick-reply-chip {
        /* Maintain 44px minimum touch target height */
        min-height: 44px;
        padding: 12px 16px;
    }
}