/**
 * Resto M2 ChatBot Widget - Frontend CSS
 */

/* Container */
.resto-chatbot {
    position: fixed;
    bottom: 20px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-sizing: border-box;
}

.resto-chatbot *,
.resto-chatbot *::before,
.resto-chatbot *::after {
    box-sizing: border-box !important;
    box-shadow: none;
    border: none;
    text-transform: none;
    letter-spacing: normal;
}

/* Global Button Reset for Widget */
#resto-chatbot-widget button {
    appearance: none !important;
    -webkit-appearance: none !important;
    background: none;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 0;
    box-shadow: none !important;
    cursor: pointer !important;
    font-family: inherit !important;
    min-height: 0 !important;
    min-width: 0 !important;
    width: auto;
    height: auto;
    line-height: normal !important;
}

.resto-chatbot.position-right {
    right: 20px;
}

.resto-chatbot.position-left {
    left: 20px;
}

/* CTA Message */
.chatbot-cta {
    position: absolute;
    bottom: 10px;
    background: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    max-width: none;
    animation: ctaPulse 2s ease-in-out infinite;
    z-index: 1;
}

.position-right .chatbot-cta {
    right: 75px;
}

.position-left .chatbot-cta {
    left: 75px;
}

/* Sağ taraftaki ok (position-right için) */
.chatbot-cta::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 12px;
    height: 12px;
    background: #fff;
    transform: translateY(-50%) rotate(45deg);
    box-shadow: 3px 0 5px rgba(0, 0, 0, 0.08);
}

.position-right .chatbot-cta::after {
    right: -6px;
}

.position-left .chatbot-cta::after {
    left: -6px;
    box-shadow: -3px 0 5px rgba(0, 0, 0, 0.08);
}

/* Mobile Responsive - CTA */
@media (max-width: 480px) {

    /* CTA - mobilde gizle (taşmayı önlemek için) */
    .chatbot-cta {
        display: none !important;
    }
}

@keyframes ctaPulse {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-3px);
    }
}

/* FAB Button */
#resto-chatbot-widget .chatbot-fab {
    width: 60px !important;
    height: 60px !important;
    border-radius: 50% !important;
    border: none !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25) !important;
    transition: transform 0.3s, box-shadow 0.3s !important;
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
    background-color: var(--chatbot-color, #007cba) !important;
}

.chatbot-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.3);
}

.chatbot-fab img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chatbot-fab svg {
    width: 28px;
    height: 28px;
    fill: #fff;
}

/* Chat Window */
.chatbot-window {
    position: absolute;
    bottom: 75px;
    width: 350px;
    height: 450px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.position-right .chatbot-window {
    right: 0;
}

.position-left .chatbot-window {
    left: 0;
}

.chatbot-window.open {
    display: flex;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.chatbot-header {
    padding: 15px 20px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chatbot-header img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    object-fit: cover;
}

.chatbot-header span {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
}

#resto-chatbot-widget .chatbot-close {
    background: rgba(255, 255, 255, 0.2) !important;
    border: none !important;
    color: #fff !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 50% !important;
    font-size: 20px !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.2s !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
}

#resto-chatbot-widget .chatbot-close:hover {
    background: rgba(255, 255, 255, 0.3) !important;
}

/* Messages */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.chatbot-msg {
    margin-bottom: 15px;
    padding: 12px 16px;
    border-radius: 16px;
    max-width: 85%;
    font-size: 14px;
    line-height: 1.5;
    animation: msgFade 0.3s ease;
}

.chatbot-msg.bot {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-bottom-left-radius: 4px;
    margin-right: auto;
}

.chatbot-msg.user {
    background: var(--chatbot-color, #007cba);
    color: #fff;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

@keyframes msgFade {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Typing Indicator */
.chatbot-typing {
    display: flex;
    gap: 5px;
    padding: 15px 20px;
}

.chatbot-typing span {
    width: 10px;
    height: 10px;
    background: #ccc;
    border-radius: 50%;
    animation: typingBounce 1s infinite;
}

.chatbot-typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.chatbot-typing span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes typingBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

/* Input */
.chatbot-input {
    display: flex;
    padding: 15px;
    gap: 10px;
    background: #fff;
    border-top: 1px solid #eee;
}

#resto-chatbot-widget .chatbot-input input {
    flex: 1 !important;
    border: 1px solid #ddd !important;
    border-radius: 24px !important;
    padding: 12px 20px !important;
    font-size: 14px !important;
    outline: none !important;
    transition: border-color 0.2s !important;
    background-color: #fff !important;
    color: #333 !important;
}

#resto-chatbot-widget .chatbot-input input:focus {
    border-color: var(--chatbot-color, #007cba) !important;
}

/* Mobil zoom önleme - ID ile yüksek specificity */
@media (max-width: 480px) {
    #chatbot-user-input {
        font-size: 16px !important;
        -webkit-text-size-adjust: 100%;
    }
}

#resto-chatbot-widget .chatbot-input button {
    width: 44px !important;
    height: 44px !important;
    border: none !important;
    border-radius: 50% !important;
    color: #fff !important;
    font-size: 20px !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: transform 0.2s !important;
    background-color: var(--chatbot-color, #007cba) !important;
    padding: 0 !important;
    margin: 0 !important;
}

.chatbot-input button:hover {
    transform: scale(1.05);
}

/* Mobile Responsive - Ana Stiller */
@media (max-width: 480px) {

    /* HTML/Body overflow kontrolü */
    html body {
        overflow-x: hidden !important;
    }

    /* Ana container - taşmayı kesinlikle önle */
    .resto-chatbot {
        bottom: 10px !important;
        max-width: 60px !important;
        overflow: visible !important;
    }

    .resto-chatbot.position-right {
        right: 10px !important;
        left: auto !important;
    }

    .resto-chatbot.position-left {
        left: 10px !important;
        right: auto !important;
    }

    /* FAB buton - mobil boyut */
    .chatbot-fab {
        width: 50px !important;
        height: 50px !important;
        min-width: 50px !important;
        max-width: 50px !important;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    /* Chat window - tam ekran modal gibi */
    .chatbot-window {
        position: fixed !important;
        top: 10px !important;
        left: 10px !important;
        right: 10px !important;
        bottom: 70px !important;
        width: calc(100vw - 20px) !important;
        height: auto !important;
        max-width: calc(100vw - 20px) !important;
        max-height: calc(100vh - 80px) !important;
        border-radius: 12px !important;
        transform: none !important;
    }

    .position-right .chatbot-window,
    .position-left .chatbot-window {
        left: 10px !important;
        right: 10px !important;
    }

    /* Input alanı - mobil optimize */
    .chatbot-input {
        padding: 10px !important;
        gap: 8px !important;
    }

    .chatbot-input input {
        padding: 10px 16px !important;
        font-size: 16px !important;
        /* iOS zoom engellemek için */
        touch-action: manipulation;
        -webkit-appearance: none;
        border-radius: 20px !important;
    }

    .chatbot-input button {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        flex-shrink: 0 !important;
        touch-action: manipulation;
    }

    /* Header - daha kompakt */
    .chatbot-header {
        padding: 12px 15px !important;
    }

    .chatbot-header img {
        width: 35px !important;
        height: 35px !important;
    }

    .chatbot-header span {
        font-size: 15px !important;
    }

    /* Mesajlar - mobil optimize */
    .chatbot-messages {
        padding: 15px !important;
    }

    .chatbot-msg {
        padding: 10px 14px !important;
        font-size: 14px !important;
        max-width: 90% !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
}

/* Bot Message Formatting */
.chatbot-msg.bot p {
    margin: 0 0 8px 0;
}

.chatbot-msg.bot p:last-child {
    margin-bottom: 0;
}

.chatbot-msg.bot strong {
    color: #333;
    font-weight: 600;
}

.chatbot-msg.bot em {
    font-style: italic;
}

/* Bot Message List */
.chatbot-msg.bot .chatbot-list {
    margin: 8px 0;
    padding-left: 0;
    list-style: none;
}

.chatbot-msg.bot .chatbot-list li {
    position: relative;
    padding-left: 18px;
    margin-bottom: 6px;
    line-height: 1.4;
}

.chatbot-msg.bot .chatbot-list li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--chatbot-color, #007cba);
    font-weight: bold;
}

.chatbot-msg.bot .chatbot-list li:last-child {
    margin-bottom: 0;
}

/* Price Highlight */
.chatbot-msg.bot .chatbot-price {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    color: #2e7d32;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
}

/* Strikethrough (Üstü Çizili) - Eski fiyat için */
.chatbot-msg.bot .chatbot-strikethrough {
    text-decoration: line-through;
    color: #d32f2f;
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 13px;
    opacity: 0.85;
}

/* Kampanyalı fiyat kalın strong içinde */
.chatbot-msg.bot strong .chatbot-price,
.chatbot-msg.bot strong {
    color: #1b5e20;
}

/* Chatbot Image (Markdown image desteği) */
.chatbot-msg.bot .chatbot-image {
    margin: 10px 0;
    text-align: center;
}

.chatbot-msg.bot .chatbot-image img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    cursor: zoom-in;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chatbot-msg.bot .chatbot-image img:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.chatbot-msg.bot .chatbot-image-caption {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #666;
    font-style: italic;
}

/* Chatbot Image Modal (Lightbox) */
.chatbot-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: chatbotModalFadeIn 0.2s ease;
}

@keyframes chatbotModalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.chatbot-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    animation: chatbotModalSlideUp 0.3s ease;
}

@keyframes chatbotModalSlideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.chatbot-modal-content img {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 8px;
    display: block;
}

.chatbot-modal-close {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 36px;
    height: 36px;
    background: #fff;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s, background 0.2s;
}

.chatbot-modal-close:hover {
    transform: scale(1.1);
    background: #f5f5f5;
}

.chatbot-modal-caption {
    text-align: center;
    margin: 12px 0 0 0;
    font-size: 14px;
    color: #666;
}