/* ==========================================================================
   AI Chatbot Widget Styles - İzmir Petek & Tesisat
   Apple HIG & Dark Glassmorphism Design
   ========================================================================== */

#ai-chat-root {
    position: fixed;
    bottom: 95px;
    right: 24px;
    z-index: 99998;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* 1. Floating Trigger Button */
.ai-chat-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #f36a0a 0%, #e05300 100%);
    color: #ffffff;
    border: none;
    border-radius: 999px;
    padding: 8px 18px 8px 8px;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(243, 106, 10, 0.4), 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    user-select: none;
}

.ai-chat-trigger:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 14px 30px rgba(243, 106, 10, 0.55);
}

.trigger-icon-wrap {
    position: relative;
    width: 44px;
    height: 44px;
    background: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: inset 0 0 4px rgba(0,0,0,0.1);
}

.trigger-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ff3b30;
    color: #ffffff;
    font-size: 11px;
    font-weight: 800;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    animation: bounceBadge 2s infinite;
}

.pulse-ring {
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 999px;
    border: 2px solid rgba(243, 106, 10, 0.6);
    animation: ringPulse 2.5s infinite;
    pointer-events: none;
}

.trigger-label {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* 2. Teaser Speech Bubble */
.ai-chat-teaser {
    position: absolute;
    bottom: 65px;
    right: 0;
    width: 290px;
    background: rgba(18, 22, 25, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
    padding: 14px 14px 14px 14px;
    animation: slideUpTeaser 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: bottom right;
}

.teaser-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: transparent;
    border: none;
    color: #8b9298;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}
.teaser-close:hover { color: #fff; }

.teaser-content {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    cursor: pointer;
}

.teaser-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    background: #1e2428;
    border: 1px solid #333d45;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: #34c759;
    border-radius: 50%;
    border: 2px solid #121619;
}

.teaser-text strong {
    display: block;
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 2px;
}
.teaser-text p {
    color: #b0b8c0;
    font-size: 12px;
    line-height: 1.45;
    margin: 0;
}

/* 3. Chat Window */
.ai-chat-window {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 380px;
    height: 580px;
    max-height: calc(100vh - 120px);
    background: #0f1214;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: scaleInChat 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: bottom right;
}

/* Chat Header */
.chat-header {
    background: linear-gradient(180deg, #181d21 0%, #121619 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

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

.header-avatar-box {
    position: relative;
    width: 44px;
    height: 44px;
    background: #20272c;
    border: 1.5px solid var(--orange, #f36a0a);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.online-indicator {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 12px;
    height: 12px;
    background: #34c759;
    border-radius: 50%;
    border: 2px solid #121619;
}

.header-name {
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    margin: 0 0 2px 0;
    line-height: 1.2;
}

.header-role {
    color: #8e98a0;
    font-size: 11px;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.dot-online {
    width: 6px;
    height: 6px;
    background: #34c759;
    border-radius: 50%;
    display: inline-block;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-call-btn {
    background: rgba(52, 199, 89, 0.15);
    border: 1px solid rgba(52, 199, 89, 0.35);
    color: #34c759;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
}
.header-call-btn:hover {
    background: #34c759;
    color: #ffffff;
}

.chat-ctrl-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #a0a8b0;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.chat-ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* Assurance Bar */
.chat-assurance-bar {
    background: #0b0d0e;
    color: #ff9800;
    font-size: 10px;
    font-weight: 600;
    text-align: center;
    padding: 6px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    letter-spacing: 0.2px;
    user-select: none;
}

/* Chat Body (Messages) */
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: radial-gradient(circle at bottom, rgba(243, 106, 10, 0.03) 0%, rgba(15, 18, 20, 1) 70%);
    scroll-behavior: smooth;
}

.chat-body::-webkit-scrollbar {
    width: 5px;
}
.chat-body::-webkit-scrollbar-thumb {
    background: #252b30;
    border-radius: 4px;
}

/* Message Bubbles */
.msg-wrap {
    display: flex;
    gap: 10px;
    max-width: 86%;
    animation: fadeInMsg 0.25s ease-out forwards;
}

.msg-wrap.assistant {
    align-self: flex-start;
}

.msg-wrap.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 30px;
    height: 30px;
    background: #1c2226;
    border: 1px solid #2e373e;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
    margin-top: 2px;
}

.msg-bubble {
    padding: 11px 14px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
    position: relative;
}

.msg-wrap.assistant .msg-bubble {
    background: #191f24;
    color: #e6ebf0;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.msg-wrap.user .msg-bubble {
    background: linear-gradient(135deg, #f36a0a 0%, #db5000 100%);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 14px rgba(243, 106, 10, 0.35);
}

.msg-time {
    display: block;
    font-size: 9.5px;
    color: rgba(255, 255, 255, 0.45);
    margin-top: 4px;
    text-align: right;
}

.msg-wrap.user .msg-time {
    color: rgba(255, 255, 255, 0.7);
}

/* Typing Indicator Animation */
.typing-bubble {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    background: #191f24;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.07);
}
.typing-dot {
    width: 6px;
    height: 6px;
    background: #8e98a0;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* Quick Reply Chips */
.chat-chips-scroll {
    /* Satır satır dizilir: yana kayan şeritte son düğmeler kesik görünüyor, devamı olduğu anlaşılmıyordu. */
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px 6px 12px;
    background: #101416;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}
.chat-chips-scroll.is-hidden { display: none; }
.chat-chips-scroll::-webkit-scrollbar { display: none; }

.chip-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #cfd6dc;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.chip-btn:hover {
    background: rgba(243, 106, 10, 0.15);
    border-color: #f36a0a;
    color: #ffffff;
    transform: translateY(-1px);
}

/* Phone Strip */
.chat-phone-strip {
    background: rgba(243, 106, 10, 0.12);
    border-top: 1px solid rgba(243, 106, 10, 0.25);
    padding: 6px 14px;
    font-size: 11px;
    color: #ff9800;
    text-align: center;
    flex-shrink: 0;
}

/* Chat Footer Form */
.chat-footer-form {
    padding: 10px 14px 12px 14px;
    background: #13171a;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    flex-shrink: 0;
}

.input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #0a0d0e;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 4px 6px 4px 12px;
    transition: border-color 0.2s;
}

.input-wrap:focus-within {
    border-color: #f36a0a;
    box-shadow: 0 0 0 2px rgba(243, 106, 10, 0.2);
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 13px;
    outline: none;
    padding: 8px 0;
}

.chat-input::placeholder {
    color: #69737d;
}

.chat-send-btn {
    background: #f36a0a;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-send-btn:hover {
    background: #ff7700;
    transform: scale(1.05);
}

.chat-subnote {
    font-size: 10px;
    color: #5c6670;
    text-align: center;
    margin-top: 6px;
    user-select: none;
}

/* Animations */
@keyframes ringPulse {
    0% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.2); opacity: 0; }
    100% { transform: scale(1.2); opacity: 0; }
}

@keyframes bounceBadge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

@keyframes slideUpTeaser {
    from { opacity: 0; transform: translateY(12px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

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

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

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
    #ai-chat-root {
        bottom: 85px;
        right: 14px;
    }

    .ai-chat-window {
        width: calc(100vw - 20px);
        right: -4px;
        bottom: 0;
        height: 520px;
        max-height: calc(100vh - 100px);
        border-radius: 18px;
    }

    .ai-chat-teaser {
        width: calc(100vw - 40px);
        right: 0;
    }

    .trigger-label {
        display: none;
    }

    .ai-chat-trigger {
        padding: 6px;
    }
}

/* Fotoğraf gönderme */
.chat-attach-btn {
    background: transparent;
    border: none;
    font-size: 18px;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
    opacity: 0.85;
}
.chat-attach-btn:hover { opacity: 1; transform: scale(1.08); }
.msg-photo {
    display: block;
    max-width: 200px;
    max-height: 220px;
    border-radius: 10px;
    margin-bottom: 6px;
}
