@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* CSS Variables for Customization */
:root {
    --optic-chat-primary: #268CCD;
    --optic-chat-secondary: #1a6ba3;
    --optic-chat-button-text: #ffffff;
    --optic-chat-bg: #f8f9fb;
    --optic-chat-shadow: rgba(0, 0, 0, 0.15);
}

/* Base Styles */
#optic-chat-container, 
#optic-chat-container * { 
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    box-sizing: border-box; 
}

/* Font size CSS vars applied to key elements */
#optic-chat-messages           { font-size: var(--optic-font-body,   14px); }
.optic-chat-header             { font-size: var(--optic-font-header, 18px); }
#optic-chat-input              { font-size: var(--optic-font-input,  14px); }
#optic-chat-send,
.optic-booking-trigger,
.quick-reply-btn               { font-size: var(--optic-font-btn,    14px); }

/* Emoji font — ensures flags render on all platforms */
.optic-lang-flag-em,
.optic-lang-btn > span:first-child {
    font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif;
}

/* Lang selector color vars — higher specificity wins over header/theme rules */
.optic-chat-header .optic-lang-trigger,
.optic-lang-trigger {
    background:    var(--optic-lang-bg,     rgba(255,255,255,0.18));
    color:         var(--optic-lang-text,   var(--optic-chat-button-text));
    border-color:  var(--optic-lang-border, rgba(255,255,255,0.4));
}
.optic-chat-header .optic-lang-btn,
.optic-lang-btn {
    background:   var(--optic-lang-bg,     rgba(255,255,255,0.18));
    color:        var(--optic-lang-text,   var(--optic-chat-button-text));
    border-color: var(--optic-lang-border, rgba(255,255,255,0.35));
}

/* Floating Button - Modernized */
/* position overridden by backoffice settings via inline style in chat_widget.tpl */
#optic-chat-toggle {
    position: fixed;
    bottom: 24px; /* fallback default */
    right: 24px;  /* fallback default */
    background: linear-gradient(135deg, var(--optic-chat-primary) 0%, var(--optic-chat-secondary) 100%);
    color: var(--optic-chat-button-text);
    border: none;
    border-radius: 50%;
    width: 64px;
    height: 64px;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(38, 140, 205, 0.4);
    z-index: 9999;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
}

#optic-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 32px rgba(38, 140, 205, 0.5);
}

/* Chat Container - Modern Card Design */
/* position overridden by backoffice settings via inline style in chat_widget.tpl */
#optic-chat-container {
    position: fixed;
    bottom: 100px; /* fallback default */
    right: 24px;   /* fallback default */
    width: var(--optic-chat-width, 400px);
    max-width: calc(100vw - 48px);
    height: var(--optic-chat-height, 600px);
    max-height: calc(100vh - 140px);
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px var(--optic-chat-shadow);
    display: flex;
    flex-direction: column;
    z-index: 9998;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#optic-chat-container.optic-chat-closed {
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
}

#optic-chat-container.optic-chat-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header - Gradient Design */
.optic-chat-header {
    background: linear-gradient(135deg, var(--optic-chat-primary) 0%, var(--optic-chat-secondary) 100%);
    color: var(--optic-chat-button-text);
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 20px 20px 0 0;
}

.optic-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.optic-chat-lang-header {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 6px;
    color: var(--optic-chat-button-text);
    font-size: 11px;
    padding: 4px 6px;
    cursor: pointer;
    outline: none;
    transition: background 0.2s;
}

.optic-chat-lang-header:hover {
    background: rgba(255, 255, 255, 0.3);
}

.optic-chat-lang-header option {
    background: #fff;
    color: #333;
}

.header-title {
    font-weight: 600;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-logo {
    height: 32px;
    width: 32px;
    object-fit: contain;
    background: white;
    padding: 4px;
    border-radius: 8px;
}

#optic-chat-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: var(--optic-chat-button-text);
    font-size: 24px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#optic-chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Messages Area - Clean Design */
#optic-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: var(--optic-chat-bg);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Scrollbar Styling */
#optic-chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

#optic-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

#optic-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Message Bubbles - Modern Design */
.message {
    max-width: 85%;
    animation: messageSlideIn 0.3s ease;
}

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

.user-message {
    background: linear-gradient(135deg, var(--optic-chat-primary) 0%, var(--optic-chat-secondary) 100%);
    color: var(--optic-chat-button-text);
    padding: 12px 16px;
    border-radius: 16px;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
}

.bot-message {
    background: white;
    color: #2d3748;
    padding: 12px 16px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.bot-text {
    margin-bottom: 12px;
    line-height: 1.6;
    font-size: 15px;
}

.bot-text:last-child {
    margin-bottom: 0;
}

/* Product Cards - Beautiful Design */
.product-card {
    background: linear-gradient(135deg, #f6f8fa 0%, #ffffff 100%);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    margin: 8px 0;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    max-width: 100%;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
}

.product-image {
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: #f7fafc;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

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

.product-info {
    padding: 16px;
}

.product-name {
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
    margin: 0 0 8px 0;
}

.product-price {
    font-size: 20px;
    font-weight: 700;
    color: var(--optic-chat-primary);
    margin-bottom: 12px;
}

.product-link {
    display: inline-block;
    background: var(--optic-chat-primary);
    color: var(--optic-chat-button-text);
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
}

.product-link:hover {
    background: var(--optic-chat-secondary);
    transform: translateX(4px);
}

/* Typing Indicator - Animated */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.typing-indicator::after {
    content: '●●●';
    animation: typingDots 1.4s infinite;
    letter-spacing: 2px;
}

@keyframes typingDots {
    0%, 20% { content: '●○○'; }
    40% { content: '●●○'; }
    60%, 100% { content: '●●●'; }
}

/* Quick Replies - Pill Design */
#optic-chat-suggestions {
    padding: 12px 20px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
    overflow-x: auto;
}

#optic-chat-suggestions::-webkit-scrollbar {
    height: 4px;
}

#optic-chat-suggestions::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 2px;
}

.quick-reply-btn {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    color: #4a5568;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.quick-reply-btn:hover {
    background: var(--optic-chat-primary);
    color: var(--optic-chat-button-text);
    border-color: var(--optic-chat-primary);
    transform: translateY(-1px);
}

.quick-reply-link {
    display: inline-block;
    text-decoration: none;
    color: #4a5568;
}

.quick-reply-link:hover {
    color: var(--optic-chat-button-text);
    text-decoration: none;
}

/* Input Area - Clean Design */
.optic-chat-input-area {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 12px;
}

#optic-chat-input {
    flex: 1;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 15px;
    outline: none;
    transition: all 0.2s;
    background: #f8f9fb;
}

#optic-chat-input:focus {
    border-color: var(--optic-chat-primary);
    background: white;
}

#optic-chat-send {
    background: linear-gradient(135deg, var(--optic-chat-primary) 0%, var(--optic-chat-secondary) 100%);
    color: var(--optic-chat-button-text);
    border: none;
    border-radius: 12px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

#optic-chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(38, 140, 205, 0.3);
}

#optic-chat-send:active {
    transform: scale(0.98);
}

/* Mobile Responsive */
@media (max-width: 480px) {
    #optic-chat-container {
        bottom: 0 !important;
        top: auto !important;
        right: 0 !important;
        left: 0 !important;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .optic-chat-header {
        border-radius: 0;
    }
    
    #optic-chat-toggle {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
        font-size: 24px;
    }
    
    .message {
        max-width: 90%;
    }
    
    .product-image {
        height: 150px;
    }
    
    .product-card {
        max-width: 100%;
    }
}

/* Custom icon in toggle button */
.optic-chat-toggle-icon {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 4px;
}

/* OpticWeb Branding Footer – hidden */
.optic-chat-footer {
    display: none;
}

.optic-branding {
    font-size: 11px;
    color: #aab;
    margin-left: auto;
    white-space: nowrap;
}

.optic-branding a {
    color: #aab;
    text-decoration: none;
    transition: color 0.2s;
}

.optic-branding a:hover {
    color: var(--optic-chat-primary) !important;
    text-decoration: underline;
}


.optic-branding-powered {
    font-size: 10px;
    color: #999;
}

.optic-branding-link {
    color: #268CCD;
    text-decoration: none;
}

.optic-branding-contact {
    font-size: 9px;
    color: #aaa;
}

.optic-branding-contact-link {
    color: inherit;
}

/* Custom Logo in Header */
.optic-chat-logo {
    max-height: 40px;
    max-width: 150px;
    object-fit: contain;
    margin-right: 10px;
}

/* Products Grid - for multiple products in a list */
.products-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    width: 100%;
    margin: 6px 0;
}

/* When only one product is in the grid, show it full-width */
.products-grid .product-card:only-child {
    grid-column: 1 / -1;
}

/* In grid mode, reduce image height to fit better */
.products-grid .product-image {
    height: 140px;
}

/* In grid mode, adjust font sizes for compact layout */
.products-grid .product-name {
    font-size: 13px;
}

.products-grid .product-price {
    font-size: 15px;
    margin-bottom: 8px;
}

.products-grid .product-link {
    padding: 7px 12px;
    font-size: 12px;
}

/* Mobile: single column grid */
@media (max-width: 480px) {
    .products-grid {
        grid-template-columns: 1fr;
    }
}

/* Bot messages containing a product grid should use full width */
.bot-message:has(.products-grid) {
    max-width: 100%;
    width: 100%;
}

/* ===== Contact Card ===== */
.contact-card {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    width: 100%;
}

.contact-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    border-radius: 10px;
    text-decoration: none !important;
    font-size: 13px;
    font-weight: 500;
    background: #f0f4f8;
    color: #2d3748 !important;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.contact-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.contact-btn--phone     { background: #e8f5e9; border-color: #a5d6a7; }
.contact-btn--email     { background: #e3f2fd; border-color: #90caf9; }
.contact-btn--viber     { background: #ede7f6; border-color: #ce93d8; }
.contact-btn--whatsapp  { background: #e8f5e9; border-color: #81c784; }
.contact-btn--messenger { background: #e3f2fd; border-color: #64b5f6; }
.contact-btn--telegram  { background: #e1f5fe; border-color: #4fc3f7; }
.contact-btn--instagram { background: #fce4ec; border-color: #f48fb1; }
.contact-btn--facebook  { background: #e8eaf6; border-color: #9fa8da; }

.contact-btn-icon  { font-size: 16px; line-height: 1; }
.contact-btn-label { font-size: 13px; }

/* Feature 1: Add to Cart button on product cards */
.optic-product-buy-btn {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--optic-chat-primary, #268CCD);
    color: var(--optic-chat-button-text, #fff);
    text-align: center;
    border-radius: 6px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}
.optic-product-buy-btn:hover {
    opacity: 0.85;
}

/* Bottom bar with clear button */
.optic-chat-bottom-bar {
    padding: 8px 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

/* Clear button – moved to bottom bar */
#optic-chat-clear {
    background: transparent;
    border: 1px solid #e2e8f0;
    color: #a0aec0;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    height: 28px;
    padding: 0 12px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: all 0.2s ease;
    white-space: nowrap;
}
#optic-chat-clear:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #dc2626;
}
#optic-chat-clear:active {
    transform: scale(0.97);
}
@media (max-width: 480px) {
    #optic-chat-clear {
        font-size: 11px;
    }
}

/* Feature 6: Comparison card */
.comparison-card {
    width: 100%;
}
.comparison-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    margin: 8px 0;
}
.comparison-grid .product-card {
    margin: 0;
}
.comparison-vs {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    color: var(--optic-chat-primary);
    padding: 4px 0;
    grid-column: 1 / -1;
}
@media (max-width: 480px) {
    .comparison-grid {
        grid-template-columns: 1fr;
    }
}

/* Feature 7: Handoff buttons */
.handoff-card {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    width: 100%;
}
.handoff-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    border-radius: 10px;
    text-decoration: none !important;
    font-size: 13px;
    font-weight: 500;
    background: #f0f4f8;
    color: #2d3748 !important;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.handoff-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.handoff-btn--phone     { background: #e8f5e9; border-color: #a5d6a7; }
.handoff-btn--whatsapp  { background: #e8f5e9; border-color: #81c784; }
.handoff-btn--viber     { background: #ede7f6; border-color: #ce93d8; }
.handoff-btn--email     { background: #e3f2fd; border-color: #90caf9; }

/* Booking bar */
.optic-chat-booking-bar {
    padding: 10px 20px;
    background: white;
    border-top: 1px solid #e2e8f0;
    text-align: center;
}

.optic-booking-trigger {
    background: linear-gradient(135deg, var(--optic-chat-primary) 0%, var(--optic-chat-secondary) 100%);
    color: var(--optic-chat-button-text);
    border: none;
    border-radius: 8px;
    padding: 9px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.optic-booking-trigger:hover {
    opacity: 0.88;
    transform: translateY(-1px);
}

/* Booking status badges in admin */
.booking-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}
.booking-status-pending   { background: #fef3c7; color: #92400e; }
.booking-status-confirmed { background: #d1fae5; color: #065f46; }
.booking-status-rejected  { background: #fee2e2; color: #991b1b; }
.booking-status-cancelled { background: #f3f4f6; color: #374151; }
.booking-status-completed { background: #dbeafe; color: #1e40af; }

/* ── Language selector ─────────────────────────────────────────────────── */

/* Custom dropdown (replaces <select> — flags render here) */
.optic-lang-dropdown {
    position: relative;
    display: inline-block;
}

.optic-lang-trigger {
    display: flex;
    align-items: center;
    gap: 5px;
    border-width: 1px;
    border-style: solid;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 13px;
    cursor: pointer;
    outline: none;
    transition: background .2s, border-color .2s, color .2s;
    white-space: nowrap;
}
.optic-lang-trigger:hover,
.optic-lang-dropdown.open .optic-lang-trigger {
    background: rgba(255,255,255,0.32);
}
.optic-lang-arrow {
    font-size: 10px;
    opacity: .8;
    transition: transform .2s;
}
.optic-lang-dropdown.open .optic-lang-arrow {
    transform: rotate(180deg);
}

.optic-lang-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.14);
    list-style: none;
    margin: 0;
    padding: 4px 0;
    min-width: 140px;
    z-index: 9999;
}
.optic-lang-dropdown.open .optic-lang-menu {
    display: block;
}
.optic-lang-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 14px;
    color: #374151;
    transition: background .12s;
    white-space: nowrap;
}
.optic-lang-option:hover {
    background: #f0f9ff;
}
.optic-lang-option.selected {
    background: #e0f2fe;
    color: var(--optic-chat-primary);
    font-weight: 600;
}
.optic-lang-lbl {
    font-size: 13px;
}

/* Buttons mode */
.optic-lang-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
}
.optic-lang-btn {
    display: flex;
    align-items: center;
    gap: 3px;
    border: 1px solid;
    border-radius: 6px;
    padding: 4px 7px;
    cursor: pointer;
    line-height: 1;
    transition: all .2s;
    opacity: .8;
}
.optic-lang-btn:hover,
.optic-lang-btn.active {
    background: rgba(255,255,255,0.40);
    border-color: rgba(255,255,255,0.7);
    opacity: 1;
}
.optic-lang-btn-lbl {
    font-size: 11px;
    font-weight: 600;
}
