/* =====================================================
 * AI Chat Widget - Site-Integrated Design
 * Shared: Kurumsal + Kariyer
 * Uses site CSS variables for seamless integration
 * Supports: Light + Dark mode via [data-theme]
 * ===================================================== */

/* ── CSS Variables (Dark Mode - Default) ── */
:root {
    --chat-bg: rgba(10, 10, 10, 0.92);
    --chat-surface: rgba(20, 20, 20, 0.95);
    --chat-surface-hover: rgba(30, 30, 30, 0.95);
    --chat-surface-alt: rgba(15, 15, 15, 0.95);
    --chat-border: rgba(255, 255, 255, 0.08);
    --chat-border-strong: rgba(255, 255, 255, 0.12);
    --chat-text: #FFFFFF;
    --chat-text-secondary: #E0E0E0;
    --chat-text-muted: #888;
    --chat-accent: var(--brand-primary, #667eea);
    --chat-accent-secondary: var(--brand-secondary, #764ba2);
    --chat-accent-light: #8da2ff;
    --chat-accent-glow: rgba(102, 126, 234, 0.15);
    --chat-user-bubble: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
    --chat-user-bubble-solid: rgba(102, 126, 234, 0.15);
    --chat-user-bubble-text: #e0e4f0;
    --chat-ai-bubble: rgba(255, 255, 255, 0.04);
    --chat-ai-bubble-text: #d0d3da;
    --chat-input-bg: rgba(255, 255, 255, 0.05);
    --chat-success: #16a34a;
    --chat-success-bg: rgba(22, 163, 74, 0.08);
    --chat-danger: #f87171;
    --chat-danger-bg: rgba(248, 113, 113, 0.08);
    --chat-haiku-badge: #888;
    --chat-sonnet-badge: var(--brand-primary, #667eea);
    --chat-radius: 16px;
    --chat-radius-sm: 10px;
    --chat-radius-xs: 8px;
    --chat-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 1px rgba(255,255,255,0.1);
    --chat-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --chat-font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --chat-gradient: var(--gradient-primary, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
}

/* ── Light Mode Override ── */
[data-theme="light"] {
    --chat-bg: rgba(255, 255, 255, 0.96);
    --chat-surface: rgba(250, 250, 250, 0.98);
    --chat-surface-hover: rgba(240, 241, 243, 0.98);
    --chat-surface-alt: rgba(245, 245, 250, 0.98);
    --chat-border: rgba(0, 0, 0, 0.08);
    --chat-border-strong: rgba(0, 0, 0, 0.12);
    --chat-text: #1a1a2e;
    --chat-text-secondary: #4a4a5a;
    --chat-text-muted: #888;
    --chat-accent-light: #5570d4;
    --chat-accent-glow: rgba(102, 126, 234, 0.1);
    --chat-user-bubble: linear-gradient(135deg, rgba(102, 126, 234, 0.12) 0%, rgba(118, 75, 162, 0.12) 100%);
    --chat-user-bubble-solid: rgba(102, 126, 234, 0.1);
    --chat-user-bubble-text: #2d3348;
    --chat-ai-bubble: rgba(0, 0, 0, 0.03);
    --chat-ai-bubble-text: #333848;
    --chat-input-bg: #ffffff;
    --chat-success: #16a34a;
    --chat-success-bg: rgba(22, 163, 74, 0.06);
    --chat-danger: #dc2626;
    --chat-danger-bg: rgba(220, 38, 38, 0.06);
    --chat-haiku-badge: #7c8194;
    --chat-sonnet-badge: var(--brand-primary, #667eea);
    --chat-shadow: 0 20px 60px rgba(0, 0, 0, 0.12), 0 0 1px rgba(0,0,0,0.1);
}

/* ── Toggle Button ── */
.ai-chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--chat-gradient);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.35);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--chat-transition);
    padding: 0;
    outline: none;
}

.ai-chat-toggle:hover {
    box-shadow: 0 6px 28px rgba(102, 126, 234, 0.5), 0 0 20px rgba(102, 126, 234, 0.2);
    transform: translateY(-2px) scale(1.05);
}

.ai-chat-toggle.active {
    background: var(--chat-gradient);
    border: none;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.35);
}

.ai-chat-toggle svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: #ffffff !important;
    stroke-width: 2.8 !important;
    transition: all var(--chat-transition);
}

.ai-chat-toggle.active svg {
    stroke: #ffffff !important;
    stroke-width: 2.8 !important;
}

.ai-chat-toggle.active svg .toggle-open {
    display: none;
}

.ai-chat-toggle.active svg .toggle-close {
    display: block;
}

.ai-chat-toggle svg .toggle-close {
    display: none;
}

/* ── Chat Panel ── */
.ai-chat-panel {
    position: fixed;
    bottom: 88px;
    right: 24px;
    width: 400px;
    height: 560px;
    background: var(--chat-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--chat-border);
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: var(--chat-font);
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px) scale(0.97);
}

.ai-chat-panel.open {
    opacity: 1;
    pointer-events: auto;
    transform: none;
}

/* ── Header ── */
.ai-chat-header {
    padding: 16px 18px;
    background: var(--chat-surface);
    border-bottom: 1px solid var(--chat-border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

/* Header shine effect */
.ai-chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.04), transparent);
    transition: left 0.6s ease;
    pointer-events: none;
}

.ai-chat-header:hover::before {
    left: 100%;
}

.ai-chat-header-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--chat-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.ai-chat-header-icon svg {
    width: 16px;
    height: 16px;
    fill: #ffffff;
}

.ai-chat-header-info {
    flex: 1;
    min-width: 0;
}

.ai-chat-header-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--chat-text);
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.ai-chat-header-subtitle {
    font-size: 11.5px;
    color: var(--chat-text-muted);
    line-height: 1.3;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-chat-header-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.ai-chat-header-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    color: var(--chat-text-muted);
    cursor: pointer;
    border-radius: var(--chat-radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--chat-transition);
    padding: 0;
}

.ai-chat-header-btn:hover {
    background: var(--chat-surface-hover);
    color: var(--chat-text);
}

.ai-chat-header-btn svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

/* ── Quota Bar ── */
.ai-chat-quota {
    padding: 8px 18px;
    background: var(--chat-surface-alt);
    border-bottom: 1px solid var(--chat-border);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11px;
    color: var(--chat-text-muted);
    flex-shrink: 0;
}

.ai-chat-quota-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.ai-chat-quota-bar {
    width: 48px;
    height: 3px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
    overflow: hidden;
}

.ai-chat-quota-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
}

.ai-chat-quota-fill.total {
    background: var(--chat-text-muted);
}

.ai-chat-quota-fill.sonnet {
    background: var(--chat-accent);
}

.ai-chat-quota-separator {
    width: 1px;
    height: 12px;
    background: var(--chat-border-strong);
}

/* ── Messages Container ── */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

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

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

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.14);
}

[data-theme="light"] .ai-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.18);
}

/* ── Welcome Card ── */
.ai-chat-welcome {
    text-align: center;
    padding: 32px 20px;
    margin: auto 0;
}

.ai-chat-welcome-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: var(--chat-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.ai-chat-welcome-icon svg {
    width: 22px;
    height: 22px;
    fill: #ffffff;
}

.ai-chat-welcome-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--chat-text);
    margin-bottom: 6px;
}

.ai-chat-welcome-desc {
    font-size: 13px;
    color: var(--chat-text-muted);
    line-height: 1.5;
}

/* ── Message Bubbles ── */
.ai-chat-msg {
    max-width: 84%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
    position: relative;
}

.ai-chat-msg.user {
    align-self: flex-end;
    background: var(--chat-user-bubble);
    background-color: var(--chat-user-bubble-solid);
    color: var(--chat-user-bubble-text);
    border-bottom-right-radius: 4px;
    border: 1px solid rgba(102, 126, 234, 0.15);
}

.ai-chat-msg.assistant {
    align-self: flex-start;
    background: var(--chat-ai-bubble);
    color: var(--chat-ai-bubble-text);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--chat-border);
}

/* ── Model Badge ── */
.ai-chat-model-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 4px;
    margin-bottom: 6px;
}

.ai-chat-model-badge.haiku {
    background: rgba(107, 112, 128, 0.15);
    color: var(--chat-haiku-badge);
}

.ai-chat-model-badge.sonnet {
    background: var(--chat-accent-glow);
    color: var(--chat-sonnet-badge);
}

/* ── Cache Badge ── */
.ai-chat-cache-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    color: var(--chat-text-muted);
    margin-bottom: 6px;
    margin-left: 6px;
}

/* ── Approval Card ── */
.ai-chat-approval-card {
    background: var(--chat-surface);
    border: 1px solid var(--chat-border-strong);
    border-left: 3px solid var(--chat-accent);
    border-radius: var(--chat-radius-sm);
    padding: 12px 14px;
    margin-top: 8px;
}

.ai-chat-approval-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--chat-accent);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}

.ai-chat-approval-detail {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 3px 0;
    font-size: 12.5px;
}

.ai-chat-approval-key {
    color: var(--chat-text-muted);
    min-width: 70px;
    flex-shrink: 0;
}

.ai-chat-approval-value {
    color: var(--chat-text);
    font-weight: 500;
}

.ai-chat-approval-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.ai-chat-approval-btn {
    flex: 1;
    padding: 7px 14px;
    border-radius: var(--chat-radius-xs);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--chat-transition);
    border: 1.5px solid transparent;
    background: transparent;
    font-family: var(--chat-font);
}

.ai-chat-approval-btn.approve {
    border-color: var(--chat-success);
    color: var(--chat-success);
}

.ai-chat-approval-btn.approve:hover {
    background: var(--chat-success-bg);
}

.ai-chat-approval-btn.reject {
    border-color: var(--chat-danger);
    color: var(--chat-danger);
}

.ai-chat-approval-btn.reject:hover {
    background: var(--chat-danger-bg);
}

.ai-chat-approval-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ai-chat-approval-btn.approved {
    background: var(--chat-success);
    color: #fff;
    border-color: var(--chat-success);
}

.ai-chat-approval-btn.rejected {
    background: var(--chat-danger);
    color: #fff;
    border-color: var(--chat-danger);
}

/* ── Error Message ── */
.ai-chat-error {
    padding: 8px 12px;
    background: var(--chat-danger-bg);
    border: 1px solid rgba(248, 113, 113, 0.15);
    border-radius: var(--chat-radius-sm);
    color: var(--chat-danger);
    font-size: 12.5px;
    text-align: center;
}

/* ── Rate Limit / Premium Upsell ── */
.ai-chat-rate-limit {
    margin: 12px 8px;
    padding: 16px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: var(--chat-radius);
    text-align: center;
}
.ai-rate-limit-icon {
    font-size: 28px;
    margin-bottom: 8px;
}
.ai-rate-limit-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--chat-text);
    margin-bottom: 4px;
}
.ai-rate-limit-count {
    font-size: 12px;
    color: var(--chat-text-muted);
    margin-bottom: 8px;
}
.ai-rate-limit-reset {
    font-size: 12.5px;
    color: var(--chat-text-muted);
    margin-bottom: 12px;
    padding: 6px 10px;
    background: rgba(102, 126, 234, 0.06);
    border-radius: var(--chat-radius-sm);
}
.ai-rate-limit-upsell {
    margin-top: 12px;
    padding: 12px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: var(--chat-radius-sm);
}
.ai-rate-limit-upsell-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--brand-primary, #667eea);
    margin-bottom: 4px;
}
.ai-rate-limit-upsell-desc {
    font-size: 12px;
    color: var(--chat-text-muted);
    margin-bottom: 10px;
}
.ai-rate-limit-btn {
    display: inline-block;
    padding: 8px 20px;
    background: var(--chat-gradient);
    color: #fff !important;
    border-radius: 20px;
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
}
.ai-rate-limit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}

/* ── Load More ── */
.ai-chat-load-more {
    text-align: center;
    padding: 6px;
}

.ai-chat-load-more button {
    background: transparent;
    border: 1px solid var(--chat-border-strong);
    color: var(--chat-text-muted);
    font-size: 11.5px;
    padding: 5px 14px;
    border-radius: 20px;
    cursor: pointer;
    transition: all var(--chat-transition);
    font-family: var(--chat-font);
}

.ai-chat-load-more button:hover {
    border-color: var(--chat-accent);
    color: var(--chat-accent-light);
}

/* ── Loading Indicator ── */
.ai-chat-loading {
    display: flex;
    gap: 5px;
    padding: 10px 14px;
    align-self: flex-start;
}

.ai-chat-loading-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--chat-accent);
    animation: chatDotPulse 1.4s ease-in-out infinite;
}

.ai-chat-loading-dot:nth-child(2) {
    animation-delay: 0.16s;
    background: var(--chat-accent-secondary);
}

.ai-chat-loading-dot:nth-child(3) {
    animation-delay: 0.32s;
}

@keyframes chatDotPulse {
    0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
    40% { opacity: 1; transform: scale(1); }
}

/* ── Navigate Button ── */
.ai-chat-navigate-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 14px;
    margin-top: 6px;
    background: transparent;
    border: 1px solid var(--chat-border-strong);
    border-radius: 20px;
    color: var(--chat-accent-light);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--chat-transition);
    font-family: var(--chat-font);
}

.ai-chat-navigate-btn:hover {
    background: var(--chat-accent-glow);
    border-color: var(--chat-accent);
}

/* ── Input Area ── */
.ai-chat-input-area {
    padding: 12px 14px;
    background: var(--chat-surface);
    border-top: 1px solid var(--chat-border);
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

.ai-chat-input {
    flex: 1;
    background: var(--chat-input-bg);
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    padding: 9px 14px;
    font-size: 13.5px;
    color: var(--chat-text);
    outline: none;
    resize: none;
    max-height: 80px;
    min-height: 38px;
    line-height: 1.5;
    font-family: var(--chat-font);
    transition: border-color var(--chat-transition), box-shadow var(--chat-transition);
}

.ai-chat-input::placeholder {
    color: var(--chat-text-muted);
}

.ai-chat-input:focus {
    border-color: rgba(102, 126, 234, 0.4);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.08);
}

.ai-chat-send-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--chat-gradient);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--chat-transition);
    flex-shrink: 0;
    padding: 0;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.ai-chat-send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(102, 126, 234, 0.45);
}

.ai-chat-send-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.ai-chat-send-btn svg {
    width: 16px;
    height: 16px;
    fill: #ffffff;
}

/* ── Markdown Styles ── */
.ai-chat-msg.assistant h3,
.ai-chat-msg.assistant .ai-md-h3 {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--chat-text);
    margin: 8px 0 4px;
}

.ai-chat-msg.assistant h4,
.ai-chat-msg.assistant .ai-md-h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--chat-text);
    margin: 6px 0 3px;
}

.ai-chat-msg.assistant table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 12px;
}

.ai-chat-msg.assistant thead {
    background: rgba(102, 126, 234, 0.06);
}

.ai-chat-msg.assistant th {
    font-weight: 600;
    text-align: left;
    padding: 6px 8px;
    color: var(--chat-text-secondary);
    border-bottom: 1px solid var(--chat-border-strong);
}

.ai-chat-msg.assistant td {
    padding: 5px 8px;
    border-bottom: 1px solid var(--chat-border);
    color: var(--chat-ai-bubble-text);
}

.ai-chat-msg.assistant tr:last-child td {
    border-bottom: none;
}

.ai-chat-msg.assistant ul,
.ai-chat-msg.assistant ol {
    margin: 4px 0;
    padding-left: 18px;
}

.ai-chat-msg.assistant li {
    margin: 2px 0;
}

.ai-chat-msg.assistant code {
    background: rgba(102, 126, 234, 0.1);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'Inter', sans-serif;
}

.ai-chat-msg.assistant strong {
    font-weight: 600;
    color: var(--chat-text);
}

.ai-chat-msg.assistant hr,
.ai-chat-msg.assistant .ai-md-hr {
    border: none;
    border-top: 1px solid var(--chat-border);
    margin: 8px 0;
}

/* ── Excel Download Modal ── */
.ai-chat-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: chatFadeIn 0.2s ease;
}

@keyframes chatFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ai-chat-modal {
    background: var(--chat-surface);
    border: 1px solid var(--chat-border-strong);
    border-radius: var(--chat-radius);
    width: 360px;
    max-width: 90vw;
    animation: chatModalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

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

.ai-chat-modal-header {
    padding: 16px 18px;
    border-bottom: 1px solid var(--chat-border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-chat-modal-header-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--chat-success-bg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-modal-header-icon svg {
    width: 16px;
    height: 16px;
    stroke: var(--chat-success);
    fill: none;
    stroke-width: 2;
}

.ai-chat-modal-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--chat-text);
}

.ai-chat-modal-close {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--chat-text-muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 4px;
}

.ai-chat-modal-body {
    padding: 18px;
}

.ai-chat-modal-message {
    font-size: 13px;
    color: var(--chat-text-secondary);
    margin-bottom: 14px;
    line-height: 1.5;
}

.ai-chat-modal-info {
    background: var(--chat-bg);
    border-radius: var(--chat-radius-sm);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ai-chat-modal-info-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
}

.ai-chat-modal-info-label {
    color: var(--chat-text-muted);
}

.ai-chat-modal-info-value {
    color: var(--chat-text);
    font-weight: 500;
}

.ai-chat-modal-footer {
    padding: 14px 18px;
    border-top: 1px solid var(--chat-border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.ai-chat-modal-btn {
    padding: 8px 18px;
    border-radius: var(--chat-radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--chat-transition);
    font-family: var(--chat-font);
    border: 1px solid transparent;
}

.ai-chat-modal-btn.cancel {
    background: transparent;
    border-color: var(--chat-border-strong);
    color: var(--chat-text-muted);
}

.ai-chat-modal-btn.cancel:hover {
    background: var(--chat-surface-hover);
    color: var(--chat-text);
}

.ai-chat-modal-btn.download {
    background: var(--chat-success);
    color: #ffffff;
    border-color: var(--chat-success);
}

.ai-chat-modal-btn.download:hover {
    opacity: 0.9;
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

/* ── Light Mode Overrides ── */
[data-theme="light"] .ai-chat-toggle {
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.25);
}

[data-theme="light"] .ai-chat-toggle:hover {
    box-shadow: 0 6px 28px rgba(102, 126, 234, 0.4), 0 0 16px rgba(102, 126, 234, 0.15);
}

[data-theme="light"] .ai-chat-panel {
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .ai-chat-input {
    border-color: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .ai-chat-input:focus {
    border-color: rgba(102, 126, 234, 0.4);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.06);
}

[data-theme="light"] .ai-chat-send-btn svg {
    fill: #ffffff;
}

[data-theme="light"] .ai-chat-msg.user {
    border-color: rgba(102, 126, 234, 0.1);
}

[data-theme="light"] .ai-chat-msg.assistant {
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .ai-chat-msg.assistant code {
    background: rgba(102, 126, 234, 0.08);
}

[data-theme="light"] .ai-chat-msg.assistant thead {
    background: rgba(102, 126, 234, 0.04);
}

[data-theme="light"] .ai-chat-msg.assistant td {
    border-bottom-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .ai-chat-msg.assistant th {
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .ai-chat-quota-bar {
    background: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .ai-chat-modal-overlay {
    background: rgba(0, 0, 0, 0.35);
}

/* ── Dark Mode: Premium Glow Toggle ── */
[data-theme="dark"] .ai-chat-toggle {
    animation: chat-premium-glow 3s ease-in-out infinite;
}

[data-theme="dark"] .ai-chat-toggle:hover {
    animation: none;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.5), 0 0 40px rgba(118, 75, 162, 0.2);
}

[data-theme="dark"] .ai-chat-toggle.active {
    animation: none;
}

@keyframes chat-premium-glow {
    0%, 100% {
        box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
    }
    50% {
        box-shadow: 0 4px 24px rgba(102, 126, 234, 0.45), 0 0 20px rgba(118, 75, 162, 0.2);
    }
}

/* ── Responsive ── */
@media (max-width: 480px) {
    .ai-chat-panel {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .ai-chat-toggle {
        bottom: 16px;
        right: 16px;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .ai-chat-panel {
        width: 360px;
        height: 500px;
    }
}

/* ── Streaming Styles ── */
.ai-chat-msg.streaming::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 14px;
    background: var(--chat-accent);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: ai-blink 0.8s infinite;
}

@keyframes ai-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.ai-stream-tool {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--chat-text-muted);
    padding: 4px 0;
    margin-top: 4px;
}

.ai-stream-tool-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--chat-accent);
    animation: ai-pulse 1.2s infinite;
}

@keyframes ai-pulse {
    0%, 100% { opacity: 0.4; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.1); }
}
