/* =============================================================================
   ChatRAG — Design System
   Paleta: Indigo/Violet + Neutros + Semânticas
   ============================================================================= */

:root {
    --primary:        #4F46E5;
    --primary-hover:  #4338CA;
    --primary-light:  #EEF2FF;
    --primary-rgb:    79, 70, 229;

    --success:        #10B981;
    --success-light:  #D1FAE5;
    --warning:        #F59E0B;
    --warning-light:  #FEF3C7;
    --danger:         #EF4444;
    --danger-light:   #FEE2E2;
    --info:           #3B82F6;
    --info-light:     #DBEAFE;

    --bg:             #F8FAFC;
    --surface:        #FFFFFF;
    --surface-2:      #F1F5F9;
    --border:         #E2E8F0;
    --border-focus:   #4F46E5;

    --text-primary:   #0F172A;
    --text-secondary: #64748B;
    --text-muted:     #94A3B8;
    --text-inverse:   #FFFFFF;

    --sidebar-w:      260px;
    --topbar-h:       64px;
    --radius:         10px;
    --radius-lg:      16px;
    --shadow-sm:      0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow:         0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.04);
    --shadow-lg:      0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.03);

    --transition:     .18s ease;
    --font:           'Inter', system-ui, sans-serif;
}

/* Dark mode */
body.dark-mode {
    --bg:             #0F172A;
    --surface:        #1E293B;
    --surface-2:      #334155;
    --border:         #334155;
    --text-primary:   #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted:     #64748B;
    --primary-light:  #1E1B4B;
    --shadow-sm:      0 1px 3px rgba(0,0,0,.3);
    --shadow:         0 4px 6px -1px rgba(0,0,0,.4);
}

/* =============================================================================
   Reset & Base
   ============================================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

img { max-width: 100%; display: block; }

/* =============================================================================
   LOGIN PAGE
   ============================================================================= */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background: linear-gradient(135deg, #667EEA 0%, #764BA2 100%);
    padding: 1.5rem;
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.login-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    box-shadow: var(--shadow-lg);
}

.login-brand {
    text-align: center;
    margin-bottom: 2rem;
}

.login-brand .brand-icon {
    width: 64px;
    height: 64px;
    background: var(--primary);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.75rem;
    color: #fff;
    box-shadow: 0 8px 24px rgba(79,70,229,.35);
}

.login-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -.02em;
}

.login-brand p {
    font-size: .875rem;
    color: var(--text-secondary);
    margin-top: .25rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: .875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: .5rem;
}

.input-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon > i:first-child {
    position: absolute;
    left: .875rem;
    color: var(--text-muted);
    font-size: 1rem;
    pointer-events: none;
}

.input-icon input {
    width: 100%;
    padding: .75rem .875rem .75rem 2.5rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: .9375rem;
    font-family: var(--font);
    background: var(--surface);
    color: var(--text-primary);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.input-icon input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .12);
}

.input-icon input::placeholder { color: var(--text-muted); }

.toggle-password {
    position: absolute;
    right: .875rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: .25rem;
    line-height: 1;
    transition: color var(--transition);
}
.toggle-password:hover { color: var(--text-secondary); }

.alert-error {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid #FECACA;
    border-radius: var(--radius);
    padding: .75rem 1rem;
    font-size: .875rem;
    margin-bottom: 1rem;
}

.login-footer {
    font-size: .8125rem;
    color: rgba(255,255,255,.65);
}

/* =============================================================================
   BUTTONS
   ============================================================================= */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .75rem 1.5rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: .9375rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), .3);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(var(--primary-rgb), .4);
}

.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .65; cursor: not-allowed; }
.btn-full { width: 100%; }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .625rem 1.25rem;
    background: var(--surface);
    color: var(--text-primary);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
}
.btn-secondary:hover { background: var(--surface-2); border-color: var(--text-muted); }

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .625rem 1.25rem;
    background: var(--danger-light);
    color: var(--danger);
    border: 1.5px solid #FECACA;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition);
    font-size: 1.1rem;
}
.btn-icon:hover { background: var(--surface-2); color: var(--text-primary); }

/* =============================================================================
   PANEL LAYOUT
   ============================================================================= */
.panel-page { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .875rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -.02em;
}

.sidebar-brand .brand-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem .75rem;
    display: flex;
    flex-direction: column;
    gap: .25rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6875rem 1rem;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: .9rem;
    font-weight: 500;
    transition: all var(--transition);
    text-decoration: none;
}

.nav-item i { font-size: 1.1rem; flex-shrink: 0; }

.nav-item:hover {
    background: var(--surface-2);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: .75rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: .625rem;
    flex: 1;
    min-width: 0;
}

.user-avatar {
    width: 34px;
    height: 34px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 1.1rem;
    flex-shrink: 0;
}

.user-meta { min-width: 0; }
.user-name { display: block; font-size: .875rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; font-size: .75rem; color: var(--text-muted); text-transform: capitalize; }

.btn-logout {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 1rem;
    flex-shrink: 0;
}
.btn-logout:hover { background: var(--danger-light); border-color: #FECACA; color: var(--danger); }

/* Main */
.main-wrapper {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.btn-menu {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: .25rem;
}

.topbar-right { display: flex; align-items: center; gap: .75rem; }

.main-content {
    flex: 1;
    padding: 2rem 1.75rem;
    max-width: 1280px;
    width: 100%;
}

/* Overlay mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
}

/* =============================================================================
   PAGE LOADER
   ============================================================================= */
.page-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin .7s linear infinite; display: inline-block; }

/* =============================================================================
   CARDS & KPIs
   ============================================================================= */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title { font-size: 1.375rem; font-weight: 700; color: var(--text-primary); letter-spacing: -.02em; }
.page-subtitle { font-size: .875rem; color: var(--text-secondary); margin-top: .25rem; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.375rem 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow); }

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.375rem;
    flex-shrink: 0;
}

.kpi-icon.indigo  { background: var(--primary-light); color: var(--primary); }
.kpi-icon.green   { background: var(--success-light); color: var(--success); }
.kpi-icon.amber   { background: var(--warning-light); color: var(--warning); }
.kpi-icon.blue    { background: var(--info-light);    color: var(--info);    }

.kpi-body { flex: 1; min-width: 0; }
.kpi-label { font-size: .8125rem; color: var(--text-secondary); font-weight: 500; }
.kpi-value { font-size: 1.625rem; font-weight: 700; color: var(--text-primary); letter-spacing: -.02em; line-height: 1.2; margin-top: .25rem; }
.kpi-sub   { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }

/* =============================================================================
   CARDS GENÉRICOS
   ============================================================================= */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body { padding: 1.5rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.25rem; }

/* =============================================================================
   TABLES
   ============================================================================= */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

thead th {
    padding: .875rem 1.25rem;
    text-align: left;
    font-size: .8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .04em;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: .9375rem 1.25rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover { background: var(--surface-2); }

/* =============================================================================
   BADGES / STATUS
   ============================================================================= */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .25rem .625rem;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-pending    { background: var(--warning-light); color: #92400E; }
.badge-processing { background: var(--info-light);    color: #1E40AF; }
.badge-ready      { background: var(--success-light); color: #065F46; }
.badge-error      { background: var(--danger-light);  color: #991B1B; }
.badge-active     { background: var(--success-light); color: #065F46; }
.badge-closed     { background: var(--surface-2);     color: var(--text-secondary); }
.badge-archived   { background: var(--surface-2);     color: var(--text-muted); }

/* =============================================================================
   PROGRESS BAR
   ============================================================================= */
.progress-wrap { margin-bottom: .5rem; }
.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: .8125rem;
    color: var(--text-secondary);
    margin-bottom: .5rem;
}
.progress-bar-bg {
    height: 8px;
    background: var(--surface-2);
    border-radius: 99px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 99px;
    transition: width .6s ease;
}
.progress-bar-fill.warning { background: var(--warning); }
.progress-bar-fill.danger  { background: var(--danger);  }

/* =============================================================================
   FORMS (painel)
   ============================================================================= */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }

.field-group { margin-bottom: 1.25rem; }

.field-group label {
    display: block;
    font-size: .875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: .5rem;
}

.field-group input,
.field-group select,
.field-group textarea {
    width: 100%;
    padding: .6875rem .875rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: .9rem;
    font-family: var(--font);
    background: var(--surface);
    color: var(--text-primary);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .12);
}

.field-group textarea { resize: vertical; min-height: 90px; }
.field-hint { font-size: .8rem; color: var(--text-muted); margin-top: .375rem; }

/* Color picker */
.color-picker-wrap {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.color-picker-wrap input[type="color"] {
    width: 44px;
    height: 44px;
    padding: 2px;
    border-radius: var(--radius);
    cursor: pointer;
    flex-shrink: 0;
}

.color-picker-wrap input[type="text"] {
    flex: 1;
}

/* =============================================================================
   DRAG & DROP UPLOAD
   ============================================================================= */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--surface);
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
}

.drop-zone i {
    font-size: 2.5rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: .75rem;
}

.drop-zone:hover i,
.drop-zone.drag-over i { color: var(--primary); }

.drop-zone p { color: var(--text-secondary); font-size: .9rem; }
.drop-zone span { color: var(--primary); font-weight: 600; }
.drop-zone small { color: var(--text-muted); font-size: .8rem; display: block; margin-top: .5rem; }

/* =============================================================================
   PAGINATION
   ============================================================================= */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
    gap: .75rem;
}

.pagination-info { font-size: .875rem; color: var(--text-secondary); }

.pagination-btns { display: flex; gap: .375rem; }

.page-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: .875rem;
    cursor: pointer;
    transition: all var(--transition);
}

.page-btn:hover { background: var(--surface-2); color: var(--text-primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* =============================================================================
   FILTERS BAR
   ============================================================================= */
.filters-bar {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.filters-bar input,
.filters-bar select {
    padding: .5625rem .875rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: .875rem;
    font-family: var(--font);
    background: var(--surface);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition);
}

.filters-bar input:focus,
.filters-bar select:focus { border-color: var(--border-focus); }

/* =============================================================================
   MODAL
   ============================================================================= */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.modal-backdrop.open {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(16px);
    transition: transform var(--transition);
}

.modal-backdrop.open .modal { transform: translateY(0); }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 1.0625rem; font-weight: 600; color: var(--text-primary); }

.modal-close {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: var(--radius);
    transition: all var(--transition);
    font-size: 1.1rem;
}
.modal-close:hover { background: var(--surface-2); color: var(--text-primary); }

.modal-body { padding: 1.5rem; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

/* =============================================================================
   TOAST NOTIFICATIONS
   ============================================================================= */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: .625rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .875rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    font-size: .875rem;
    font-weight: 500;
    min-width: 280px;
    max-width: 380px;
    animation: slideInRight .25s ease;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger);  }
.toast.info    { border-left: 4px solid var(--info);    }

.toast i { font-size: 1.1rem; flex-shrink: 0; }
.toast.success i { color: var(--success); }
.toast.error   i { color: var(--danger);  }
.toast.info    i { color: var(--info);    }

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

/* =============================================================================
   CHART PLACEHOLDER
   ============================================================================= */
.chart-container {
    position: relative;
    height: 240px;
    width: 100%;
}

/* =============================================================================
   CONVERSATION VIEW
   ============================================================================= */
.chat-bubble-wrap { display: flex; flex-direction: column; gap: .875rem; }

.chat-bubble {
    display: flex;
    gap: .75rem;
    max-width: 85%;
}

.chat-bubble.user { align-self: flex-end; flex-direction: row-reverse; }

.bubble-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .9rem;
    flex-shrink: 0;
    color: var(--text-secondary);
}

.chat-bubble.user .bubble-avatar { background: var(--primary-light); color: var(--primary); }

.bubble-content {
    background: var(--surface-2);
    border-radius: 12px 12px 12px 4px;
    padding: .75rem 1rem;
    font-size: .9rem;
    line-height: 1.55;
    color: var(--text-primary);
}

.chat-bubble.user .bubble-content {
    background: var(--primary);
    color: #fff;
    border-radius: 12px 12px 4px 12px;
}

.bubble-time {
    font-size: .75rem;
    color: var(--text-muted);
    margin-top: .375rem;
    display: block;
}

.bubble-sources {
    margin-top: .5rem;
    font-size: .8rem;
    color: var(--text-muted);
    border-top: 1px solid rgba(0,0,0,.06);
    padding-top: .5rem;
}

.bubble-sources a {
    color: var(--primary);
    font-weight: 500;
}

/* =============================================================================
   STAR RATING
   ============================================================================= */
.stars { display: inline-flex; gap: 2px; }
.star  { color: var(--warning); font-size: .9rem; }
.star.empty { color: var(--border); }

/* =============================================================================
   EMPTY STATE
   ============================================================================= */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.empty-state i {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: .5rem;
}

.empty-state p {
    font-size: .875rem;
    color: var(--text-secondary);
    max-width: 320px;
}

/* =============================================================================
   SANDBOX CHAT (Settings)
   ============================================================================= */
.sandbox-chat {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 420px;
}

.sandbox-header {
    padding: .875rem 1.25rem;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    gap: .75rem;
    font-weight: 600;
}

.sandbox-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.sandbox-input-wrap {
    display: flex;
    gap: .625rem;
    padding: .875rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.sandbox-input-wrap input {
    flex: 1;
    padding: .625rem .875rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: .9rem;
    font-family: var(--font);
    background: var(--surface);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition);
}

.sandbox-input-wrap input:focus { border-color: var(--border-focus); }

/* =============================================================================
   CODE SNIPPET
   ============================================================================= */
.code-block {
    background: #1E293B;
    border-radius: var(--radius);
    padding: 1.125rem 1.25rem;
    position: relative;
    overflow-x: auto;
}

.code-block code {
    font-family: 'Fira Code', 'Cascadia Code', monospace;
    font-size: .8125rem;
    color: #E2E8F0;
    line-height: 1.7;
    white-space: pre;
}

.code-copy {
    position: absolute;
    top: .75rem;
    right: .75rem;
    background: rgba(255,255,255,.1);
    border: none;
    border-radius: 6px;
    color: #94A3B8;
    padding: .3rem .6rem;
    font-size: .75rem;
    cursor: pointer;
    transition: all var(--transition);
}
.code-copy:hover { background: rgba(255,255,255,.2); color: #fff; }

/* =============================================================================
   RESPONSIVE
   ============================================================================= */
@media (max-width: 1024px) {
    .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.open {
        display: block;
    }
    .main-wrapper {
        margin-left: 0;
    }
    .btn-menu {
        display: flex;
    }
    .main-content {
        padding: 1.25rem 1rem;
    }
    .kpi-grid {
        grid-template-columns: 1fr 1fr;
    }
    .grid-2, .grid-3, .form-row {
        grid-template-columns: 1fr;
    }
    .page-header {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .login-card { padding: 1.75rem 1.25rem; }
}
