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

:root {
    --bg-main: #0b0f19;
    --bg-surface: rgba(17, 24, 39, 0.7);
    --bg-glass-card: rgba(30, 41, 59, 0.45);
    --border-glass: rgba(255, 255, 255, 0.06);
    
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.4);
    
    --secondary: #d946ef;
    --secondary-hover: #c084fc;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.15);
    
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.15);
    
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.15);
    
    --info: #0ea5e9;
    --info-bg: rgba(14, 165, 233, 0.15);

    --accent-purple: #a78bfa;
    --accent-blue: #60a5fa;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(217, 70, 239, 0.1) 0px, transparent 50%);
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(11, 15, 25, 0.5);
}
::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.6);
}

/* Glassmorphism Cards */
.glass-panel {
    background: var(--bg-glass-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Layout */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Fixed Header */
.app-header {
    height: 64px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    background: rgba(11, 15, 25, 0.8);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-glass);
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 24px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
}

.logo-text {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info {
    text-align: right;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
}

.user-role {
    font-size: 11px;
    color: var(--text-secondary);
    background: rgba(99, 102, 241, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 2px;
    display: inline-block;
}

.btn-logout {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #ef4444;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    transform: translateY(-1px);
}

/* Sidebar and Main Content wrapper */
.main-wrapper {
    display: flex;
    margin-top: 64px;
    flex: 1;
}

.sidebar {
    width: 240px;
    position: fixed;
    top: 64px;
    bottom: 0;
    left: 0;
    background: rgba(11, 15, 25, 0.95);
    border-right: 1px solid var(--border-glass);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 40;
    transition: all 0.3s ease;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
    transform: translateX(4px);
}

.nav-link.active {
    color: var(--text-primary);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(217, 70, 239, 0.1));
    border-left: 3px solid var(--primary);
    box-shadow: inset 0 0 12px rgba(99, 102, 241, 0.05);
}

.nav-link-super {
    margin-top: auto;
    border: 1px dashed rgba(217, 70, 239, 0.3);
}

.nav-link-super:hover {
    background: rgba(217, 70, 239, 0.1);
}

/* Content Area */
.content-area {
    margin-left: 240px;
    padding: 32px;
    flex: 1;
    min-height: calc(100vh - 64px);
}

/* Auth Center Card Layout */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    padding: 40px;
}

.auth-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    text-align: center;
    background: linear-gradient(135deg, #fff, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    text-align: center;
    margin-bottom: 32px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    background: rgba(11, 15, 25, 0.6);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

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

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-2px);
}

/* Tables */
.table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: 12px;
    margin-top: 16px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

.data-table th {
    background: rgba(17, 24, 39, 0.8);
    padding: 16px;
    color: var(--text-secondary);
    font-weight: 500;
    border-bottom: 1px solid var(--border-glass);
}

.data-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-glass);
    color: var(--text-primary);
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
}

/* Alert Banners */
.alert-banner {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 24px;
    border: 1px solid transparent;
}

.alert-danger {
    background: var(--danger-bg);
    border-color: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.alert-success {
    background: var(--success-bg);
    border-color: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

/* Dashboard Grid Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.metric-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.metric-title {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.metric-value {
    font-size: 32px;
    font-weight: 700;
    background: linear-gradient(135deg, #fff, var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
}

.modal-content {
    width: 100%;
    max-width: 500px;
    padding: 32px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
}

/* Wizard steps */
.wizard-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: 32px;
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 16px;
}

.wizard-step {
    flex: 1;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    position: relative;
}

.wizard-step.active {
    color: var(--primary);
    font-weight: 600;
}

.wizard-step.complete {
    color: var(--success);
}

/* Editor layout */
.editor-layout {
    display: flex;
    gap: 24px;
    margin-top: 24px;
}

.editor-main {
    flex: 2;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.editor-sidebar {
    flex: 1;
    max-height: 720px;
    min-height: 500px;
    overflow: hidden;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.schema-table-item {
    margin-bottom: 12px;
}

.schema-table-header {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}

.schema-table-columns {
    padding-left: 20px;
    font-size: 12px;
    color: var(--text-muted);
    display: none;
}

.schema-table-columns.active {
    display: block;
}

.sql-textarea {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    line-height: 1.5;
    background: #060911;
    color: #38bdf8;
    resize: vertical;
    min-height: 200px;
}

/* Form checkboxes */
.checkbox-container {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
}

.checkbox-container input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* Chart Canvas wrapping */
.chart-wrapper {
    position: relative;
    width: 100%;
    max-height: 400px;
    margin-top: 24px;
    padding: 16px;
    background: rgba(6, 9, 17, 0.4);
    border-radius: 12px;
}

/* ── AI Assistant Sidebar ───────────────────────────────────────────────── */

.sidebar-tab {
    flex: 1;
    padding: 12px 8px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.02em;
}

.sidebar-tab:hover {
    color: var(--text-secondary);
    background: rgba(255,255,255,0.04);
}

.sidebar-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: rgba(99,102,241,0.08);
}

/* AI Chat Messages */
.ai-msg {
    display: flex;
    width: 100%;
}

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

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

.ai-bubble-user {
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: #fff;
    border-radius: 16px 16px 4px 16px;
    padding: 10px 14px;
    font-size: 13px;
    max-width: 85%;
    line-height: 1.5;
    word-break: break-word;
    box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}

.ai-bubble-assistant {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    border-radius: 16px 16px 16px 4px;
    padding: 10px 14px;
    font-size: 13px;
    max-width: 95%;
    line-height: 1.6;
    word-break: break-word;
}

/* AI code block */
.ai-code-block {
    margin: 8px 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(99,102,241,0.3);
    background: #060911;
}

.ai-code-block pre {
    overflow-x: auto;
    padding: 12px;
    margin: 0;
}

.ai-sql-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: #38bdf8;
    white-space: pre;
    line-height: 1.6;
}

.ai-insert-btn {
    display: block;
    width: 100%;
    padding: 8px 12px;
    background: linear-gradient(135deg, rgba(99,102,241,0.2), rgba(139,92,246,0.2));
    border: none;
    border-top: 1px solid rgba(99,102,241,0.3);
    color: var(--primary);
    font-family: 'Outfit', sans-serif;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.ai-insert-btn:hover {
    background: linear-gradient(135deg, rgba(99,102,241,0.4), rgba(139,92,246,0.4));
    color: #fff;
}

/* Inline code inside AI messages */
.ai-inline-code {
    background: rgba(99,102,241,0.15);
    color: #a5b4fc;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    padding: 1px 5px;
    border-radius: 4px;
}

/* AI empty state */
.ai-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    padding: 24px;
}

/* Thinking animation */
.ai-thinking {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
}

.ai-thinking span {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary);
    animation: ai-bounce 1.2s infinite ease-in-out;
}

.ai-thinking span:nth-child(2) { animation-delay: 0.2s; }
.ai-thinking span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ai-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40%            { transform: scale(1.0); opacity: 1.0; }
}
