/* ==========================================================================
   KTM WhatsApp Canlı Destek Botu - Modern & Responsive Widget Stilleri
   ========================================================================== */

/* Canlı Destek Tetikleyici Butonu (Floating Trigger) */
.ktm-support-trigger {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 99990;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #25D366;
    color: #ffffff;
    border: none;
    border-radius: 50px;
    padding: 8px 16px 8px 10px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(37, 211, 102, 0.4), 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    font-family: inherit;
}

.ktm-support-trigger:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 12px 30px rgba(37, 211, 102, 0.5), 0 4px 10px rgba(0, 0, 0, 0.2);
    background: #22bf5b;
}

.ktm-support-trigger:active {
    transform: translateY(0) scale(0.98);
}

.ktm-trigger-icon-wrap {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.ktm-trigger-icon-wrap img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 50%;
}

.ktm-trigger-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    background: #10b981;
    border: 2px solid #ffffff;
    border-radius: 50%;
}

.ktm-trigger-badge.pulse {
    animation: ktmPulse 2s infinite;
}

@keyframes ktmPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.ktm-trigger-text {
    display: flex;
    flex-direction: column;
    text-align: left;
    line-height: 1.2;
}

.ktm-trigger-title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.2px;
    color: #ffffff;
}

.ktm-trigger-sub {
    font-size: 11px;
    opacity: 0.92;
    color: #e6ffed;
}

/* Canlı Destek Asistanı Penceresi */
.ktm-support-widget {
    position: fixed;
    bottom: 96px;
    right: 28px;
    z-index: 99995;
    width: 390px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22), 0 2px 10px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.08);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: inherit;
}

.ktm-support-widget.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Widget Header */
.ktm-support-header {
    background: linear-gradient(135deg, #075E54 0%, #128C7E 100%);
    color: #ffffff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    position: relative;
    z-index: 2;
}

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

.ktm-header-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    background: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.ktm-header-avatar img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border-radius: 50%;
}

.ktm-avatar-status {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 11px;
    height: 11px;
    background: #25D366;
    border: 2px solid #ffffff;
    border-radius: 50%;
}

.ktm-header-info {
    display: flex;
    flex-direction: column;
}

.ktm-header-name {
    font-size: 14.5px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.25;
}

.ktm-header-status {
    font-size: 11.5px;
    color: #d1fae5;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.ktm-status-dot {
    width: 7px;
    height: 7px;
    background: #25D366;
    border-radius: 50%;
    display: inline-block;
    animation: ktmBlink 1.5s infinite;
}

@keyframes ktmBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

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

.ktm-btn-icon {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    transition: background 0.2s, transform 0.15s;
    text-decoration: none;
}

.ktm-btn-icon:hover {
    background: rgba(255, 255, 255, 0.28);
    transform: scale(1.05);
}

.ktm-btn-close {
    font-size: 20px;
    font-weight: 300;
    line-height: 1;
}

/* Chat Body (Messages) */
.ktm-support-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    background-color: #EFEAE2;
    background-image: radial-gradient(#d1d5db 0.75px, transparent 0.75px);
    background-size: 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.ktm-support-body::-webkit-scrollbar {
    width: 5px;
}

.ktm-support-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

/* Date / Security Notice */
.ktm-system-notice {
    align-self: center;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    padding: 5px 12px;
    border-radius: 12px;
    font-size: 11px;
    color: #54656f;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    text-align: center;
    max-width: 90%;
    line-height: 1.3;
}

/* Message Bubble */
.ktm-msg {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    position: relative;
    animation: ktmMsgIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.ktm-msg-bot {
    align-self: flex-start;
}

.ktm-msg-user {
    align-self: flex-end;
}

.ktm-msg-content {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.48;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    word-break: break-word;
    position: relative;
}

.ktm-msg-bot .ktm-msg-content {
    background: #ffffff;
    color: #111b21;
    border-bottom-left-radius: 4px;
}

.ktm-msg-user .ktm-msg-content {
    background: #D9FDD3;
    color: #111b21;
    border-bottom-right-radius: 4px;
}

.ktm-msg-time {
    font-size: 10px;
    color: #667781;
    align-self: flex-end;
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 3px;
}

.ktm-msg-user .ktm-msg-time {
    color: #53bdeb;
}

/* Quick Topic Pills / Action Buttons */
.ktm-quick-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
    width: 100%;
}

.ktm-quick-btn {
    background: #ffffff;
    border: 1px solid #128C7E;
    color: #075E54;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 12.5px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.18s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    font-family: inherit;
}

.ktm-quick-btn:hover {
    background: #128C7E;
    color: #ffffff;
    transform: translateX(3px);
}

.ktm-quick-btn span.arrow {
    font-size: 14px;
    opacity: 0.7;
}

/* WhatsApp Escalation Card inside Message */
.ktm-wa-card {
    margin-top: 8px;
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ktm-wa-card-text {
    font-size: 12px;
    color: #166534;
    font-weight: 500;
    line-height: 1.35;
}

.ktm-wa-direct-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #25D366;
    color: #ffffff !important;
    text-decoration: none !important;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(37, 211, 102, 0.35);
    transition: all 0.2s;
    text-align: center;
}

.ktm-wa-direct-btn:hover {
    background: #1eb956;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(37, 211, 102, 0.45);
}

.ktm-wa-direct-btn img {
    width: 18px;
    height: 18px;
}

/* Typing Indicator */
.ktm-typing-indicator {
    display: none;
    align-self: flex-start;
    background: #ffffff;
    padding: 8px 14px;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    align-items: center;
    gap: 4px;
}

.ktm-typing-indicator.active {
    display: inline-flex;
}

.ktm-dot {
    width: 6px;
    height: 6px;
    background: #8696a0;
    border-radius: 50%;
    animation: ktmTyping 1.4s infinite ease-in-out;
}

.ktm-dot:nth-child(1) { animation-delay: -0.32s; }
.ktm-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes ktmTyping {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Chat Input Bar */
.ktm-support-footer {
    background: #F0F2F5;
    padding: 10px 12px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ktm-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ktm-support-input {
    flex: 1;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 24px;
    padding: 9px 16px;
    font-size: 13.5px;
    color: #111b21;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

.ktm-support-input:focus {
    border-color: #128C7E;
    box-shadow: 0 0 0 2px rgba(18, 140, 126, 0.15);
}

.ktm-support-input::placeholder {
    color: #94a3b8;
}

.ktm-btn-send {
    background: #128C7E;
    color: #ffffff;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ktm-btn-send:hover {
    background: #075E54;
    transform: scale(1.06);
}

.ktm-btn-send svg {
    width: 17px;
    height: 17px;
    fill: currentColor;
}

.ktm-footer-wa-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 11.5px;
    color: #475569;
    text-align: center;
    padding-top: 2px;
}

.ktm-footer-wa-bar a {
    color: #075E54;
    font-weight: 700;
    text-decoration: underline;
}

/* Backdrop for Mobile */
.ktm-support-backdrop {
    display: none;
}

/* ==========================================================================
   Responsive & Mobil Uyumluluk
   ========================================================================== */
@media (max-width: 768px) {
    /* Tetikleyici buton mobilde alt tab barın (mobile-tab-bar) üzerinde kalır */
    .ktm-support-trigger {
        bottom: calc(84px + env(safe-area-inset-bottom, 0px));
        right: 14px;
        padding: 6px 12px 6px 8px;
        box-shadow: 0 6px 16px rgba(37, 211, 102, 0.4);
    }

    .ktm-trigger-icon-wrap {
        width: 36px;
        height: 36px;
    }

    .ktm-trigger-icon-wrap img {
        width: 26px;
        height: 26px;
    }

    .ktm-trigger-title {
        font-size: 12px;
    }

    .ktm-trigger-sub {
        font-size: 10px;
    }

    /* Mobilde Açılan Widget */
    .ktm-support-widget {
        bottom: calc(76px + env(safe-area-inset-bottom, 0px));
        right: 10px;
        left: 10px;
        width: auto;
        max-width: none;
        height: calc(100vh - 180px);
        max-height: 520px;
        border-radius: 16px;
    }

    .ktm-support-backdrop.active {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(15, 23, 42, 0.4);
        backdrop-filter: blur(3px);
        z-index: 99992;
    }
}
