/* === AI Chat — "Zapytaj o dane" === */

/* Floating Action Button */
.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--gold, #c9962b);
    border: none;
    cursor: pointer;
    z-index: 8000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s, background 0.2s;
    color: #000;
}

.chat-fab:hover {
    transform: scale(1.08);
    background: #d4a535;
}

.chat-fab--active {
    background: var(--bg-card, #1c2128);
    color: var(--text-muted, #8b949e);
    border: 1px solid var(--border, #30363d);
}

.chat-fab--active:hover {
    background: var(--bg-card-hover, #252b33);
}

/* Chat Panel */
.chat-panel {
    position: fixed;
    bottom: 88px;
    right: 24px;
    width: 400px;
    max-height: 560px;
    background: var(--bg-card, #161b22);
    border: 1px solid var(--border, #30363d);
    border-radius: 16px;
    z-index: 8001;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

/* Header */
.chat-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border, #30363d);
    background: var(--bg-surface, #0d1117);
}

.chat-panel__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-heading, #e6edf3);
}

.chat-panel__title svg {
    color: var(--gold, #c9962b);
}

.chat-panel__close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted, #8b949e);
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
}

.chat-panel__close:hover {
    color: var(--text-heading, #e6edf3);
    background: var(--bg-card-hover, #252b33);
}

/* Messages area */
.chat-panel__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 300px;
    max-height: 400px;
}

/* Scrollbar */
.chat-panel__messages::-webkit-scrollbar {
    width: 4px;
}

.chat-panel__messages::-webkit-scrollbar-thumb {
    background: var(--border, #30363d);
    border-radius: 4px;
}

/* Message layout */
.chat-msg {
    display: flex;
}

.chat-msg--user {
    justify-content: flex-end;
}

.chat-msg--assistant {
    justify-content: flex-start;
}

/* Bubbles */
.chat-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.8125rem;
    line-height: 1.5;
    word-break: break-word;
}

.chat-bubble--user {
    background: var(--gold, #c9962b);
    color: #000;
    border-bottom-right-radius: 4px;
    font-weight: 500;
}

.chat-bubble--assistant {
    background: var(--bg-surface, #0d1117);
    color: var(--text-primary, #c9d1d9);
    border: 1px solid var(--border, #30363d);
    border-bottom-left-radius: 4px;
}

.chat-bubble--assistant p {
    margin: 0 0 8px 0;
}

.chat-bubble--assistant p:last-child {
    margin-bottom: 0;
}

.chat-bubble--assistant strong {
    color: var(--text-heading, #e6edf3);
}

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

.chat-bubble--assistant li {
    margin-bottom: 2px;
}

/* Error */
.chat-msg--error {
    text-align: center;
    color: var(--danger, #f85149);
    font-size: 0.8125rem;
    padding: 8px;
}

/* Empty state with suggestions */
.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted, #8b949e);
    font-size: 0.8125rem;
    text-align: center;
    padding: 24px;
}

.chat-suggestions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin-top: 4px;
}

.chat-suggestions button {
    background: transparent;
    border: 1px solid var(--border, #30363d);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.8125rem;
    color: var(--text-primary, #c9d1d9);
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.2s, background 0.2s;
}

.chat-suggestions button:hover {
    border-color: var(--gold, #c9962b);
    background: rgba(201, 150, 43, 0.06);
    color: var(--text-heading, #e6edf3);
}

/* Disclaimer */
.chat-disclaimer {
    font-size: 0.6875rem;
    color: var(--text-muted, #6e7681);
    text-align: center;
    padding: 4px 16px;
    border-top: 1px solid var(--border, #30363d);
}

.chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted, #8b949e);
    font-size: 0.8125rem;
}

/* Typing indicator */
.chat-bubble--typing {
    display: flex;
    gap: 4px;
    padding: 12px 18px;
    background: var(--bg-surface, #0d1117);
    border: 1px solid var(--border, #30363d);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted, #8b949e);
    animation: typingBounce 1.2s ease-in-out infinite;
}

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

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

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Input area */
.chat-panel__input {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border, #30363d);
    background: var(--bg-surface, #0d1117);
}

.chat-input {
    flex: 1;
    background: var(--bg-card, #161b22);
    border: 1px solid var(--border, #30363d);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.8125rem;
    color: var(--text-primary, #c9d1d9);
    font-family: 'DM Sans', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: var(--gold, #c9962b);
}

.chat-input::placeholder {
    color: var(--text-muted, #6e7681);
}

.chat-send {
    background: var(--gold, #c9962b);
    border: none;
    border-radius: 10px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #000;
    flex-shrink: 0;
    transition: background 0.2s, opacity 0.2s;
}

.chat-send:hover {
    background: #d4a535;
}

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

/* Light theme */
[data-theme="light"] .chat-fab {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .chat-panel {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

/* Mobile responsive */
@media (max-width: 640px) {
    .chat-panel {
        width: calc(100vw - 16px);
        right: 8px;
        bottom: 80px;
        max-height: 70vh;
        border-radius: 12px;
    }

    .chat-fab {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
    }

    .chat-bubble {
        max-width: 90%;
    }
}
