.ai-assistant-container {
    position: fixed;
    bottom: 0;
    right: 0;
    z-index: 1030;
}

/* ==============================
   Desktop + Tablet: Right Panel Dock Mode
   - Panel içi overlay (fixed yerine)
   - right-panel-card ile görsel uyum (radius/ölçü)
   ============================== */
@media (min-width: 768px) {
    .ai-assistant-container.ai-docked-right-panel {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        border-radius: 14px;
        /* chart-card/right-panel-card ile aynı */
        z-index: 1030;
        /* panel-header (1040) altında kalır, chart-badge + tabs üstünde */
        bottom: auto;
        right: auto;
        pointer-events: none;
        /* kapalıyken alttaki panel tıklanabilsin */
    }

    .ai-assistant-container.ai-docked-right-panel.ai-open {
        pointer-events: auto;
        /* açılınca overlay tıklamaları alsın */
    }

    /* Desktop'ta floating buton gizli, rightTabs içindeki sekme kullanılacak */
    .ai-assistant-container.ai-docked-right-panel .ai-assistant-btn {
        display: none !important;
    }
}

.ai-assistant-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #0F5A4F;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    transition: all 0.3s ease;
    margin: 0 20px 20px 0;
    box-shadow: 0 4px 12px rgba(15, 90, 79, 0.3);
}

.ai-assistant-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.ai-assistant-btn:active {
    transform: scale(0.95);
}

.ai-assistant-nudge-pulse {
    animation: aiAssistantPulse 1.6s ease-in-out infinite;
}

@keyframes aiAssistantPulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(15, 90, 79, 0.3);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(15, 90, 79, 0.14), 0 4px 16px rgba(15, 90, 79, 0.45);
    }
}

.ai-assistant-intro-tooltip {
    position: fixed;
    z-index: 10001;
    width: min(280px, calc(100vw - 16px));
    background: #fff;
    border: 1px solid rgba(15, 23, 42, .12);
    border-radius: 12px;
    box-shadow: 0 14px 28px rgba(2, 6, 23, .18);
    padding: 12px;
}

.ai-assistant-intro-tooltip__title {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 4px;
}

.ai-assistant-intro-tooltip__text {
    font-size: 13px;
    color: #475569;
    margin-bottom: 10px;
}

.ai-assistant-intro-tooltip__actions {
    display: flex;
    gap: 8px;
}

/* Home page: mobile floating button alignment with hero actions */
@media (max-width: 767.98px) {
    body.home-page .ai-assistant-btn {
        margin-right: 12px;
        margin-bottom: 12px;
    }
}

.ai-chat-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--astro-sand);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: block;
    visibility: hidden;
    pointer-events: none;
    opacity: 0;
    overflow: visible;
    /* desktop'ta chart-badge için */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(20px) scale(0.95);
}

.ai-chat-window.show {
    visibility: visible;
    pointer-events: auto;
    opacity: 1;
    transform: translateY(0) scale(1);
}

.ai-chat-shell {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 16px;
    background: var(--astro-sand);
}

.ai-right-panel-badge {
    /* panel.css içindeki .chart-badge görünümünü kullanır */
    pointer-events: none;
}

.ai-chat-header {
    background: linear-gradient(135deg, var(--astro-ocean) 0%, var(--astro-deep-teal) 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 16px 16px 0 0;
}

.ai-chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.ai-chat-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}

.ai-chat-context-badge {
    font-weight: 600;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-chat-header h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-chat-header .btn-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.ai-chat-header .btn-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.ai-chat-header .btn-close i {
    pointer-events: none;
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--astro-parchment);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: var(--astro-clay);
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--astro-beige);
}

/* Chat'in gördüğü veri: Doğum + Transit açıları */
.ai-chat-aspect-data-container {
    background: #f8f9fa;
    border-bottom: 1px solid var(--astro-clay, #ddd);
    flex-shrink: 0;
}
.ai-chat-aspect-data-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    color: #333;
}
.ai-chat-aspect-data-toggle {
    padding: 4px 8px;
    font-size: 14px;
}
.ai-chat-aspect-data-body {
    padding: 0 14px 14px;
    max-height: 280px;
    overflow-y: auto;
}
.ai-chat-aspect-data-body .table {
    font-size: 11px;
}
.ai-chat-aspect-data-loading {
    padding: 12px 0;
    color: #666;
    font-size: 12px;
}
.ai-chat-aspect-data-error {
    padding: 8px 0;
    font-size: 12px;
}

.ai-message {
    display: flex;
    gap: 10px;
    animation: fadeIn 0.3s ease;
}

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

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

.ai-message.user {
    flex-direction: row-reverse;
}

.ai-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}

.ai-message.user .ai-message-avatar {
    background: linear-gradient(135deg, var(--astro-ocean) 0%, var(--astro-deep-teal) 100%);
    color: white;
}

.ai-message.assistant .ai-message-avatar {
    background: var(--astro-light-beige);
    color: var(--astro-dark-teal);
}

.ai-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 16px;
    line-height: 1.5;
    word-wrap: break-word;
}

.ai-message-actions {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ai-message-actions .btn {
    white-space: normal;
    text-align: left;
}

.ai-message.user .ai-message-content {
    background: linear-gradient(135deg, var(--astro-ocean) 0%, var(--astro-deep-teal) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-message.assistant .ai-message-content {
    background: var(--astro-light-cream);
    color: var(--astro-dark-teal);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Quota/Bakiye Hatası Özel Stili */
.ai-message.error .ai-message-content {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    border: 2px solid #ef4444;
    border-left: 4px solid #dc2626;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);
    line-height: 1.6;
}

.ai-message.error .ai-message-content a {
    color: #dc2626;
    text-decoration: underline;
    font-weight: 600;
    transition: all 0.2s ease;
}

.ai-message.error .ai-message-content a:hover {
    color: #991b1b;
    text-decoration: none;
}

.ai-message.error .ai-message-content ol {
    margin: 8px 0 0 20px;
    padding: 0;
    line-height: 1.8;
}

.ai-message.error .ai-message-content li {
    margin-bottom: 4px;
}

.ai-message.error .ai-message-avatar {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    animation: pulse-error 2s infinite;
}

@keyframes pulse-error {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.9;
    }
}

.ai-chat-input-container {
    padding: 16px;
    background: var(--astro-sand);
    border-top: 1px solid var(--astro-clay);
    display: flex;
    gap: 10px;
    align-items: center;
}

.ai-chat-input-wrapper {
    flex: 1;
    position: relative;
}

.ai-chat-input {
    width: 100%;
    border: 1px solid var(--astro-clay);
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 16px;
    resize: none;
    max-height: 120px;
    background: var(--astro-light-cream);
    color: var(--astro-dark-teal);
    transition: all 0.2s ease;
}

.ai-chat-input:focus {
    outline: none;
    border-color: var(--astro-ocean);
    box-shadow: 0 0 0 3px rgba(51, 101, 138, 0.1);
}

.ai-chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--astro-ocean) 0%, var(--astro-deep-teal) 100%);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ai-chat-send-btn:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(51, 101, 138, 0.4);
}

.ai-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--astro-dark-teal);
}

.ai-welcome-message i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.ai-welcome-message p {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
}

.ai-welcome-message h6 {
    font-size: 16px;
    margin-bottom: 12px;
    font-weight: 600;
}

/* ✅ Fade-in animasyonu için */
.welcome-fade-in {
    animation: welcomeFadeIn 0.8s ease-out;
}

@keyframes welcomeFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

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

/* Yükleniyor Animasyonu */
.ai-loading-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
}

.ai-typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--astro-ocean);
    animation: typingAnimation 1.4s infinite ease-in-out;
}

.ai-typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

.ai-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingAnimation {

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

    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Streaming cursor (yazıyor efekti) */
.ai-stream-cursor {
    display: inline-block;
    width: 1px;
    height: 14px;
    margin-left: 2px;
    vertical-align: baseline;
    background: var(--astro-ocean);
    border-radius: 2px;
    animation: aiCursorBlink 0.9s steps(1) infinite;
}

@keyframes aiCursorBlink {

    0%,
    49% {
        opacity: 1;
    }

    50%,
    100% {
        opacity: 0;
    }
}

/* Disabled state */
.ai-chat-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--astro-very-light-beige);
}

/* Desktop + Tablet dock görünümü: right-panel-card ile birebir hizalama */
@media (min-width: 768px) {
    .ai-assistant-container.ai-docked-right-panel .ai-chat-window {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        bottom: auto;
        right: auto;
        box-shadow: none;
        /* right-panel-card zaten gölgeli */
        z-index: 81;
    }
 
    .ai-assistant-container.ai-docked-right-panel .ai-chat-shell {
        border-radius: 14px;
        /* chart-card/right-panel-card ile aynı */
        background: #fff;
    }

    .ai-assistant-container.ai-docked-right-panel .ai-chat-header {
        background: linear-gradient(180deg, #ffffff, #fafafa);
        color: #0f172a;
        border-radius: 14px 14px 0 0;
        border-bottom: 1px solid rgba(15, 23, 42, .08);
    }

    .ai-assistant-container.ai-docked-right-panel .ai-chat-header .btn-close {
        background: rgba(15, 23, 42, .06);
        color: #0f172a;
    }

    .ai-assistant-container.ai-docked-right-panel .ai-chat-header .btn-close:hover {
        background: rgba(15, 23, 42, .10);
    }

    .ai-assistant-container.ai-docked-right-panel .ai-chat-messages {
        background: #fff;
    }

    /* Sağ panel tab bar'daki butonun görünümü (mevcut nav-link stiliyle uyumlu) */
    .ai-right-panel-tab-btn {
        white-space: nowrap;
    }

 

    .right-tabs-bar .ai-right-panel-tab-item {
        position: fixed;
        /* ✅ viewport'a sabit */
        right: 18px;
        bottom: 4px;
        /* ✅ sağ-alt */
        top: auto;
        transform: none;
        margin: 0;
        padding: 0;
        z-index: 9999;
        /* ✅ her şeyin üstünde */
    }

    .right-tabs-bar #aiAssistantRightTabBtn {
        width: 64px;
        height: 64px;
        border-radius: 50% !important;
        background: #0F5A4F !important;
        border: none !important;
        padding: 0 !important;
        cursor: pointer;
        display: flex !important;
        align-items: center;
        justify-content: center;
        color: #fff !important;
        font-size: 24px;
        transition: all 0.3s ease;
        box-shadow: 0 4px 12px rgba(15, 90, 79, 0.3);
        line-height: 1;
        position: relative;
    }

    .right-tabs-bar #aiAssistantRightTabBtn::before,
    .right-tabs-bar #aiAssistantRightTabBtn::after {
        content: '';
        position: absolute;
        inset: 0;
        border-radius: 50%;
        background: transparent;
        border: 2px solid rgba(255, 255, 255, 0.35);
        box-shadow: 0 0 12px rgba(255, 255, 255, 0.15), inset 0 0 8px rgba(255, 255, 255, 0.08);
        animation: ai-btn-pulse 2.2s ease-out infinite;
        pointer-events: none;
    }

    .right-tabs-bar #aiAssistantRightTabBtn::after {
        animation-delay: 1.1s;
    }

    @keyframes ai-btn-pulse {
        0%   { transform: scale(1);   opacity: 0.7; }
        60%  { opacity: 0.3; }
        100% { transform: scale(1.9); opacity: 0; }
    }

    .right-tabs-bar #aiAssistantRightTabBtn:hover {
        transform: scale(1.1);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    }

    .right-tabs-bar #aiAssistantRightTabBtn:active {
        transform: scale(0.95);
    }

    .right-tabs-bar #aiAssistantRightTabBtn i {
        pointer-events: none;
    }
}

@media (max-width: 576px) {
    .ai-chat-window {
        width: 100vw;
        right: 0;
        bottom: 0;
        height: 100vh;
        /* max-height: 100vh; */
        border-radius: 0;
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
    }

    .ai-chat-shell {
        border-radius: 0;
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
    }

    .ai-chat-header {
        border-radius: 0;
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
    }



    .ai-message-content {
        max-width: 85%;
    }
}



/* PDF Download Button */
.ai-chat-pdf-container {
    padding: 12px 20px;
    background: var(--astro-light-cream, #f9f7f4);
    border-top: 1px solid var(--astro-clay, #d4c5b8);
    display: flex;
    justify-content: center;
    align-items: center;
}

.ai-chat-pdf-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--astro-ocean, #0F5A4F) 0%, var(--astro-deep-teal, #0b423a) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(15, 90, 79, 0.2);
}

.ai-chat-pdf-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(15, 90, 79, 0.3);
}

.ai-chat-pdf-btn:active:not(:disabled) {
    transform: translateY(0);
}

.ai-chat-pdf-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ai-chat-pdf-btn i {
    font-size: 18px;
}