/* ==========================================
   SQL Agent Chat - Темна тема
   ========================================== */

:root {
    --chat-bg: #161615;
    --chat-surface: #1b1b18;
    --chat-border: #3E3E3A;
    --chat-text: #EDEDEC;
    --chat-text-muted: #A1A09A;
    --chat-primary: #F53003;
    --chat-primary-hover: #FF4433;
    --chat-success: #10b981;
    --chat-user-bubble: #2563eb;
    --chat-bot-bubble: #262622;
    --chat-shadow: rgba(0, 0, 0, 0.3);
    --chat-overlay: rgba(0, 0, 0, 0.5);
}

/* ==========================================
   Floating Action Button
   ========================================== */

.chat-fab {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--chat-primary);
    color: white;
    border: none;
    box-shadow: 0 4px 12px var(--chat-shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1000;
}

.chat-fab:hover {
    background: var(--chat-primary-hover);
    transform: scale(1.05);
    box-shadow: 0 6px 20px var(--chat-shadow);
}

.chat-fab:active {
    transform: scale(0.95);
}

.chat-fab svg {
    width: 28px;
    height: 28px;
}

.chat-fab-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--chat-primary);
    opacity: 0;
    animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    70% {
        transform: scale(1.4);
        opacity: 0;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

/* ==========================================
   Chat Window
   ========================================== */

.chat-window {
    position: fixed;
    right: 24px;
    bottom: 100px;
    width: 400px;
    height: 600px;
    background: var(--chat-bg);
    border: 1px solid var(--chat-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px var(--chat-shadow);
    display: flex;
    flex-direction: column;
    z-index: 1001;
    animation: slideUp 0.3s ease-out;
    overflow: hidden;
}

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

/* ==========================================
   Chat Header
   ========================================== */

.chat-header {
    padding: 16px 20px;
    background: var(--chat-surface);
    border-bottom: 1px solid var(--chat-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--chat-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.chat-header-text {
    display: flex;
    flex-direction: column;
}

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

.chat-subtitle {
    font-size: 12px;
    color: var(--chat-text-muted);
    margin: 0;
}

.chat-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--chat-border);
    color: var(--chat-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chat-close-btn:hover {
    background: var(--chat-surface);
    border-color: var(--chat-text-muted);
    color: var(--chat-text);
}

/* ==========================================
   Chat Body
   ========================================== */

.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

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

.chat-body::-webkit-scrollbar-thumb {
    background: var(--chat-border);
    border-radius: 3px;
}

.chat-body::-webkit-scrollbar-thumb:hover {
    background: var(--chat-text-muted);
}

/* ==========================================
   Messages
   ========================================== */

.chat-message {
    display: flex;
    gap: 10px;
    animation: messageIn 0.3s ease-out;
}

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

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

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

.message-avatar.bot {
    background: var(--chat-primary);
    color: white;
}

.message-avatar.user {
    background: var(--chat-user-bubble);
    color: white;
}

.message-content {
    max-width: 75%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-message.bot .message-bubble {
    background: var(--chat-bot-bubble);
    color: var(--chat-text);
    border-bottom-left-radius: 4px;
}

.chat-message.user .message-bubble {
    background: var(--chat-user-bubble);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: var(--chat-text-muted);
    padding: 0 4px;
}

.chat-message.user .message-time {
    text-align: right;
}

/* Markdown в повідомленнях */
.message-bubble h1,
.message-bubble h2,
.message-bubble h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 8px 0 4px 0;
    color: var(--chat-text);
}

.message-bubble p {
    margin: 4px 0;
}

.message-bubble ul,
.message-bubble ol {
    margin: 8px 0;
    padding-left: 20px;
}

.message-bubble li {
    margin: 4px 0;
}

.message-bubble code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.message-bubble pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.message-bubble pre code {
    background: none;
    padding: 0;
}

.message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 13px;
}

.message-bubble table th,
.message-bubble table td {
    padding: 6px 8px;
    border: 1px solid var(--chat-border);
    text-align: left;
}

.message-bubble table th {
    background: rgba(255, 255, 255, 0.05);
    font-weight: 600;
}

.message-bubble strong {
    font-weight: 600;
    color: var(--chat-text);
}

.message-bubble a {
    color: var(--chat-primary-hover);
    text-decoration: underline;
}

.message-bubble a:hover {
    color: var(--chat-primary);
}

/* Welcome message */
.welcome-message {
    background: var(--chat-surface);
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    padding: 16px;
    margin: 0;
    animation: messageIn 0.5s ease-out;
}

.welcome-message .emoji {
    font-size: 28px;
    margin-bottom: 8px;
    display: block;
}

.welcome-message h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--chat-text);
    margin: 0 0 12px 0;
}

.welcome-message ul {
    margin: 8px 0 12px 0;
    padding-left: 0;
    list-style: none;
}

.welcome-message li {
    margin: 6px 0;
    padding-left: 20px;
    position: relative;
    font-size: 13px;
    color: var(--chat-text-muted);
}

.welcome-message li:before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--chat-primary);
    font-weight: bold;
}

.welcome-message .footer-text {
    font-size: 13px;
    color: var(--chat-text);
    margin-top: 8px;
}

/* ==========================================
   Typing Indicator
   ========================================== */

.typing-indicator {
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: messageIn 0.3s ease-out;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--chat-text-muted);
    animation: typingDot 1.4s ease-in-out infinite;
}

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

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

@keyframes typingDot {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    30% {
        opacity: 1;
        transform: scale(1);
    }
}

.typing-text {
    font-size: 12px;
    color: var(--chat-text-muted);
}

/* ==========================================
   Input Area
   ========================================== */

.chat-input-area {
    border-top: 1px solid var(--chat-border);
    background: var(--chat-surface);
    padding: 12px;
}

.chat-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    padding: 10px 12px;
    background: var(--chat-bg);
    border: 1px solid var(--chat-border);
    border-radius: 8px;
    color: var(--chat-text);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    outline: none;
    border-color: var(--chat-primary);
}

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

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--chat-primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    background: var(--chat-primary-hover);
    transform: scale(1.05);
}

.chat-send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

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

.chat-footer-text {
    display: flex;
    justify-content: center;
    margin-top: 8px;
}

.new-conversation-btn {
    background: transparent;
    border: none;
    color: var(--chat-text-muted);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.new-conversation-btn:hover {
    color: var(--chat-text);
    background: rgba(255, 255, 255, 0.05);
}

.new-conversation-btn svg {
    width: 14px;
    height: 14px;
}

/* ==========================================
   Mobile Responsive
   ========================================== */

@media (max-width: 480px) {
    .chat-fab {
        right: 16px;
        bottom: 16px;
        width: 56px;
        height: 56px;
    }

    .chat-window {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        border: none;
    }

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