/* ============================================
   OptiCore Analytics — Premium Dark Theme
   ============================================ */

/* === RESET & BASE === */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a {
    color: var(--primary-light);
    text-decoration: none;
}

a:hover {
    color: var(--primary);
}

/* === LOADING === */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

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

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

/* === APP LAYOUT === */
.app-container {
    min-height: 100vh;
}

.app-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
    position: relative;
}

/* === SIDEBAR === */
.sidebar {
    background: linear-gradient(180deg, #0c1222 0%, #131b2e 100%);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: width var(--transition-base);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.sidebar-logo {
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

.sidebar-title {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-main), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-base);
    text-decoration: none;
}

.sidebar-link:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--text-main);
}

.sidebar-link.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(6, 182, 212, 0.1));
    color: var(--primary-light);
    box-shadow: inset 3px 0 0 var(--primary);
}

.sidebar-link-icon {
    font-size: 1.15rem;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--glass-border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0.75rem;
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
}

.sidebar-user-name {
    font-size: 0.85rem;
    font-weight: 600;
}

.sidebar-user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.sidebar-logout {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-base);
}

.sidebar-logout:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* === MAIN CONTENT === */
.main-content {
    padding: 1.5rem 2rem;
    min-height: 100vh;
    overflow-y: auto;
    transition: margin-right var(--transition-base);
}

.main-content.chat-open {
    margin-right: 360px;
}

.page-content {
    max-width: 1400px;
}

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--text-main), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.page-header p {
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* === CHAT PANEL === */
.chat-panel {
    position: fixed;
    top: 0;
    right: -360px;
    width: 360px;
    height: 100vh;
    background: linear-gradient(180deg, #0c1222 0%, #131b2e 100%);
    border-left: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
}

.chat-panel.open {
    right: 0;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--glass-border);
    cursor: pointer;
    background: rgba(99, 102, 241, 0.05);
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-icon {
    font-size: 1.25rem;
}

.chat-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.chat-toggle-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
}

.chat-toggle-btn:hover {
    color: var(--primary-light);
    background: rgba(99, 102, 241, 0.1);
}

.chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    scroll-behavior: smooth;
}

.chat-welcome {
    text-align: center;
    padding: 2rem 1rem;
}

.chat-welcome-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.chat-welcome h3 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.chat-welcome p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.chat-suggestions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 1rem;
}

.chat-suggestion {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: rgba(99, 102, 241, 0.05);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-base);
    text-align: left;
}

.chat-suggestion:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    color: var(--text-main);
}

.chat-message {
    display: flex;
    gap: 8px;
    margin-bottom: 1rem;
}

.chat-message-avatar {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.chat-message-content {
    flex: 1;
}

.chat-message-text {
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-lg);
    font-size: 0.85rem;
    line-height: 1.5;
}

.chat-message.user .chat-message-text {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant .chat-message-text {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    border-bottom-left-radius: 4px;
}

.chat-message-text code {
    background: rgba(0, 0, 0, 0.3);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.8rem;
}

.chat-input-area {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.15);
}

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

.chat-input {
    flex: 1;
    resize: none;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-input);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    max-height: 100px;
    transition: border-color var(--transition-base);
}

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

.chat-send-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}

.chat-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* === CARDS === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    transition: box-shadow var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--text-main);
}

.card-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.chart-card {}

.chart-container {
    position: relative;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* === GRIDS === */
.grid {
    display: grid;
    gap: 1rem;
}

.grid-cols-1 {
    grid-template-columns: 1fr;
}

.grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* === KPI CARDS === */
.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 1.25rem;
    transition: all var(--transition-base);
}

.kpi-card:hover {
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.08);
}

.kpi-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 800;
    margin-top: 0.25rem;
}

.kpi-change {
    font-size: 0.8rem;
    margin-top: 0.25rem;
    color: var(--text-muted);
}

.kpi-change.positive {
    color: var(--success);
}

.kpi-change.negative {
    color: var(--danger);
}

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius-lg);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary-dark));
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
    color: var(--text-main);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

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

/* === FORMS === */
.form-control {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

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

select.form-control {
    cursor: pointer;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-row {}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

/* === TABLES === */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

th {
    text-align: left;
    padding: 0.75rem;
    border-bottom: 2px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-secondary);
}

tr:hover td {
    background: rgba(99, 102, 241, 0.03);
}

.compact-table th {
    padding: 0.5rem;
    font-size: 0.7rem;
}

.compact-table td {
    padding: 0.4rem 0.5rem;
    font-size: 0.8rem;
}

/* === BADGES === */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-xl);
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.badge-info {
    background: rgba(6, 182, 212, 0.15);
    color: var(--secondary);
}

/* === UPLOAD AREA === */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
    color: var(--text-muted);
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
    color: var(--text-main);
}

.upload-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

/* === ALERTS === */
.alert-success {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-lg);
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--success);
    font-size: 0.875rem;
}

.alert-warning {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-lg);
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--warning);
    font-size: 0.875rem;
}

.alert-error {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-lg);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
    font-size: 0.875rem;
}

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    padding: 2rem;
}

.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    opacity: 0.6;
}

.empty-state-text {
    font-size: 0.95rem;
    color: var(--text-muted);
}

.empty-state-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    opacity: 0.7;
}

/* === TOAST === */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 10000;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-xl);
}

.toast-visible {
    transform: translateY(0);
    opacity: 1;
}

.toast-success {
    background: rgba(16, 185, 129, 0.95);
    color: white;
}

.toast-error {
    background: rgba(239, 68, 68, 0.95);
    color: white;
}

.toast-info {
    background: rgba(99, 102, 241, 0.95);
    color: white;
}

.toast-warning {
    background: rgba(245, 158, 11, 0.95);
    color: white;
}

/* === DATA SOURCES PAGE === */
.ds-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 4px;
    margin-bottom: 1rem;
    width: fit-content;
}

.ds-tab {
    padding: 0.55rem 1.25rem;
    border: none;
    border-radius: var(--radius-lg);
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
}

.ds-tab.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.ds-tab:hover:not(.active) {
    background: rgba(99, 102, 241, 0.1);
    color: var(--text-main);
}

.ds-form {
    max-width: 600px;
}

.ds-sources-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ds-source-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
}

.ds-source-item:hover {
    border-color: var(--primary);
}

.ds-source-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ds-source-icon {
    font-size: 1.25rem;
}

.ds-source-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.ds-source-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.ds-source-disabled {
    opacity: 0.5;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.dashboard-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--text-main), var(--text-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.dashboard-header p {
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.dashboard-source-picker {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dashboard-source-picker label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.ds-browser-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 1rem;
    min-height: 400px;
}

.ds-table-list {
    background: var(--bg-main);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    overflow-y: auto;
    max-height: 500px;
}

.ds-table-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.6rem 0.8rem;
    cursor: pointer;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.85rem;
    transition: all var(--transition-fast);
}

.ds-table-item:hover {
    background: rgba(99, 102, 241, 0.08);
}

.ds-table-item.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-light);
}

.ds-table-icon {
    font-size: 0.9rem;
}

.ds-table-name {
    flex: 1;
    font-weight: 500;
}

.ds-table-count {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.ds-table-data {
    background: var(--bg-main);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    overflow: auto;
    max-height: 500px;
}

.ds-data-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.85rem;
    color: var(--text-muted);
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
}

/* === SANDBOX PAGE === */
.sandbox-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.sandbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    gap: 1rem;
    min-height: 200px;
}

.sandbox-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.sandbox-empty-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.sandbox-empty h3 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.sandbox-widget {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    transition: all var(--transition-base);
    cursor: default;
}

.sandbox-widget:hover {
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.sandbox-widget.dragging {
    opacity: 0.5;
}

.widget-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.15);
}

.widget-drag-handle {
    cursor: grab;
    color: var(--text-muted);
    font-size: 1.1rem;
    user-select: none;
}

.widget-title {
    flex: 1;
    font-weight: 600;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.widget-actions {
    display: flex;
    gap: 4px;
}

.widget-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    opacity: 0.6;
}

.widget-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.05);
}

.widget-body {
    padding: 0.5rem;
}

.widget-chart-container {
    position: relative;
    height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.widget-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--glass-border);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.widget-type-badge,
.widget-group-badge {
    padding: 2px 8px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: var(--radius-xl);
}

/* === CHART TYPE SELECTOR === */
.chart-type-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 0.5rem;
}

.chart-type-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-base);
}

.chart-type-option:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.chart-type-option.selected {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.15);
    box-shadow: 0 0 0 1px var(--primary);
}

.chart-type-icon {
    font-size: 1.5rem;
}

.chart-type-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* === MODAL === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.2s ease;
}

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

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--glass-border);
}

/* === LOGIN PAGE === */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-main);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 30% 50%, var(--login-glow) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 50%, rgba(6, 182, 212, 0.06) 0%, transparent 50%);
    animation: loginGlow 10s ease-in-out infinite alternate;
}

@keyframes loginGlow {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }

    100% {
        transform: translate(-5%, 5%) rotate(3deg);
    }
}

.login-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-2xl);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
    box-shadow: var(--shadow-xl);
    backdrop-filter: blur(12px);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    font-size: 2rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.login-form .form-group {
    margin-bottom: 1.25rem;
}

.login-form .btn {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.75rem;
}

.login-error {
    color: var(--danger);
    font-size: 0.8rem;
    text-align: center;
    margin-top: 0.5rem;
    min-height: 1.2em;
}

/* === DASHBOARD (updated to work without navbar) === */
.dashboard {}

.dashboard-header {
    margin-bottom: 1.5rem;
}

.dashboard-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--text-main), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.dashboard-header p {
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* === UTILITY CLASSES === */
.text-center {
    text-align: center;
}

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

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

/* === SCROLLBAR === */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

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

/* === RESPONSIVE === */
@media (max-width: 1200px) {
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .sandbox-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        left: -260px;
        z-index: 500;
        transition: left 0.3s ease;
    }

    .sidebar.open {
        left: 0;
    }

    .main-content {
        padding: 1rem;
    }

    .main-content.chat-open {
        margin-right: 0;
    }

    .chat-panel {
        width: 100%;
        right: -100%;
    }

    .grid-cols-2,
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }

    .form-row-2 {
        grid-template-columns: 1fr;
    }

    .ds-browser-layout {
        grid-template-columns: 1fr;
    }
}

/* === NAVBAR (legacy compat for admin/upload pages) === */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: var(--glass-bg);
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(8px);
}

.navbar-brand {
    font-size: 1.25rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
}

.navbar-menu {
    display: flex;
    list-style: none;
    gap: 0.5rem;
}

.navbar-menu a {
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.navbar-menu a:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--text-main);
}

.navbar-menu a.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-light);
}

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

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: white;
}

/* === FLOATING CHAT BUTTON (FAB) === */
.chat-fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    transition: all 0.3s ease;
    animation: fabPulse 2s ease-in-out infinite;
}

.chat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(99, 102, 241, 0.6);
}

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

@keyframes fabPulse {

    0%,
    100% {
        box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    }

    50% {
        box-shadow: 0 4px 28px rgba(99, 102, 241, 0.6);
    }
}

/* === TAB CONTENT === */
.tab-content {
    /* shown/hidden via js display toggle */
}