* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #f39c12;
    --primary-dark: #e67e22;
    --secondary-color: #f5b041;
    --orange-gradient: linear-gradient(135deg, #f39c12 0%, #f5b041 100%);
    --success-color: #10b981;
    --danger-color: #ef4444;
    --text-dark: #2c3e50;
    --text-light: #95a5a6;
    --bg-light: #ffffff;
    --bg-white: #ffffff;
    --border-color: #ecf0f1;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 2px 4px 0 rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #ecf0f1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Chat Button */
.chat-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--orange-gradient);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow-xl);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1000;
    animation: pulse 2s infinite;
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 25px 30px -5px rgba(0, 0, 0, 0.2);
}

.chat-button.hidden {
    display: none;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 0 0 0 rgba(99, 102, 241, 0.7);
    }
    50% {
        box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 0 0 10px rgba(99, 102, 241, 0);
    }
}

/* Chat Popup */
.chat-popup {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 420px;
    max-width: calc(100vw - 60px);
    height: 650px;
    max-height: calc(100vh - 60px);
    background: var(--bg-white);
    border-radius: 20px;
    box-shadow: var(--shadow-xl);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 1001;
    animation: slideUp 0.3s ease;
}

.chat-popup.active {
    display: flex;
}

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

/* Chat Header */
.chat-header {
    background: var(--orange-gradient);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.menu-btn {
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: opacity 0.2s ease;
}

.menu-btn:hover {
    opacity: 0.8;
}

.header-title {
    flex: 1;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.close-btn {
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: opacity 0.2s ease;
}

.close-btn:hover {
    opacity: 0.8;
}

/* Chat Body */
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: white;
    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(--border-color);
    border-radius: 3px;
}

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

/* Messages */
.message {
    display: flex;
    gap: 12px;
    animation: fadeIn 0.3s ease;
}

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--orange-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}

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

.user-message .message-avatar {
    background: var(--text-dark);
}

.message-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message-bubble {
    background: #f8f9fa;
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: none;
    max-width: 85%;
    border: 1px solid #e9ecef;
}

.user-message .message-bubble {
    background: var(--orange-gradient);
    color: white;
    margin-left: auto;
    border: none;
}

.message-bubble p {
    margin: 0 0 8px 0;
    line-height: 1.5;
    color: var(--text-dark);
}

.user-message .message-bubble p {
    color: white;
}

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


.message-time {
    font-size: 11px;
    color: var(--text-light);
    padding: 0 8px;
}

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

/* Data Table */
.data-table {
    width: 100%;
    margin-top: 12px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.data-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    background: var(--primary-color);
    color: white;
    padding: 10px;
    text-align: left;
    font-weight: 600;
}

.data-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    background: white;
}

.data-table tr:last-child td {
    border-bottom: none;
}


/* Chat Footer */
.chat-footer {
    background: white;
    border-top: 1px solid var(--border-color);
    padding: 12px 16px;
}

.input-container {
    display: flex;
    gap: 10px;
    align-items: center;
    background: #f8f9fa;
    border-radius: 24px;
    padding: 8px 16px;
    border: 1px solid #e9ecef;
    transition: all 0.2s ease;
}

.input-container:focus-within {
    border-color: var(--primary-color);
    background: white;
}

#messageInput {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 4px;
    font-size: 15px;
    outline: none;
    color: var(--text-dark);
}

#messageInput::placeholder {
    color: #bdc3c7;
}

.send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--orange-gradient);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.send-btn:hover {
    transform: scale(1.05);
    opacity: 0.9;
}

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

/* Loading Overlay */
.loading-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-light);
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Suggestion Bar */
.suggestion-bar {
    background: white;
    border-top: 1px solid var(--border-color);
    padding: 8px 12px;
    transition: all 0.3s ease;
}

.suggestion-bar.hidden {
    display: none;
}

.suggestion-scroll {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: nowrap;
}

.suggestion-item {
    flex-shrink: 0;
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    user-select: none;
}

.suggestion-item:hover {
    background: var(--secondary-color);
    border-color: var(--primary-color);
    color: white;
    transform: translateY(-1px);
}

.suggestion-item:active {
    transform: translateY(0);
}

.suggestion-item:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Flash animation for new suggestions */
.suggestion-item.flash-animation {
    animation: flashSuggestion 1s ease-in-out;
}

@keyframes flashSuggestion {
    0%, 100% {
        background: #f8f9fa;
        transform: scale(1);
    }
    25% {
        background: var(--secondary-color);
        color: white;
        transform: scale(1.05);
    }
    50% {
        background: var(--primary-color);
        color: white;
        transform: scale(1.1);
    }
    75% {
        background: var(--secondary-color);
        color: white;
        transform: scale(1.05);
    }
}

/* Responsive */
@media (max-width: 480px) {
    .chat-popup {
        width: calc(100vw - 20px);
        height: calc(100vh - 20px);
        bottom: 10px;
        right: 10px;
    }
    
    .chat-button {
        bottom: 20px;
        right: 20px;
        width: 55px;
        height: 55px;
    }
    
    .suggestion-bar {
        padding: 6px 10px;
    }
    
    .suggestion-item {
        font-size: 12px;
        padding: 5px 10px;
    }
}
