/* ===================================
   BRGT Bot - Painel de Controle v2
   Theme: Dark Professional SaaS
   =================================== */

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Cores principais - BRGT neutral dark */
    --bg-primary: #121212;
    --bg-secondary: #1a1a1a;
    --bg-card: #242424;
    --bg-input: #161616;
    --bg-elevated: #2e2e2e;

    /* Sidebar */
    --sidebar-width: 260px;
    --sidebar-bg: #0e0e0e;
    --sidebar-border: #2a2a2a;
    --sidebar-hover: rgba(244, 81, 30, 0.08);
    --sidebar-active: rgba(244, 81, 30, 0.15);

    /* Accent - BRGT Orange */
    --accent: #F4511E;
    --accent-hover: #E64A19;
    --accent-subtle: rgba(244, 81, 30, 0.12);
    --success: #22c55e;
    --success-subtle: rgba(34, 197, 94, 0.12);
    --danger: #ef4444;
    --danger-subtle: rgba(239, 68, 68, 0.12);
    --warning: #f59e0b;
    --warning-subtle: rgba(245, 158, 11, 0.12);

    /* Texto */
    --text-primary: #f0f0f0;
    --text-secondary: #9e9e9e;
    --text-muted: #757575;
    --text-inverse: #121212;

    /* Bordas */
    --border: #333333;
    --border-subtle: #282828;
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;

    /* Sombras */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.4);

    /* Transicoes */
    --transition: 200ms ease;

    /* Tipografia */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Monaco', monospace;

    /* Z-index */
    --z-sidebar: 50;
    --z-topbar: 40;
    --z-modal: 200;
    --z-toast: 300;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
    overflow: hidden;
}

/* ===================================
   Sidebar
   =================================== */

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    z-index: var(--z-sidebar);
    transition: transform var(--transition);
}

.sidebar-header {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #BF360C, #FF7043);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    color: white;
    flex-shrink: 0;
}

.logo-text {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.nav-item:hover {
    color: var(--text-primary);
    background: var(--sidebar-hover);
}

.nav-item.active {
    color: var(--accent);
    background: var(--sidebar-active);
}

.nav-item svg,
.nav-item i {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke-width: 1.75;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--sidebar-border);
}

.server-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

.status-dot.offline {
    background: var(--danger);
}

/* ===================================
   Main Content
   =================================== */

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: calc(100% - var(--sidebar-width));
    transition: margin-left var(--transition), width var(--transition);
}

/* Sidebar colapsada */
body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
}

body.sidebar-collapsed .main-content {
    margin-left: 0;
    width: 100%;
}

.topbar {
    position: sticky;
    top: 0;
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    z-index: var(--z-topbar);
    flex-shrink: 0;
}

.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.sidebar-toggle:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.sidebar-toggle svg {
    width: 20px;
    height: 20px;
}

.page-title {
    font-size: 1.1rem;
    font-weight: 600;
    flex: 1;
}

.topbar-time {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* ===================================
   Stats Grid
   =================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: border-color var(--transition);
}

.stat-card:hover {
    border-color: var(--accent);
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: var(--accent-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 20px;
    height: 20px;
    color: var(--accent);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ===================================
   Cards
   =================================== */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.card + .card {
    margin-top: 1rem;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-description {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 1rem;
}

/* ===================================
   Buttons
   =================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.55rem 1.15rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.825rem;
    font-weight: 550;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    line-height: 1.4;
}

.btn svg {
    width: 15px;
    height: 15px;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover:not(:disabled) {
    background: #16a34a;
}

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn-warning {
    background: var(--warning);
    color: var(--text-inverse);
}
.btn-warning:hover:not(:disabled) {
    background: #d97706;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.btn-outline:hover:not(:disabled) {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.4rem 0.65rem;
}
.btn-ghost:hover:not(:disabled) {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
}

.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}
.btn.loading::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
}

.quick-action-btn:hover {
    background: var(--accent-subtle);
    color: var(--accent);
    border-color: var(--accent);
}

.quick-action-btn svg {
    width: 16px;
    height: 16px;
}

/* ===================================
   Section Tabs
   =================================== */

.section-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.tab-btn {
    padding: 0.65rem 1.15rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text-secondary);
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ===================================
   Section Toolbar
   =================================== */

.section-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.section-toolbar .select-input {
    min-width: 220px;
}

/* ===================================
   Data Tables
   =================================== */

.data-table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.data-table-scroll {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 70vh;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.825rem;
}

.data-table th {
    background: var(--bg-elevated);
    padding: 0.6rem 0.85rem;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    position: sticky;
    top: 0;
    z-index: 1;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.data-table td {
    padding: 0.6rem 0.85rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: rgba(244, 81, 30, 0.03);
}

.data-table .cell-actions {
    white-space: nowrap;
}

.data-table .cell-id {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

/* ===================================
   Items Split View
   =================================== */

.items-split {
    display: flex;
    gap: 1rem;
    min-height: 400px;
}

.items-list-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.items-detail-panel {
    flex: 1;
    min-width: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
}

.items-detail-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 2rem;
    text-align: center;
}

.items-detail-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-shrink: 0;
}

.items-detail-header h4 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
}

.items-detail-id {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    word-break: break-all;
    padding: 0.4rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
}

.items-detail-body {
    padding: 1rem;
    flex: 1;
    overflow-y: auto;
    max-height: 60vh;
}

.items-detail-body pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 0.825rem;
    line-height: 1.6;
    color: var(--text-primary);
    margin: 0 0 1rem 0;
    font-family: inherit;
}

.items-detail-meta {
    border-top: 1px solid var(--border);
    padding: 0.75rem 1rem;
    flex-shrink: 0;
}

.items-detail-meta h5 {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 0 0 0.5rem 0;
}

.items-detail-meta-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.items-detail-meta-item {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
}

.item-row {
    padding: 0.6rem 0.85rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
}

.item-row:hover {
    background: var(--bg-elevated);
}

.item-row.active {
    background: rgba(244, 81, 30, 0.1);
    border-left: 3px solid var(--accent);
    padding-left: calc(0.85rem - 3px);
}

.item-row-id {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 250px;
}

.item-row-preview {
    font-size: 0.825rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.item-row-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.3rem;
}

@media (max-width: 768px) {
    .items-split {
        flex-direction: column;
    }
}

/* ===================================
   Pagination
   =================================== */

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.pagination-info {
    font-variant-numeric: tabular-nums;
}

.pagination-controls {
    display: flex;
    gap: 0.35rem;
}

.pagination-controls .btn {
    min-width: 32px;
    padding: 0.35rem 0.5rem;
}

/* ===================================
   Forms
   =================================== */

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 550;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.form-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

input[type="text"],
input[type="number"],
input[type="password"],
.text-input,
.select-input,
textarea {
    width: 100%;
    padding: 0.55rem 0.85rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    transition: border-color var(--transition);
}

input:focus,
.text-input:focus,
.select-input:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
}

::placeholder {
    color: var(--text-muted);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.select-input {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.25rem;
}

/* File Input */
.file-input {
    display: none;
}

.file-label {
    display: block;
    padding: 1rem;
    background: var(--bg-input);
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    text-align: center;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.85rem;
    transition: all var(--transition);
}

.file-label:hover {
    border-color: var(--accent);
    color: var(--text-secondary);
}

/* Inline form */
.form-inline {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.form-inline .form-group {
    margin-bottom: 0;
    flex: 1;
}

/* ===================================
   Badges
   =================================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.55rem;
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-success {
    background: var(--success-subtle);
    color: var(--success);
}

.badge-danger {
    background: var(--danger-subtle);
    color: var(--danger);
}

.badge-info {
    background: var(--accent-subtle);
    color: var(--accent);
}

.badge-warning {
    background: var(--warning-subtle);
    color: var(--warning);
}

.badge-muted {
    background: rgba(100, 116, 139, 0.15);
    color: var(--text-muted);
}

/* ===================================
   Modal
   =================================== */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 150ms ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    min-width: 400px;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 200ms ease;
    box-shadow: var(--shadow-lg);
}

@keyframes slideUp {
    from { transform: translateY(16px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* ===================================
   Toast
   =================================== */

.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    font-size: 0.825rem;
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: slideIn 250ms ease;
    pointer-events: auto;
    max-width: 380px;
}

.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-error { border-left: 3px solid var(--danger); }
.toast.toast-warning { border-left: 3px solid var(--warning); }
.toast.toast-info { border-left: 3px solid var(--accent); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===================================
   Log Viewer
   =================================== */

.log-viewer {
    background: #0a0a0a;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    height: 400px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    line-height: 1.6;
}

.log-line { margin-bottom: 1px; }
.log-line.error { color: var(--danger); }
.log-line.warning { color: var(--warning); }
.log-line.info { color: var(--success); }
.log-line.debug { color: var(--text-muted); }

.log-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

/* ===================================
   RAG
   =================================== */

.rag-input-group {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.rag-input-group textarea {
    flex: 1;
}

.rag-resposta {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    min-height: 100px;
    white-space: pre-wrap;
    font-size: 0.85rem;
    line-height: 1.7;
    margin-top: 1rem;
}

.rag-resposta:empty::before {
    content: 'A resposta aparecera aqui...';
    color: var(--text-muted);
}

.rag-chunks {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.75rem;
}

.chunk-tag {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

/* ===================================
   Env Editor
   =================================== */

.env-group {
    margin-bottom: 1.5rem;
}

.env-group-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border-subtle);
}

.env-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0;
}

.env-key {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--accent);
    min-width: 240px;
    flex-shrink: 0;
}

.env-value {
    flex: 1;
}

.env-value input {
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

.env-secret-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 4px;
}

.env-secret-toggle:hover {
    color: var(--text-secondary);
    background: var(--bg-elevated);
}

/* ===================================
   Empty State
   =================================== */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    text-align: center;
}

.empty-state svg {
    width: 40px;
    height: 40px;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.empty-state p {
    font-size: 0.85rem;
}

/* ===================================
   Loading
   =================================== */

.loading-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ===================================
   Search Results (knowledge)
   =================================== */

.search-result {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.search-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.search-result-score {
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

.search-result-score.high { color: var(--success); }
.search-result-score.medium { color: var(--warning); }
.search-result-score.low { color: var(--text-muted); }

.search-result-id {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.search-result-text {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.6;
    max-height: 120px;
    overflow: hidden;
}

/* ===================================
   Resultado (success/error messages)
   =================================== */

.resultado {
    font-size: 0.825rem;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm);
    margin-top: 0.75rem;
}

.resultado.sucesso {
    background: var(--success-subtle);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--success);
}

.resultado.erro {
    background: var(--danger-subtle);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

.resultado:empty {
    display: none;
}

/* ===================================
   Normas List
   =================================== */

.lista-items {
    max-height: 300px;
    overflow-y: auto;
}

.lista-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.45rem 0.65rem;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.825rem;
}

.lista-item:last-child {
    border-bottom: none;
}

.lista-item-name {
    color: var(--text-primary);
}

.lista-item-size {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-family: var(--font-mono);
}

/* ===================================
   Restart Overlay
   =================================== */

.restart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.restart-modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    min-width: 400px;
    max-width: 90vw;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.restart-modal h3 {
    font-size: 1.2rem;
    margin-bottom: 1.75rem;
}

.restart-steps {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
    text-align: left;
}

.restart-step {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    transition: all 0.3s;
}

.restart-step.active {
    color: var(--warning);
    background: var(--warning-subtle);
}

.restart-step.done {
    color: var(--success);
    background: var(--success-subtle);
}

.restart-step.error {
    color: var(--danger);
    background: var(--danger-subtle);
}

.step-icon {
    font-size: 1rem;
    min-width: 1.25rem;
    text-align: center;
    font-weight: bold;
}

.step-icon.spinner {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 2.5px solid rgba(245, 158, 11, 0.2);
    border-top-color: var(--warning);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    font-size: 0;
}

.restart-status-text {
    color: var(--text-secondary);
    font-size: 0.82rem;
    margin-bottom: 1rem;
    min-height: 1.2em;
}

/* ===================================
   Responsive
   =================================== */

@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .env-row {
        flex-direction: column;
        align-items: stretch;
    }

    .env-key {
        min-width: auto;
    }
}

@media (max-width: 640px) {
    .content-area {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .rag-input-group {
        flex-direction: column;
    }

    .section-toolbar {
        flex-direction: column;
    }

    .section-toolbar .select-input {
        min-width: 100%;
    }

    .modal {
        min-width: auto;
        margin: 1rem;
        max-width: calc(100vw - 2rem);
    }

    .form-inline {
        flex-direction: column;
    }
}

/* ===================================
   Login View
   =================================== */

body.login-view .sidebar {
    display: none;
}

body.login-view .main-content {
    margin-left: 0;
    width: 100%;
}

body.login-view .topbar {
    display: none;
}

body.login-view .content-area {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.login-card .login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.login-card .login-logo .logo-icon {
    width: 44px;
    height: 44px;
    font-size: 1.3rem;
}

.login-card .login-logo .logo-text {
    font-size: 1.35rem;
}

.login-card h2 {
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

.login-card .form-group {
    margin-bottom: 1.25rem;
}

.login-card .btn-primary {
    width: 100%;
    padding: 0.7rem;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.login-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
    font-size: 0.825rem;
    padding: 0.55rem 0.85rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    display: none;
}

.login-error.visible {
    display: block;
}

/* ===================================
   Sidebar User Menu
   =================================== */

.sidebar-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    min-width: 0;
    overflow: hidden;
}

.sidebar-user-info svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--accent);
}

.sidebar-user-info span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-logout-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-logout-btn:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.sidebar-logout-btn svg {
    width: 16px;
    height: 16px;
}
