/* ShopGuide Chatbot - Flat & Sexy Design */

:root {
    /* Main Brand Colors - Will be overridable via Admin Panel */
    --sgc-primary: #2563eb;
    /* Canlı Mavi */
    --sgc-primary-text: #ffffff;
    /* Primary üzerindeki yazı */
    --sgc-accent: #2563eb;
    /* Mavi (Launcher İkonu) */
    --sgc-accent-text: #ffffff;
    /* Accent üzerindeki yazı */

    /* Neutral Colors */
    --sgc-bg: #ffffff;
    --sgc-surface: #f8fafc;
    --sgc-text-main: #1e293b;
    --sgc-text-sub: #64748b;
    --sgc-border: #e2e8f0;

    /* Dimensions & Spacing */
    --sgc-radius: 16px;
    --sgc-spacing: 16px;

    /* Typography */
    --sgc-font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    /* Shadows */
    --sgc-shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --sgc-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

#sgc-chat-wrapper {
    position: fixed;
    z-index: 999999;
    font-family: var(--sgc-font);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 20px;
    /* Default Positioning */
    bottom: 30px;
    right: 30px;
    transition: all 0.3s ease;
    pointer-events: none;
}

/* Pulse Control */
.sgc-pulse-disabled #sgc-trigger-btn::before,
.sgc-pulse-disabled #sgc-trigger-btn::after {
    animation: none !important;
    display: none !important;
}

/* Positioning - DESKTOP and MOBILE are now handled dynamically via Inline CSS */

@media (max-width: 768px) {

    /* Mobile Fullscreen Mode */
    #sgc-chat-wrapper.sgc-mobile-fullscreen #sgc-chat-window {
        position: fixed;
        width: 100vw;
        height: 100dvh;
        /* dynamic viewport height */
        max-width: 100%;
        max-height: 100%;
        bottom: 0;
        right: 0;
        left: 0;
        border-radius: 0;
        z-index: 1000000;
        margin: 0;
        transform: translateY(100vh);
        /* Start off-screen */
    }

    #sgc-chat-wrapper.sgc-mobile-fullscreen #sgc-chat-window.sgc-visible {
        transform: translateY(0);
        opacity: 1;
    }
}

/* -------------------------------------------------------------------------- */
/* LAUNCHER BUTTON (The "Sexy" Pulse Part) */
/* -------------------------------------------------------------------------- */
#sgc-trigger-btn {
	all: unset;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--sgc-accent);
    color: var(--sgc-accent-text);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--sgc-shadow-md);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    position: relative;
    z-index: 20;
    pointer-events: auto;
}

#sgc-trigger-btn svg {
    width: 32px;
    height: 32px;
    fill: currentColor;
    transition: all 0.3s ease;
}

/* Hover Effects */
#sgc-trigger-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.6);
    /* Glow mathing blue */
}

/* Pulse Animation Ring */
#sgc-trigger-btn::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border-radius: 50%;
    border: 2px solid var(--sgc-accent);
    opacity: 0.6;
    animation: sgc-pulse-ring 2s infinite;
    z-index: -1;
}

/* Second Pulse Ring for extra "sexiness" */
#sgc-trigger-btn::after {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border-radius: 50%;
    background: var(--sgc-accent);
    opacity: 0.2;
    animation: sgc-pulse-dot 2s infinite;
    z-index: -2;
}

@keyframes sgc-pulse-ring {
    0% {
        transform: scale(0.9);
        opacity: 0.6;
    }

    50% {
        opacity: 0;
    }

    100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

@keyframes sgc-pulse-dot {
    0% {
        transform: scale(0.9);
        opacity: 0.4;
    }

    50% {
        opacity: 0;
    }

    100% {
        transform: scale(1.8);
        opacity: 0;
    }
}

/* Active State (Open) - Stop Pulse, Morph Icon */
#sgc-trigger-btn.sgc-active {
    background: var(--sgc-text-main);
    /* Darker background when open */
    color: white;
    transform: rotate(90deg);
}

#sgc-trigger-btn.sgc-active::before,
#sgc-trigger-btn.sgc-active::after {
    animation: none;
    opacity: 0;
}

#sgc-trigger-btn .sgc-icon-close {
    display: none;
}

#sgc-trigger-btn.sgc-active .sgc-icon-open {
    display: none;
}

#sgc-trigger-btn.sgc-active .sgc-icon-close {
    display: block;
}


/* -------------------------------------------------------------------------- */
/* CHAT WINDOW (Flat Design) */
/* -------------------------------------------------------------------------- */
#sgc-chat-window {
    width: 380px;
    height: 600px;
    max-height: 80vh;
    max-width: calc(100vw - 40px);
    background: var(--sgc-bg);
    border-radius: var(--sgc-radius);
    box-shadow: var(--sgc-shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* Animation State */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#sgc-chat-wrapper.sgc-open #sgc-chat-window {
    opacity: 1 !important;
    transform: translateY(0) scale(1) !important;
    pointer-events: auto !important;
    visibility: visible !important;
    z-index: 1000000;
}

/* HEADER */
.sgc-header {
    background: var(--sgc-primary);
    color: var(--sgc-primary-text);
    padding: 20px;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sgc-header-top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.sgc-header-title {
    font-weight: 700;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sgc-header-actions {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

.sgc-action-btn {
	all: unset;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    border: none;
    color: white;
}

.sgc-action-btn:hover {
	all: unset;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    border: none;
    color: white;
    background: rgba(255, 255, 255, 0.3);
}

.sgc-action-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* BODY */
.sgc-body {
    flex: 1;
    background: var(--sgc-surface);
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Message Styles injected via JS */
.sgc-message {
    margin-bottom: 10px;
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 80%;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.sgc-message-user {
    align-self: flex-end;
    background: var(--sgc-primary);
    color: white;
    border-bottom-right-radius: 2px;
}

.sgc-message-bot {
    align-self: flex-start;
    background: white;
    color: var(--sgc-text-main);
    border: 1px solid var(--sgc-border);
    border-bottom-left-radius: 2px;
}

/* TYPING INDICATOR (YAZIYOR...) */
.sgc-typing-bubble {
    padding: 12px 16px;
    background: #fff;
    border: 1px solid var(--sgc-border);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    width: fit-content;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    margin-bottom: 10px;
}

.sgc-typing-dot {
    width: 6px;
    height: 6px;
    background: var(--sgc-text-sub);
    border-radius: 50%;
    animation: sgc-typing-bounce 1.4s infinite ease-in-out both;
    opacity: 0.6;
}

.sgc-typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.sgc-typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes sgc-typing-bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* MESSAGES */
.sgc-message-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.sgc-message-row.sgc-user-row {
    justify-content: flex-end;
}

.sgc-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--sgc-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 5px;
}

.sgc-avatar svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.sgc-bubble {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    max-width: 80%;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
	box-sizing: unset!important;
}

.sgc-bot .sgc-bubble {
    background: white;
    color: var(--sgc-text-main);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--sgc-border);
}

.sgc-user .sgc-bubble {
    background: var(--sgc-primary);
    color: var(--sgc-primary-text);
    border-bottom-right-radius: 4px;
}

.sgc-meta {
    font-size: 11px;
    color: var(--sgc-text-sub);
    margin-top: 4px;
    margin-left: 48px;
    /* Align with text */
}

/* QUICK ACTIONS (Buttons) */
.sgc-quick-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    margin-left: 48px;
    /* Align with bot text */
}

.sgc-btn-outline {
    background: transparent;
    border: 1px solid var(--sgc-primary);
    color: var(--sgc-primary);
    padding: 10px;
    border-radius: 8px;
    /* Slightly rounded, flat */
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.sgc-btn-outline:hover {
    background: var(--sgc-primary);
    color: white;
}


/* FOOTER */
.sgc-footer {
    padding: 15px;
    background: white;
    border-top: 1px solid var(--sgc-border);
}

.sgc-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--sgc-surface);
    border: 1px solid var(--sgc-border);
    border-radius: 24px;
    padding: 6px 6px 6px 16px;
    transition: border 0.2s;
}

.sgc-input-wrapper:focus-within {
    border-color: var(--sgc-primary);
}

.sgc-input-wrapper input {
    flex: 1;
    border: none !important;
    background: transparent !important;
    outline: none;
    font-size: 14px;
    color: var(--sgc-text-main) !important;
    padding: 8px 0 !important;
    box-shadow: unset !important;
}

.sgc-send-btn {
	all: unset;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--sgc-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: transform 0.2s;
}

.sgc-send-btn:hover {
	all: unset;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--sgc-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: transform 0.2s;
    transform: scale(1.05);
}
.sgc-input-wrapper input:focus{
    background-color: transparent!important;
    outline-color: unset!important;
    outline: unset!important;
}
.sgc-send-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Branding Link */
.sgc-branding {
    text-align: center;
    font-size: 10px;
    color: var(--sgc-text-sub);
    padding: 8px;
    background: var(--sgc-bg);
    display: none;
}

/* -------------------------------------------------------------------------- */
/* MARKDOWN CONTENT STYLES (New) */
/* -------------------------------------------------------------------------- */
.sgc-bubble p {
    margin: 0 0 8px 0 !important;
}

.sgc-bubble p:last-child {
    margin-bottom: 0 !important;
}

.sgc-bubble strong,
.sgc-bubble b {
    font-weight: 700;
}

.sgc-bubble em,
.sgc-bubble i {
    font-style: italic;
}

.sgc-bubble ul,
.sgc-bubble ol {
    margin: 6px 0 6px 0 !important;
    padding-left: 20px !important;
    list-style-type: disc !important;
}

.sgc-bubble ol {
    list-style-type: decimal !important;
}

.sgc-bubble li {
    margin-bottom: 4px !important;
}

.sgc-bubble a {
    color: var(--sgc-primary);
    text-decoration: underline;
    word-break: break-all;
}

.sgc-bubble a:hover {
    text-decoration: none;
    opacity: 0.8;
}

.sgc-bubble pre {
    background: #f1f5f9;
    padding: 8px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 12px;
    margin: 8px 0;
    font-family: monospace;
}

.sgc-bubble code {
    background: #f1f5f9;
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 13px;
    color: #e11d48;
}

/* User msg overwrite */
.sgc-user .sgc-bubble a {
    color: white;
}

.sgc-user .sgc-bubble code {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* --- CTA BUBBLE STYLES (New Feature) --- */
.sgc-cta-bubble {
    position: absolute;
    bottom: 80px;
    /* Trigger butonunun üstünde */
    right: 0;
    /* Trigger butonu ile hizalı */
    background: #fff;
    padding: 12px 16px;
    border-radius: 12px 12px 2px 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    z-index: 999998;
    /* Chat penceresinin altında ama butondan da bağımsız */
    width: 260px;
    cursor: pointer;
    border: 1px solid var(--sgc-border);
    transition: all 0.3s ease;
    animation: sgc-fade-in-up 0.5s ease backwards;
    animation-delay: 1s;
    /* Biraz bekleyip çıksın */
    pointer-events: auto;
}

/* Küçük ok */
.sgc-cta-bubble::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 20px;
    width: 12px;
    height: 12px;
    background: #fff;
    transform: rotate(45deg);
    border-right: 1px solid var(--sgc-border);
    border-bottom: 1px solid var(--sgc-border);
}

.sgc-cta-text {
    font-size: 14px;
    color: var(--sgc-text-main);
    font-weight: 500;
    line-height: 1.4;
    display: block;
}

.sgc-cta-bubble:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

/* Chat açıkken gizle */
#sgc-chat-wrapper.sgc-open .sgc-cta-bubble {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

@keyframes sgc-fade-in-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobilde Pozisyon Ayarı */
@media (max-width: 768px) {
    .sgc-cta-bubble {
        bottom: 80px;
        right: 10px;
        width: auto;
        max-width: 250px;
    }
}

/* --- LEAD GENERATION FORM --- */
.sgc-lead-form-wrapper {
    flex-direction: row;
    /* Bot mesajı gibi Avatar sola */
    align-items: flex-end;
}

.sgc-lead-card {
    background: #fff;
    border: 1px solid var(--sgc-border);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    padding: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    width: 100%;
    max-width: 280px;
}

.sgc-lead-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--sgc-text-main);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sgc-lead-desc {
    font-size: 12px;
    color: var(--sgc-text-sub);
    margin-bottom: 12px;
    line-height: 1.4;
}

.sgc-lead-input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--sgc-border);
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: 0.2s;
    box-sizing: border-box;
    /* Padding taşmasın */
}

.sgc-lead-input:focus {
    border-color: var(--sgc-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.sgc-lead-btn {
    width: 100%;
    background: #16a34a;
    /* Yeşil - Call to Action rengi */
    color: white;
    border: none;
    padding: 10px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: 0.2s;
}

.sgc-lead-btn:hover {
    background: #15803d;
}

.sgc-lead-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}