/**
 * Colibri Jewels Chat Widget Styles
 * Elegant, minimalist design matching colibri-jewels.eu aesthetic
 */

/* Container positioning */
.colibri-chat-container {
    position: fixed;
    z-index: 9999;
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --colibri-vh: 1vh;
}

.colibri-chat-container.colibri-chat-expanded .colibri-chat-window {
    width: min(680px, calc(100vw - 40px));
    height: min(720px, calc(100vh - 40px));
}

.colibri-chat-bottom-right {
    bottom: 20px;
    right: 20px;
}

.colibri-chat-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Chat bubble (minimized state) */
.colibri-chat-bubble {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: #c9a961;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    position: relative;
}

.colibri-chat-bubble:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.colibri-chat-bubble svg {
    width: 28px;
    height: 28px;
}

/* Notification dot */
.colibri-chat-notification {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    background: #e74c3c;
    border-radius: 50%;
    border: 2px solid white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(231, 76, 60, 0); }
    100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}

/* Chat window */
.colibri-chat-window {
    width: 380px;
    height: 550px;
    background: #fffdfb;
    border-radius: 16px;
    border: 1px solid rgba(196, 154, 116, 0.18);
    box-shadow: 0 18px 42px rgba(58, 53, 51, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
    transition: width 0.28s ease, height 0.28s ease, box-shadow 0.28s ease;
    overflow-x: hidden;
}

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

/* Header */
.colibri-chat-header {
    background: #3b3634;
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.colibri-chat-logo {
    width: 110px;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.08));
}

.colibri-chat-header-text {
    display: flex;
    flex-direction: column;
}

.colibri-chat-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.colibri-chat-subtitle {
    font-size: 12px;
    color: #d8c3af;
    margin-top: 2px;
}

.colibri-chat-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.colibri-chat-close:hover {
    opacity: 1;
}

.colibri-chat-close svg {
    width: 20px;
    height: 20px;
}

/* Messages container */
.colibri-chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: linear-gradient(180deg, #f8f4ef 0%, #fcfaf7 100%);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

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

.colibri-chat-messages::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

/* Message bubbles */
.colibri-chat-message {
    display: flex;
    max-width: 85%;
}

.colibri-chat-message.user {
    align-self: flex-end;
}

.colibri-chat-message.bot {
    align-self: flex-start;
    width: min(100%, 100%);
}

.colibri-chat-message-content {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    max-width: 100%;
    overflow-x: hidden;
}

.colibri-chat-message.user .colibri-chat-message-content {
    background: #3b3634;
    color: white;
    border-bottom-right-radius: 4px;
}

.colibri-chat-message.bot .colibri-chat-message-content {
    background: rgba(24, 183, 176, 0.1);
    color: #2f2d2c;
    border-bottom-left-radius: 4px;
}

.colibri-chat-message-content p {
    margin: 0;
}

.colibri-chat-message-body h1,
.colibri-chat-message-body h2,
.colibri-chat-message-body h3 {
    margin: 0 0 8px;
    line-height: 1.3;
}

.colibri-chat-message-body h1 { font-size: 16px; }
.colibri-chat-message-body h2 { font-size: 15px; }
.colibri-chat-message-body h3 { font-size: 14px; }

.colibri-chat-message-body p {
    margin: 0 0 8px;
}

.colibri-chat-message-body p:last-child {
    margin-bottom: 0;
}

.colibri-chat-message-body.is-plain-stream {
    white-space: pre-wrap;
}

.colibri-chat-message-body ul,
.colibri-chat-message-body ol {
    margin: 0 0 8px 18px;
    padding: 0;
}

.colibri-chat-message-body li {
    margin-bottom: 4px;
}

.colibri-chat-message-body code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    padding: 2px 5px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.08);
}

.colibri-chat-message.user .colibri-chat-message-body code {
    background: rgba(255, 255, 255, 0.2);
}

.colibri-chat-message-body pre {
    margin: 0 0 8px;
    padding: 10px;
    border-radius: 8px;
    overflow-x: auto;
    background: rgba(0, 0, 0, 0.08);
}

.colibri-chat-message.user .colibri-chat-message-body pre {
    background: rgba(255, 255, 255, 0.18);
}

.colibri-chat-message-body pre code {
    padding: 0;
    background: transparent;
}

.colibri-chat-message-body a {
    color: inherit;
    text-decoration: underline;
}

.colibri-chat-inline-image {
    display: block;
    width: min(100%, 260px);
    max-width: 100%;
    margin: 10px 0 6px;
    border-radius: 12px;
    box-shadow: 0 10px 24px rgba(37, 31, 28, 0.12);
    background: #fff;
}

.colibri-product-grid {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(220px, 240px);
    gap: 12px;
    margin: 8px 0 4px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 8px;
    scroll-snap-type: x proximity;
    overscroll-behavior-x: contain;
    overscroll-behavior-y: auto;
    touch-action: pan-x;
}

.colibri-product-carousel {
    position: relative;
}

.colibri-product-grid::-webkit-scrollbar {
    height: 8px;
}

.colibri-product-grid::-webkit-scrollbar-thumb {
    background: rgba(140, 108, 85, 0.25);
    border-radius: 999px;
}

.colibri-product-showcase {
    margin: 10px 0 2px;
}

.colibri-product-showcase-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.colibri-product-showcase-kicker {
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #8c6c55;
    font-weight: 700;
}

.colibri-product-showcase-meta {
    font-size: 12px;
    color: #6f6762;
}

.colibri-product-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(23, 183, 177, 0.18);
    color: #2f2d2c;
    text-decoration: none;
    box-shadow: 0 10px 24px rgba(37, 31, 28, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    scroll-snap-align: start;
    min-height: 100%;
}

.colibri-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 30px rgba(37, 31, 28, 0.14);
}

.colibri-product-card-media {
    aspect-ratio: 1 / 1;
    background: linear-gradient(180deg, #f7f3ef 0%, #ece6de 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.colibri-product-card-media.is-fallback::after {
    content: 'Preview unavailable';
    font-size: 13px;
    color: #9d8f84;
}

.colibri-product-card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.colibri-product-card-placeholder {
    font-family: 'Playfair Display', Georgia, serif;
    color: #9d8f84;
    font-size: 18px;
}

.colibri-product-card-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
}

.colibri-product-card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.colibri-product-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(140, 108, 85, 0.1);
    color: #7f6350;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.colibri-product-card-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
}

.colibri-product-card-description {
    font-size: 12px;
    line-height: 1.45;
    color: #625954;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.colibri-product-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: auto;
}

.colibri-product-card-price {
    font-size: 14px;
    font-weight: 700;
    color: #17b7b1;
}

.colibri-product-card-link {
    font-size: 12px;
    font-weight: 600;
    color: #8c6c55;
    text-decoration: none;
}

.colibri-product-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.colibri-product-chip {
    border: 1px solid rgba(23, 183, 177, 0.22);
    background: rgba(23, 183, 177, 0.08);
    color: #136f6c;
    border-radius: 999px;
    padding: 7px 10px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.colibri-product-chip:hover {
    background: rgba(23, 183, 177, 0.14);
    border-color: rgba(23, 183, 177, 0.36);
    transform: translateY(-1px);
}

.colibri-chat-lightbox {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(31, 27, 25, 0.72);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
    z-index: 10001;
    padding: 24px;
}

.colibri-chat-lightbox.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.colibri-chat-lightbox img {
    max-width: min(90vw, 820px);
    max-height: 86vh;
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
    background: #fff;
}

.colibri-chat-lightbox-close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: #2f2d2c;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}

.colibri-chat-message-content.streaming .colibri-chat-message-body::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 14px;
    margin-left: 4px;
    vertical-align: text-bottom;
    background: currentColor;
    animation: colibri-caret 1s steps(1) infinite;
    opacity: 0.7;
}

@keyframes colibri-caret {
    50% { opacity: 0.15; }
}

.colibri-chat-message-time {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 6px;
    display: block;
}

/* Typing indicator */
.colibri-chat-typing-dots {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.colibri-chat-typing-dots span {
    width: 8px;
    height: 8px;
    background: #c9a961;
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite both;
}

.colibri-chat-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.colibri-chat-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Input area */
.colibri-chat-input-area {
    padding: 16px 20px;
    background: #fffdfb;
    border-top: 1px solid rgba(196, 154, 116, 0.16);
    display: flex;
    gap: 12px;
    align-items: center;
}

.colibri-chat-input {
    flex: 1;
    border: 1px solid rgba(196, 154, 116, 0.28);
    border-radius: 24px;
    padding: 12px 18px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
    min-height: 44px;
}

.colibri-chat-input:focus {
    border-color: #18b7b0;
}

.colibri-chat-input::placeholder {
    color: #999;
}

.colibri-chat-send {
    background: none;
    border: none;
    color: #18b7b0;
    cursor: pointer;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.colibri-chat-send:hover {
    transform: scale(1.1);
}

.colibri-chat-send svg {
    width: 22px;
    height: 22px;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .colibri-chat-container {
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
    }

    .colibri-chat-bubble {
        width: 64px;
        height: 64px;
        margin: 16px;
    }

    .colibri-chat-window {
        width: 100vw;
        height: calc(var(--colibri-vh, 1vh) * 100);
        max-height: calc(var(--colibri-vh, 1vh) * 100);
        border-radius: 0;
        position: fixed;
        top: 0;
        left: 0;
    }

    .colibri-chat-header {
        padding: 12px 16px;
    }

    .colibri-chat-messages {
        padding: 16px;
        overscroll-behavior-y: contain;
    }

    .colibri-chat-input-area {
        padding: 12px 16px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .colibri-chat-input {
        font-size: 16px;
    }

    .colibri-product-chip {
        min-height: 40px;
        padding: 9px 12px;
        font-size: 12px;
    }

    .colibri-chat-container.colibri-keyboard-open .colibri-chat-window {
        height: calc(var(--colibri-vh, 1vh) * 100);
        max-height: calc(var(--colibri-vh, 1vh) * 100);
    }

    .colibri-product-grid {
        grid-auto-columns: minmax(200px, 82vw);
    }

}

/* Tablet adjustments */
@media (min-width: 481px) and (max-width: 768px) {
    .colibri-chat-window {
        width: 360px;
        height: 500px;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    .colibri-chat-messages {
        background: #2f2c2a;
    }
    
    .colibri-chat-input-area {
        background: #322f2d;
        border-top-color: #4c4642;
    }
    
    .colibri-chat-input {
        background: #403c39;
        border-color: #5c5551;
        color: white;
    }
    
    .colibri-chat-message.bot .colibri-chat-message-content {
        background: rgba(24, 183, 176, 0.18);
        color: white;
    }
}
