/* Aistem AI Agents - Tema SaaS Clean */

:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --surface-elevated: #ffffff;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --primary: #dc2626;
    --primary-hover: #b91c1c;
    --primary-light: #fef2f2;
    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.14), 0 1px 2px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 4px 10px -1px rgba(15, 23, 42, 0.16), 0 2px 5px -1px rgba(15, 23, 42, 0.09);
    --shadow-lg: 0 10px 24px -3px rgba(15, 23, 42, 0.18), 0 4px 10px -2px rgba(15, 23, 42, 0.10);
    --sidebar-width: 260px;
}

/* ============================================
   Tema Escuro — grafite azulado, alto contraste
   ============================================ */
[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0a0e16;
    --surface: #121826;
    --surface-hover: #1c2434;
    --surface-elevated: #182031;
    --border: #232d42;
    --border-strong: #35415c;
    --text: #eef2f9;
    --text-secondary: #a3adbf;
    --text-muted: #7b879c;
    --primary: #dc2626;
    --primary-hover: #ef4444;
    --primary-light: rgba(220, 38, 38, 0.16);
    --success: #22c55e;
    --success-light: rgba(34, 197, 94, 0.14);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.14);
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.14);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.5), 0 2px 6px -2px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 12px 28px -6px rgba(0, 0, 0, 0.55), 0 6px 12px -4px rgba(0, 0, 0, 0.4);
    --card-inset: inset 0 1px 0 rgba(255, 255, 255, 0.045);
}

/* Fundo da página com brilho sutil da marca no topo */
[data-theme="dark"] body {
    background-color: var(--bg);
    background-image:
        radial-gradient(ellipse 70% 45% at 50% -15%, rgba(220, 38, 38, 0.09), transparent 70%),
        radial-gradient(ellipse 45% 35% at 92% -5%, rgba(59, 130, 246, 0.05), transparent 70%);
    background-attachment: fixed;
    background-repeat: no-repeat;
}

/* Tailwind dark mode overrides - backgrounds */
[data-theme="dark"] .bg-background { background-color: var(--bg) !important; }
[data-theme="dark"] .bg-white { background-color: var(--surface) !important; }
[data-theme="dark"] .bg-white\/80 { background-color: rgba(18, 24, 38, 0.82) !important; }
[data-theme="dark"] .bg-white\/50 { background-color: rgba(18, 24, 38, 0.5) !important; }
[data-theme="dark"] .bg-slate-50 { background-color: var(--bg) !important; }
[data-theme="dark"] .bg-slate-50\/50 { background-color: rgba(10, 14, 22, 0.5) !important; }
[data-theme="dark"] .bg-slate-100 { background-color: var(--surface-hover) !important; }
[data-theme="dark"] .bg-slate-200 { background-color: #2a344a !important; }
[data-theme="dark"] .bg-slate-900 { background-color: var(--bg) !important; }
[data-theme="dark"] .bg-slate-900\/50 { background-color: rgba(4, 7, 12, 0.6) !important; }
[data-theme="dark"] .bg-primary { background-color: var(--primary) !important; }
[data-theme="dark"] .bg-primary-light { background-color: var(--primary-light) !important; }
[data-theme="dark"] .bg-emerald-100 { background-color: rgba(34, 197, 94, 0.15) !important; }
[data-theme="dark"] .bg-emerald-50 { background-color: rgba(34, 197, 94, 0.1) !important; }
[data-theme="dark"] .bg-red-100 { background-color: rgba(239, 68, 68, 0.15) !important; }
[data-theme="dark"] .bg-red-50 { background-color: rgba(239, 68, 68, 0.1) !important; }
[data-theme="dark"] .bg-amber-100 { background-color: rgba(245, 158, 11, 0.15) !important; }
[data-theme="dark"] .bg-amber-50 { background-color: rgba(245, 158, 11, 0.1) !important; }
[data-theme="dark"] .bg-blue-100 { background-color: rgba(59, 130, 246, 0.15) !important; }
[data-theme="dark"] .bg-blue-50 { background-color: rgba(59, 130, 246, 0.1) !important; }
[data-theme="dark"] .bg-indigo-100 { background-color: rgba(99, 102, 241, 0.15) !important; }
[data-theme="dark"] .bg-sky-100 { background-color: rgba(14, 165, 233, 0.15) !important; }
[data-theme="dark"] .bg-purple-100 { background-color: rgba(168, 85, 247, 0.15) !important; }

/* Tailwind dark mode overrides - text colors */
[data-theme="dark"] .text-slate-900 { color: var(--text) !important; }
[data-theme="dark"] .text-slate-800 { color: #e2e8f0 !important; }
[data-theme="dark"] .text-slate-700 { color: #cdd6e4 !important; }
[data-theme="dark"] .text-slate-600 { color: var(--text-secondary) !important; }
[data-theme="dark"] .text-slate-500 { color: var(--text-muted) !important; }
[data-theme="dark"] .text-slate-400 { color: #5f6b81 !important; }
[data-theme="dark"] .text-primary { color: #f87171 !important; }
[data-theme="dark"] .text-danger { color: var(--danger) !important; }
[data-theme="dark"] .text-emerald-600,
[data-theme="dark"] .text-emerald-700,
[data-theme="dark"] .text-emerald-800 { color: #4ade80 !important; }
[data-theme="dark"] .text-red-600,
[data-theme="dark"] .text-red-700,
[data-theme="dark"] .text-red-800 { color: #f87171 !important; }
[data-theme="dark"] .text-red-900 { color: #fca5a5 !important; }
[data-theme="dark"] .text-amber-600,
[data-theme="dark"] .text-amber-700,
[data-theme="dark"] .text-amber-800,
[data-theme="dark"] .text-amber-900 { color: #fbbf24 !important; }
[data-theme="dark"] .text-blue-600,
[data-theme="dark"] .text-blue-700,
[data-theme="dark"] .text-blue-800,
[data-theme="dark"] .text-blue-900 { color: #60a5fa !important; }
[data-theme="dark"] .text-indigo-600 { color: #a5b4fc !important; }
[data-theme="dark"] .text-sky-700 { color: #7dd3fc !important; }
[data-theme="dark"] .text-purple-600 { color: #c4b5fd !important; }

/* Tailwind dark mode overrides - borders */
[data-theme="dark"] .border-slate-100,
[data-theme="dark"] .border-slate-200 { border-color: var(--border) !important; }
[data-theme="dark"] .border-slate-300,
[data-theme="dark"] .border-gray-300 { border-color: var(--border-strong) !important; }
[data-theme="dark"] .border-primary { border-color: var(--primary) !important; }
[data-theme="dark"] .border-primary\/20 { border-color: rgba(239, 68, 68, 0.3) !important; }
[data-theme="dark"] .border-emerald-100 { border-color: rgba(34, 197, 94, 0.22) !important; }
[data-theme="dark"] .border-emerald-200 { border-color: rgba(34, 197, 94, 0.3) !important; }
[data-theme="dark"] .border-red-100 { border-color: rgba(239, 68, 68, 0.22) !important; }
[data-theme="dark"] .border-red-200 { border-color: rgba(239, 68, 68, 0.3) !important; }
[data-theme="dark"] .border-red-500 { border-color: rgba(239, 68, 68, 0.55) !important; }
[data-theme="dark"] .border-amber-200 { border-color: rgba(245, 158, 11, 0.3) !important; }
[data-theme="dark"] .border-blue-100 { border-color: rgba(59, 130, 246, 0.22) !important; }
[data-theme="dark"] .border-blue-200 { border-color: rgba(59, 130, 246, 0.3) !important; }
[data-theme="dark"] .border-sky-200 { border-color: rgba(14, 165, 233, 0.3) !important; }
[data-theme="dark"] .border-white { border-color: rgba(255, 255, 255, 0.15) !important; }
[data-theme="dark"] .ring-red-500 { --tw-ring-color: rgba(239, 68, 68, 0.55) !important; }

/* Tailwind dark mode overrides - hovers */
[data-theme="dark"] .hover\:bg-slate-50:hover,
[data-theme="dark"] .hover\:bg-slate-100:hover { background-color: var(--surface-hover) !important; }
[data-theme="dark"] .hover\:bg-primary-hover:hover { background-color: var(--primary-hover) !important; }
[data-theme="dark"] .hover\:text-slate-900:hover,
[data-theme="dark"] .hover\:text-slate-600:hover { color: var(--text) !important; }
[data-theme="dark"] .hover\:text-red-600:hover { color: #f87171 !important; }
[data-theme="dark"] .hover\:border-primary:hover { border-color: var(--primary) !important; }
[data-theme="dark"] .focus\:border-primary:focus { border-color: var(--primary) !important; }
[data-theme="dark"] .focus\:ring-primary:focus,
[data-theme="dark"] .ring-primary { --tw-ring-color: rgba(239, 68, 68, 0.45) !important; }
[data-theme="dark"] .text-primary .hover\:text-slate-900:hover { color: var(--text) !important; }

/* Gradientes utilitários no escuro */
[data-theme="dark"] .from-primary {
    --tw-gradient-from: var(--primary) var(--tw-gradient-from-position);
    --tw-gradient-to: rgba(220, 38, 38, 0) var(--tw-gradient-to-position);
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}
[data-theme="dark"] .to-blue-400 { --tw-gradient-to: #7f1d1d var(--tw-gradient-to-position); }
[data-theme="dark"] .from-slate-50 {
    --tw-gradient-from: var(--surface) var(--tw-gradient-from-position);
    --tw-gradient-to: rgba(18, 24, 38, 0) var(--tw-gradient-to-position);
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}
[data-theme="dark"] .to-slate-200 { --tw-gradient-to: var(--surface-hover) var(--tw-gradient-to-position); }

/* Elevação: sombras profundas + filete de luz no topo dos cards */
[data-theme="dark"] .shadow-sm,
[data-theme="dark"] .shadow,
[data-theme="dark"] .shadow-md,
[data-theme="dark"] .shadow-lg,
[data-theme="dark"] .shadow-xl,
[data-theme="dark"] .shadow-2xl {
    box-shadow: var(--card-inset), var(--shadow-lg) !important;
}
[data-theme="dark"] .card,
[data-theme="dark"] .stat-card {
    box-shadow: var(--card-inset), var(--shadow);
}

/* Logo por tema: versão preta no claro, branca no escuro */
.logo-dark { display: none; }
[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark { display: block; }

/* Tema claro: fundo do menu levemente mais escuro que a página (separação visual) */
html:not([data-theme="dark"]) #sidebar { background-color: #f4f6fa; }

/* Tema claro: sombras mais intensas para nitidez visual (equivalente ao bloco escuro acima) */
html:not([data-theme="dark"]) .shadow-sm,
html:not([data-theme="dark"]) .shadow {
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.14), 0 2px 6px rgba(15, 23, 42, 0.08) !important;
}
html:not([data-theme="dark"]) .shadow-md {
    box-shadow: 0 4px 10px -1px rgba(15, 23, 42, 0.16), 0 2px 6px -1px rgba(15, 23, 42, 0.09) !important;
}
html:not([data-theme="dark"]) .shadow-lg,
html:not([data-theme="dark"]) .shadow-xl,
html:not([data-theme="dark"]) .shadow-2xl {
    box-shadow: 0 12px 28px -4px rgba(15, 23, 42, 0.18), 0 5px 12px -3px rgba(15, 23, 42, 0.10) !important;
}

/* Divisores no escuro */
[data-theme="dark"] .divide-slate-100 > * + * { border-color: var(--border) !important; }
[data-theme="dark"] .divide-y { border-style: solid; border-color: var(--border); }

/* Header com blur no escuro */
[data-theme="dark"] .backdrop-blur { background-color: rgba(18, 24, 38, 0.82) !important; }

/* Botões e alertas auxiliares no escuro */
[data-theme="dark"] .btn-danger:hover { background: rgba(239, 68, 68, 0.28); }
[data-theme="dark"] .btn-warning:hover { background: rgba(245, 158, 11, 0.28); }
[data-theme="dark"] .btn-success:hover { background: rgba(34, 197, 94, 0.28); }
[data-theme="dark"] .btn-info { background: rgba(14, 165, 233, 0.15); color: #7dd3fc; }
[data-theme="dark"] .btn-info:hover { background: rgba(14, 165, 233, 0.25); }
[data-theme="dark"] .alert-info { background: rgba(14, 165, 233, 0.12); color: #7dd3fc; }

/* Form elements dark mode */
[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
    background-color: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
}
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
    color: var(--text-muted);
}
[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
}
[data-theme="dark"] select option {
    background-color: var(--surface);
    color: var(--text);
}

/* Auth dark mode */
[data-theme="dark"] .auth-layout {
    background: linear-gradient(135deg, #0a0e16 0%, #131a2a 100%);
}

/* Logo gradient dark mode */
[data-theme="dark"] .sidebar-brand .logo-gradient,
[data-theme="dark"] .sidebar-user-avatar {
    background: linear-gradient(135deg, var(--primary), #991b1b);
}

/* Scrollbar discreta (ambos os temas, via variáveis) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 8px;
    border: 2px solid var(--bg);
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); background-clip: padding-box; }

/* Seleção de texto na cor da marca */
::selection { background: rgba(220, 38, 38, 0.35); color: #ffffff; }

/* Ensure smooth transitions */
* {
    transition-property: background-color, border-color, color;
    transition-duration: 150ms;
    transition-timing-function: ease-in-out;
}

/* SVG transitions for theme changes (dashboard charts, icons) */
svg *, svg path, svg circle, svg line, svg rect, svg polyline {
    transition: stroke 200ms ease, fill 200ms ease, stop-color 200ms ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
}

.sidebar-brand {
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand span {
    color: var(--primary);
}

.sidebar-brand p {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
    margin-left: 34px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.sidebar-nav-group {
    margin-bottom: 24px;
}

.sidebar-nav-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0 12px;
    margin-bottom: 8px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
    margin-bottom: 2px;
}

.sidebar-nav a:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.sidebar-nav a.active {
    background: var(--primary-light);
    color: var(--primary);
}

.sidebar-nav a svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

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

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

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

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-info p {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-info span {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s ease;
}

.sidebar-logout:hover {
    background: var(--danger-light);
    color: var(--danger);
}

/* Main */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.main-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 40;
}

.main-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.main-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.main-content {
    flex: 1;
    padding: 32px;
    max-width: 1400px;
    width: 100%;
}

/* Mobile menu */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--text-secondary);
}

.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 45;
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0;
    }

    .mobile-menu-btn {
        display: block;
    }

    .mobile-overlay.open {
        display: block;
    }
}

@media (max-width: 640px) {
    .main-header {
        padding: 16px;
    }

    .main-content {
        padding: 20px;
    }
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.card-body {
    padding: 24px;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.yellow { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }

.stat-info p {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-info h4 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    margin-top: 2px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
}

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

.btn-secondary:hover {
    background: var(--surface-hover);
}

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

.btn-danger:hover {
    background: #fecaca;
}

.btn-warning {
    background: var(--warning-light);
    color: var(--warning);
}

.btn-warning:hover {
    background: #fde68a;
}

.btn-success {
    background: var(--success-light);
    color: var(--success);
}

.btn-success:hover {
    background: #d1fae5;
}

.btn-info {
    background: #e0f2fe;
    color: #0369a1;
}

.btn-info:hover {
    background: #bae6fd;
}

.btn-outline-primary {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary-light);
}

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

.btn-outline-secondary:hover {
    background: var(--surface-hover);
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 14px 16px;
    text-align: left;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.05em;
    background: var(--bg);
}

.data-table tr:hover td {
    background: var(--surface-hover);
}

.data-table td {
    color: var(--text);
}

.data-table td:last-child {
    white-space: nowrap;
}

/* Bootstrap table override to keep theme */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
}

.table th,
.table td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table thead th {
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.05em;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.table-hover tbody tr:hover td {
    background: var(--surface-hover);
}

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

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

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

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

.badge-neutral {
    background: var(--surface-hover);
    color: var(--text-secondary);
}

.badge-secondary {
    background: var(--surface-hover);
    color: var(--text-secondary);
}

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

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

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    transition: all 0.15s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

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

.form-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    transition: all 0.15s ease;
    appearance: auto;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    transition: all 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-check-input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    margin-bottom: 20px;
}

/* Auth pages */
.auth-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: 40px;
}

.auth-brand {
    text-align: center;
    margin-bottom: 32px;
}

.auth-brand h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
}

.auth-brand span {
    color: var(--primary);
}

.auth-brand p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 6px;
}

.auth-error {
    background: var(--danger-light);
    color: var(--danger);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 20px;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-footer a {
    color: var(--primary);
    font-weight: 600;
}

/* Page header */
.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
}

.page-header p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Utilities */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.flex-col { flex-direction: column; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.align-items-center { align-items: center; }
.align-items-start { align-items: flex-start; }
.align-items-end { align-items: flex-end; }
.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.justify-content-start { justify-content: flex-start; }
.justify-content-end { justify-content: flex-end; }
.justify-end { justify-content: flex-end; }
.align-self-start { align-self: flex-start; }
.align-self-end { align-self: flex-end; }
.align-self-center { align-self: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.min-w-0 { min-width: 0; }
.min-h-screen { min-height: 100vh; }
.max-w-md { max-width: 420px; }
.hidden { display: none; }
.block { display: block; }
.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.text-center { text-align: center; }
.text-start { text-align: left; }
.text-end { text-align: right; }
.text-xs { font-size: 12px; }
.text-sm { font-size: 14px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 20px; }
.text-2xl { font-size: 24px; }
.text-3xl { font-size: 30px; }
.fs-1 { font-size: 36px; }
.fs-2 { font-size: 30px; }
.fs-3 { font-size: 24px; }
.fs-4 { font-size: 20px; }
.fs-5 { font-size: 18px; }
.fs-6 { font-size: 14px; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.uppercase { text-transform: uppercase; }
.text-secondary { color: var(--text-secondary); }
.text-text { color: var(--text); }
.text-primary { color: var(--primary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.border { border: 1px solid var(--border); }
.border-t { border-top: 1px solid var(--border); }
.border-dashed { border-style: dashed; }
.rounded { border-radius: var(--radius-sm); }
.rounded-lg { border-radius: var(--radius); }
.rounded-full { border-radius: 9999px; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }
.whitespace-pre-wrap { white-space: pre-wrap; }
.p-2 { padding: 8px; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.px-0 { padding-left: 0; padding-right: 0; }
.py-12 { padding-top: 48px; padding-bottom: 48px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mb-8 { margin-bottom: 32px; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.ms-2 { margin-left: 8px; }
.ms-3 { margin-left: 12px; }
.me-2 { margin-right: 8px; }
.me-3 { margin-right: 12px; }
.space-y-2 > * + * { margin-top: 8px; }
.space-y-3 > * + * { margin-top: 12px; }
.space-y-4 > * + * { margin-top: 16px; }
.space-y-6 > * + * { margin-top: 24px; }
.d-grid { display: grid; }
.d-flex { display: flex; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-block { display: block; }

/* Flexbox row/col grid system */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -12px;
    margin-left: -12px;
}

.row > * {
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    padding-right: 12px;
    padding-left: 12px;
}

.col {
    flex: 1 0 0%;
}

.col-auto {
    flex: 0 0 auto;
    width: auto;
}

.col-1 { flex: 0 0 auto; width: 8.33333333%; }
.col-2 { flex: 0 0 auto; width: 16.66666667%; }
.col-3 { flex: 0 0 auto; width: 25%; }
.col-4 { flex: 0 0 auto; width: 33.33333333%; }
.col-5 { flex: 0 0 auto; width: 41.66666667%; }
.col-6 { flex: 0 0 auto; width: 50%; }
.col-7 { flex: 0 0 auto; width: 58.33333333%; }
.col-8 { flex: 0 0 auto; width: 66.66666667%; }
.col-9 { flex: 0 0 auto; width: 75%; }
.col-10 { flex: 0 0 auto; width: 83.33333333%; }
.col-11 { flex: 0 0 auto; width: 91.66666667%; }
.col-12 { flex: 0 0 auto; width: 100%; }

@media (min-width: 576px) {
    .col-sm-1 { flex: 0 0 auto; width: 8.33333333%; }
    .col-sm-2 { flex: 0 0 auto; width: 16.66666667%; }
    .col-sm-3 { flex: 0 0 auto; width: 25%; }
    .col-sm-4 { flex: 0 0 auto; width: 33.33333333%; }
    .col-sm-5 { flex: 0 0 auto; width: 41.66666667%; }
    .col-sm-6 { flex: 0 0 auto; width: 50%; }
    .col-sm-7 { flex: 0 0 auto; width: 58.33333333%; }
    .col-sm-8 { flex: 0 0 auto; width: 66.66666667%; }
    .col-sm-9 { flex: 0 0 auto; width: 75%; }
    .col-sm-10 { flex: 0 0 auto; width: 83.33333333%; }
    .col-sm-11 { flex: 0 0 auto; width: 91.66666667%; }
    .col-sm-12 { flex: 0 0 auto; width: 100%; }
}

@media (min-width: 768px) {
    .col-md-1 { flex: 0 0 auto; width: 8.33333333%; }
    .col-md-2 { flex: 0 0 auto; width: 16.66666667%; }
    .col-md-3 { flex: 0 0 auto; width: 25%; }
    .col-md-4 { flex: 0 0 auto; width: 33.33333333%; }
    .col-md-5 { flex: 0 0 auto; width: 41.66666667%; }
    .col-md-6 { flex: 0 0 auto; width: 50%; }
    .col-md-7 { flex: 0 0 auto; width: 58.33333333%; }
    .col-md-8 { flex: 0 0 auto; width: 66.66666667%; }
    .col-md-9 { flex: 0 0 auto; width: 75%; }
    .col-md-10 { flex: 0 0 auto; width: 83.33333333%; }
    .col-md-11 { flex: 0 0 auto; width: 91.66666667%; }
    .col-md-12 { flex: 0 0 auto; width: 100%; }
}

@media (min-width: 1024px) {
    .col-lg-1 { flex: 0 0 auto; width: 8.33333333%; }
    .col-lg-2 { flex: 0 0 auto; width: 16.66666667%; }
    .col-lg-3 { flex: 0 0 auto; width: 25%; }
    .col-lg-4 { flex: 0 0 auto; width: 33.33333333%; }
    .col-lg-5 { flex: 0 0 auto; width: 41.66666667%; }
    .col-lg-6 { flex: 0 0 auto; width: 50%; }
    .col-lg-7 { flex: 0 0 auto; width: 58.33333333%; }
    .col-lg-8 { flex: 0 0 auto; width: 66.66666667%; }
    .col-lg-9 { flex: 0 0 auto; width: 75%; }
    .col-lg-10 { flex: 0 0 auto; width: 83.33333333%; }
    .col-lg-11 { flex: 0 0 auto; width: 91.66666667%; }
    .col-lg-12 { flex: 0 0 auto; width: 100%; }
}

@media (min-width: 1280px) {
    .col-xl-1 { flex: 0 0 auto; width: 8.33333333%; }
    .col-xl-2 { flex: 0 0 auto; width: 16.66666667%; }
    .col-xl-3 { flex: 0 0 auto; width: 25%; }
    .col-xl-4 { flex: 0 0 auto; width: 33.33333333%; }
    .col-xl-5 { flex: 0 0 auto; width: 41.66666667%; }
    .col-xl-6 { flex: 0 0 auto; width: 50%; }
    .col-xl-7 { flex: 0 0 auto; width: 58.33333333%; }
    .col-xl-8 { flex: 0 0 auto; width: 66.66666667%; }
    .col-xl-9 { flex: 0 0 auto; width: 75%; }
    .col-xl-10 { flex: 0 0 auto; width: 83.33333333%; }
    .col-xl-11 { flex: 0 0 auto; width: 91.66666667%; }
    .col-xl-12 { flex: 0 0 auto; width: 100%; }
}

/* Spacers for row gutters */
.g-0 { gap: 0; }
.g-1 { gap: 4px; }
.g-2 { gap: 8px; }
.g-3 { gap: 12px; }
.g-4 { gap: 16px; }
.g-5 { gap: 24px; }

/* CSS Grid */
.grid {
    display: grid;
}

.grid-cols-1 { grid-template-columns: repeat(1, 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); }
.lg\:col-span-2 { grid-column: span 2 / span 2; }
.lg\:col-span-1 { grid-column: span 1 / span 1; }

@media (min-width: 768px) {
    .md\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
    .md\:grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
    .md\:grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1024px) {
    .lg\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
    .lg\:grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
    .lg\:grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
}

.alert-success {
    background: var(--success-light);
    color: var(--success);
}

.alert-danger {
    background: var(--danger-light);
    color: var(--danger);
}

.alert-warning {
    background: var(--warning-light);
    color: var(--warning);
}

.alert-info {
    background: #e0f2fe;
    color: #0369a1;
}

.alert-dismissible {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.alert-dismissible .btn-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
}

.alert-dismissible .btn-close:hover {
    opacity: 1;
}

/* List group */
.list-group {
    display: flex;
    flex-direction: column;
}

.list-group-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.list-group-item:last-child {
    border-bottom: none;
}

.list-group-flush .list-group-item {
    border-left: none;
    border-right: none;
}

/* Text decoration */
.text-decoration-none {
    text-decoration: none;
}

/* Backgrounds */
.bg-white { background: var(--surface); }
.bg-light { background: var(--bg); }
.bg-primary { background: var(--primary); }
.bg-success { background: var(--success); }
.bg-warning { background: var(--warning); }
.bg-danger { background: var(--danger); }
.bg-secondary { background: var(--surface-hover); }
.bg-info { background: #0ea5e9; }

.bg-opacity-10 { background-opacity: 0.1; }

.text-white { color: #fff; }
.text-dark { color: var(--text); }

/* Width/height */
.w-100 { width: 100%; }
.h-100 { height: 100%; }

/* Bootstrap compatibility helpers */
.btn-sm { padding: 6px 10px; font-size: 12px; }
.fw-bold { font-weight: 700; }
.fw-medium { font-weight: 500; }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.py-5 { padding-top: 48px; padding-bottom: 48px; }
.align-middle { vertical-align: middle; }
.fade { transition: opacity 0.15s linear; opacity: 0; }
.fade.show { opacity: 1; }
.btn-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
    line-height: 1;
}
.btn-close:hover { opacity: 1; }

/* Cursor */
.cursor-pointer { cursor: pointer; }

/* Z-index */
.z-50 { z-index: 50; }

[data-theme="dark"] .fill-current {
    color: currentColor;
}

/* Aistem Core — indicador "digitando" e painel lateral */
.core-typing-dot { width: 6px; height: 6px; border-radius: 50%; background: #94a3b8; display: inline-block; animation: coreTyping 1.2s infinite; }
.core-typing-dot:nth-child(2) { animation-delay: .2s; }
.core-typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes coreTyping { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }

/* Aistem Core — balão: badge de não lidas + pulso quando há resposta nova */
/* (o botão mantém position:fixed do Tailwind, que já ancora o badge absoluto) */
#coreChatBadge { position: absolute; top: -3px; right: -3px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 9999px; background: #dc2626; color: #fff; font-size: 11px; font-weight: 700; line-height: 20px; text-align: center; pointer-events: none; }
#coreChatBadge:not(.hidden) { box-shadow: 0 0 0 2px #fff; }
[data-theme="dark"] #coreChatBadge:not(.hidden) { box-shadow: 0 0 0 2px #0f172a; }
#coreChatFab.core-fab-unread { animation: coreFabPulse 1.4s ease-in-out infinite; }
@keyframes coreFabPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(220, 38, 38, .45); }
    50% { transform: scale(1.08); box-shadow: 0 0 0 14px rgba(220, 38, 38, 0); }
}

#coreResizeHandle { position: absolute; top: 0; left: -4px; width: 8px; height: 100%; cursor: ew-resize; z-index: 20; }
#coreResizeHandle:hover { background: rgba(220, 38, 38, 0.15); }

/* Aistem Core — bolhas: textos longos (URLs, tokens, caminhos, código) não escapam do balão */
#coreChatMessages .core-bubble { min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
#coreChatMessages .core-bubble code { overflow-wrap: anywhere; word-break: break-all; }
#coreChatMessages .core-bubble a { overflow-wrap: anywhere; }
