@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg-primary: #0a0b10;
    --bg-surface: rgba(20, 22, 33, 0.7);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --accent-purple: #8b5cf6;
    --accent-blue: #3b82f6;
    --gradient-accent: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
    --font-sans: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --shadow-premium: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
}

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

body {
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(at 0% 0%, rgba(139, 92, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(59, 130, 246, 0.15) 0px, transparent 50%);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex;
    overflow: hidden;
}

/* Dashboard Container */
.dashboard {
    display: flex;
    width: 100%;
    height: 100vh;
    backdrop-filter: blur(10px);
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: rgba(10, 11, 16, 0.6);
    border-right: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    width: 38px;
    height: 38px;
    background: var(--gradient-accent);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
    color: white;
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
}

.brand-name {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #fff, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.suggestions-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-secondary);
    font-weight: 600;
}

.suggestions-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    list-style: none;
}

.suggestion-btn {
    width: 100%;
    padding: 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    text-align: left;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.suggestion-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--accent-purple);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15);
}

/* Chat Main Area */
.chat-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    margin: 1.5rem;
    border-radius: 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-premium);
    overflow: hidden;
}

.chat-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.bot-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.bot-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.bot-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 10px #10b981;
}

/* Chat Messages */
.chat-messages {
    flex-grow: 1;
    padding: 2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scroll-behavior: smooth;
}

.message {
    display: flex;
    gap: 1rem;
    max-width: 85%;
    animation: fadeIn 0.4s ease-out forwards;
}

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

.message.bot {
    align-self: flex-start;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.user .avatar {
    background: var(--gradient-accent);
    color: white;
}

.bot .avatar {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent-purple);
    border: 1px solid var(--border-color);
}

.bubble {
    padding: 1rem 1.25rem;
    border-radius: 16px;
    line-height: 1.6;
    font-size: 0.95rem;
}

.user .bubble {
    background: var(--gradient-accent);
    color: white;
    border-top-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.2);
}

.bot .bubble {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-top-left-radius: 4px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Accordion SQL/Data details */
.sql-details {
    margin-top: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.sql-details summary {
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    user-select: none;
    outline: none;
    transition: background 0.2s;
}

.sql-details summary:hover {
    background: rgba(255, 255, 255, 0.02);
}

.sql-details-content {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sql-code {
    font-family: var(--font-mono);
    background: rgba(10, 11, 16, 0.8);
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #38bdf8;
    overflow-x: auto;
    white-space: pre-wrap;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Table results design */
.table-wrapper {
    overflow-x: auto;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    max-height: 250px;
    overflow-y: auto;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    text-align: left;
}

.results-table th {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}

.results-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.results-table tr:hover td {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.01);
}

/* Loading skeleton styling */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    display: inline-block;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

/* Input Panel */
.chat-input-panel {
    padding: 1.25rem 2rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.quick-chips-container {
    padding: 0.85rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(10, 11, 16, 0.25);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    width: 100%;
}

.quick-chips {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    width: 100%;
}

.quick-chips-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.chip-btn {
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 20px !important;
    padding: 0.45rem 1rem !important;
    color: var(--text-primary) !important;
    font-size: 0.82rem !important;
    font-family: var(--font-sans) !important;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.35rem !important;
    width: auto !important;
}

.chip-btn:hover {
    background: rgba(139, 92, 246, 0.15) !important;
    border-color: var(--accent-purple) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15) !important;
}

.input-row {
    display: flex;
    gap: 1rem;
    align-items: center;
    width: 100%;
}

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

.chat-input {
    width: 100%;
    padding: 1.25rem 1.5rem;
    background: rgba(10, 11, 16, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s;
}

.chat-input:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.15);
    background: rgba(10, 11, 16, 0.8);
}

.send-btn {
    padding: 1.25rem 1.75rem;
    background: var(--gradient-accent);
    border: none;
    border-radius: 16px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.send-btn:active {
    transform: translateY(0);
}

.send-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

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

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    .chat-container {
        margin: 0;
        border-radius: 0;
        border: none;
    }
}

/* Glassmorphism Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 11, 16, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.login-card {
    background: rgba(20, 22, 33, 0.85);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 2.5rem;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
    transform: scale(0.95) translateY(10px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-overlay.active .login-card {
    transform: scale(1) translateY(0);
}

.login-header h2 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #ffffff 0%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.login-header p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    text-align: left;
}

.input-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.login-input {
    width: 100%;
    padding: 1.1rem 1.25rem;
    background: rgba(10, 11, 16, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s;
}

.login-input:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.2);
    background: rgba(10, 11, 16, 0.8);
}

.login-error {
    color: #f87171;
    font-size: 0.85rem;
    min-height: 1.25rem;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 500;
}

.login-btn {
    width: 100%;
    padding: 1.1rem;
    background: var(--gradient-accent);
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

.login-btn:active {
    transform: translateY(0);
}

/* Chart Styles */
.chart-container-wrapper {
    margin-top: 1rem;
    padding: 1.25rem;
    background: rgba(10, 11, 16, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    position: relative;
    width: 100%;
    height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.chart-container-wrapper.fade-in {
    opacity: 1;
}

.chart-container-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Preloader styles */
.chart-preloader {
    margin-top: 1rem;
    background: rgba(10, 11, 16, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 100%;
    height: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    transition: opacity 0.3s ease-in-out;
}

.preloader-spinner {
    width: 42px;
    height: 42px;
    border: 3px solid rgba(139, 92, 246, 0.1);
    border-top: 3px solid var(--accent-purple);
    border-radius: 50%;
    animation: spin-preloader 0.8s linear infinite;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.3);
}

.preloader-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    font-weight: 500;
    animation: pulse-preloader-text 1.5s ease-in-out infinite;
}

@keyframes spin-preloader {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse-preloader-text {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}
