/* ===== IMPORTAÇÃO DE TODOS OS ARQUIVOS CSS ESPECÍFICOS ===== */
@import url('base.css');
@import url('custom.css');
@import url('dashboard.css');
@import url('agendamento.css');
@import url('certificado.css');
@import url('configuracoes.css');
@import url('conversor.css');
@import url('dowload.css');
@import url('empresa.css');
@import url('historico.css');
@import url('home.css');
@import url('login.css');
@import url('nfse.css');
@import url('pessoa.css');
@import url('perfil.css');
@import url('role.css');
@import url('painel_tv.css');
@import url('painel_departamento.css');
@import url('secretaria_painel.css');
@import url('atendimento_analista.css');
@import url('usuario_form.css');

/* ===== VARIÁVEIS ===== */
:root {
    --verde-deep: #16a34a;     /* verde mais saturado */
    --verde-light: #86efac;
    --verde-suave: #dcfce7;
    --amarelo-deep: #eab308;   /* amarelo mais noturno */
    --amarelo-light: #fef08a;
    --amarelo-suave: #fef3c7;
    --off-white: #F5F0E6;
    --cinza-escuro: #1f2937;   /* mais escuro */
    --cinza-claro: #f8f9fa;
    --azul-deep: #0ea5e9;      /* azul mais vibrante */
    --gradiente-principal: linear-gradient(135deg, #F5F0E6 0%, #E8F5E9 50%, #FFF8E1 100%);
    --gradiente-card: linear-gradient(135deg, #ffffff 0%, #fafafa 100%);
    --gradiente-verde: linear-gradient(135deg, var(--verde-deep), var(--verde-light));
    --gradiente-amarelo: linear-gradient(135deg, var(--amarelo-deep), var(--amarelo-light));
    --gradiente-misto: linear-gradient(135deg, var(--verde-deep), var(--amarelo-deep));
    --sombra-suave: 0 2px 8px rgba(0, 0, 0, 0.06);
    --sombra-media: 0 4px 12px rgba(0, 0, 0, 0.1);
    --sombra-hover: 0 8px 20px rgba(22, 163, 74, 0.2);
    --borda-suave: 1px solid rgba(76, 175, 80, 0.1);
    --transicao-padrao: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Modern neutral surfaces */
    --surface-1: #ffffff;
    --surface-2: #f9fafb;
    --surface-3: #f3f4f6;
    --muted: #6b7280;
    --glass: rgba(255,255,255,0.85);
    --shadow-soft: 0 4px 12px rgba(0,0,0,0.08);
    --radius-lg: 12px;
    --radius-md: 10px;
    --radius-sm: 6px;
    --text-color: #111827;     /* mais escuro */

    /* Accessible color accents */
    --primary-600: #15803d; /* deeper green */
    --primary-500: #16a34a;
    --primary-400: #4ade80;
    --accent-600: #0ea5a4;
    --danger-600: #dc2626;
    --muted-strong: #4b5563;
}

/* ===== RESET E ESTILOS GLOBAIS ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    /* base text compactado para economizar espaço */
    font-size: 0.95rem;
    line-height: 1.4;
}

body {
    background: var(--gradiente-principal);
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto; /* allow page vertical scrolling by default */
    color: var(--text-color);
    /* compact font sizes para 40% de redução */
    font-size: 0.95rem;
}

/* ===== LAYOUT PRINCIPAL ===== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* containers should use full screen width on all pages */
.container,
.container-fluid {
    max-width: none !important;
    width: 100% !important;
    padding-left: 12px;
    padding-right: 12px;
}
.container-fluid {
    padding-left: 0;
    padding-right: 0;
}

/* compact input sizes */
.form-control, .form-select, .form-check-label {
    font-size: 0.9rem;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 220px; /* narrower sidebar */
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-right: var(--borda-suave);
    box-shadow: var(--sombra-media);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2000;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* cards de módulos na home */
.module-card {
    transition: transform 0.28s ease, box-shadow 0.28s ease;
    border-radius: var(--radius-lg);
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: var(--surface-1);
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(15,23,42,0.03);
}
.module-card .card-header {
    font-size: 1.1rem;
    font-weight: 600;
}
.module-card .card-body {
    font-size: 0.9rem;
    color: #666;
}
.module-card:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}

/* add floating animation */
@keyframes floatin {
    from {opacity:0; transform: translateY(30px);} 
    to {opacity:1; transform: translateY(0);}    
}
.animate-fade-in {
    animation: floatin 0.6s ease-out forwards;
}

/* inputs de data compactos */
input[type=date] {
    font-size: 0.9rem;
    padding: 0.4rem;
}

/* dark mode global form overrides (applied beyond pessoa forms) */
body.dark-mode .form-control,
body.dark-mode .form-select,
body.dark-mode textarea {
    background: var(--surface-2) !important;
    color: #ffffff !important;
    border-color: rgba(255,255,255,0.2) !important;
}
body.dark-mode ::placeholder {
    color: rgba(255,255,255,0.6) !important;
}

/* cards estatísticos do dashboard */
.stat-card {
    border-radius: var(--radius-md);
    background: var(--surface-2);
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(15,23,42,0.03);
}
.stat-card .card-body h2 {
    line-height: 1;
    font-weight: 700;
}

/* tables compactos */
.table {
    font-size: 0.9rem;
    border-collapse: separate;
    border-spacing: 0 4px;
    width: 100%;
}

.table thead th {
    background: transparent;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 8px 10px;
    border-bottom: none;
}

.table tbody tr {
    /* use transparent tr and style cells for consistent rounded backgrounds */
    background: transparent;
}

.table td {
    padding: 8px 10px;
    vertical-align: middle;
    border: none;
    background: var(--surface-1);
    color: var(--text-color) !important;
}

/* rounded row effect by rounding first/last cell */
.table tbody tr td:first-child {
    border-top-left-radius: var(--radius-sm);
    border-bottom-left-radius: var(--radius-sm);
}
.table tbody tr td:last-child {
    border-top-right-radius: var(--radius-sm);
    border-bottom-right-radius: var(--radius-sm);
}

/* subtle zebra achieved via spacing and soft row backgrounds applied to cells */
.table tbody tr:nth-child(odd) td {
    background: var(--surface-2);
}

.table tbody tr:nth-child(even) td {
    background: rgba(16, 24, 40, 0.02);
}

.table-hover tbody tr:hover td {
    background: linear-gradient(90deg, rgba(22, 163, 74, 0.06), rgba(22, 163, 74, 0.03)) !important;
    box-shadow: inset 0 0 0 1px rgba(22, 163, 74, 0.15), 0 4px 12px rgba(22, 163, 74, 0.1);
    transform: translateY(-2px);
}

/* Melhorias de tabela - linhas com melhor diferenciação */
.table tbody tr {
    border-bottom: 1px solid #e5e7eb;
}
.table tbody tr:hover {
    background-color: rgba(22, 163, 74, 0.02);
}
.table thead th {
    font-weight: 700;
    color: #374151;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

/* compact variant for dense lists already defined earlier - keep it */

/* compact variant for dense lists */
.table--compact td {
    padding: 4px 8px;
    font-size: 0.85rem;
}

/* inputs de data compactos */
input[type=date] {
    font-size: 0.9rem;
    padding: 0.35rem;
}

/* Global card style */
.card {
    border-radius: var(--radius-md);
    background: var(--surface-1);
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(15,23,42,0.03);
    transition: var(--transicao-padrao);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 18px 40px rgba(16,24,40,0.08);
}

/* Buttons */
.btn {
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.2s ease;
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, #16a34a, #15803d);
    color: white;
    box-shadow: 0 4px 8px rgba(22, 163, 74, 0.2);
}
.btn-primary:hover, .btn-primary:focus {
    background: linear-gradient(135deg, #15803d, #166534);
    box-shadow: 0 6px 12px rgba(22, 163, 74, 0.3);
    transform: translateY(-2px);
}

.btn-success {
    background: linear-gradient(135deg, #31c855, #28a745);
    color: white;
    box-shadow: 0 4px 8px rgba(49, 200, 85, 0.2);
}
.btn-success:hover {
    background: linear-gradient(135deg, #28a745, #217a3b);
    box-shadow: 0 6px 12px rgba(49, 200, 85, 0.3);
    transform: translateY(-2px);
}

.btn-danger {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
    box-shadow: 0 4px 8px rgba(220, 38, 38, 0.2);
}
.btn-danger:hover {
    background: linear-gradient(135deg, #b91c1c, #991b1b);
    box-shadow: 0 6px 12px rgba(220, 38, 38, 0.3);
    transform: translateY(-2px);
}

.btn-warning {
    background: linear-gradient(135deg, #eab308, #ca8a04);
    color: #1f2937;
    box-shadow: 0 4px 8px rgba(234, 179, 8, 0.2);
}
.btn-warning:hover {
    background: linear-gradient(135deg, #ca8a04, #a16207);
    box-shadow: 0 6px 12px rgba(234, 179, 8, 0.3);
    transform: translateY(-2px);
}

.btn-outline-secondary {
    border-radius: var(--radius-sm);
    border-color: rgba(107, 114, 128, 0.3);
    color: #4b5563;
    background: transparent;
}
.btn-outline-secondary:hover {
    background: rgba(107, 114, 128, 0.1);
    border-color: rgba(107, 114, 128, 0.5);
}

.btn-outline-primary {
    border-color: #16a34a;
    color: #16a34a;
    background: transparent;
}
.btn-outline-primary:hover {
    background: rgba(22, 163, 74, 0.1);
    border-color: #15803d;
    color: #15803d;
}

/* Forms - softer inputs */
.form-control, .form-select {
    border-radius: 8px;
    border: 2px solid rgba(15, 23, 42, 0.08);
    background: var(--surface-1);
    padding: 8px 12px;
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

.form-control:hover, .form-select:hover {
    border-color: rgba(22, 163, 74, 0.2);
    background: rgba(22, 163, 74, 0.02);
}

.form-control:focus, .form-select:focus {
    border-color: #16a34a;
    background: var(--surface-1);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
    outline: none;
}

.form-control::placeholder,
.form-select::placeholder {
    color: var(--muted);
    opacity: 0.85;
}

/* Checkbox and radio improvements */
.form-check-input {
    border: 2px solid rgba(107, 114, 128, 0.3);
    border-radius: 4px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.form-check-input:hover {
    border-color: #16a34a;
}

.form-check-input:checked {
    background-color: #16a34a;
    border-color: #16a34a;
    box-shadow: 0 2px 4px rgba(22, 163, 74, 0.3);
}

.form-check-label {
    cursor: pointer;
    user-select: none;
}

/* Badges */
.badge {
    border-radius: 999px;
    padding: 6px 12px;
    font-weight: 600;
    font-size: 0.8rem;
    display: inline-block;
}

/* semantic badge colors with better contrast */
.badge.bg-success { 
    background: linear-gradient(135deg, #16a34a, #15803d) !important; 
    color: #fff !important; 
    box-shadow: 0 2px 4px rgba(22, 163, 74, 0.25);
}
.badge.bg-danger { 
    background: linear-gradient(135deg, #dc2626, #b91c1c) !important; 
    color: #fff !important; 
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.25);
}
.badge.bg-warning { 
    background: linear-gradient(135deg, #eab308, #ca8a04) !important; 
    color: #1f2937 !important; 
    box-shadow: 0 2px 4px rgba(234, 179, 8, 0.25);
}
.badge.bg-secondary { 
    background: linear-gradient(135deg, #6b7280, #4b5563) !important; 
    color: #fff !important; 
    box-shadow: 0 2px 4px rgba(107, 114, 128, 0.25);
}
.badge.bg-info { 
    background: linear-gradient(135deg, #0ea5e9, #0284c7) !important; 
    color: #fff !important; 
    box-shadow: 0 2px 4px rgba(14, 165, 233, 0.25);
}
.badge.bg-secondary { background: #374151 !important; color: #e6eef2 !important; }
.badge.bg-warning { background: linear-gradient(180deg,#f59e0b,#d97706) !important; color: #08121a !important; }
.badge.bg-danger { background: linear-gradient(180deg,#ef4444,#dc2626) !important; color: #fff !important; }
.badge.bg-info { background: linear-gradient(180deg,#06b6d4,#0891b2) !important; color: #fff !important; }

/* Estado colapsado */
.sidebar-collapsed {
    width: 60px;
}

/* ===== DARK MODE ===== */
body.dark-mode {
    background: #0b0b0c !important;
    color: #e6eef2;
    /* darker surfaces for components in dark mode */
    --surface-1: #0f1720;
    --surface-2: #111316;
    --surface-3: #16181a;
    --muted: #9aa6b2;
    --text-color: #e6eef2;
    /* compact font-size in dark mode */
    font-size: 0.95rem;
}

/* fixed dark toggle button */
#dark-toggle-fixed {
    background: var(--amarelo-deep);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: var(--sombra-media);
    transition: transform 0.3s ease;
}
#dark-toggle-fixed:hover {
    transform: scale(1.1);
}
#dark-toggle-fixed.dark {
    background: var(--cinza-escuro);
}
body.dark-mode .sidebar {
    background: rgba(24,24,24,0.98);
    border-right: 1px solid #333;
}

/* Removido para permitir override específico do formulário de pessoa */

body.dark-mode .form-control:focus,
body.dark-mode .form-select:focus {
    background: #333;
}

body.dark-mode .badge {
    background: #444 !important;
    color: #eee !important;
}

/* enforce text color globally */
body.dark-mode {
    color: #e0e0e0 !important;
}
body.dark-mode .main-content {
    background: transparent;
}
body.dark-mode .card,
body.dark-mode .module-card,
body.dark-mode .stat-card {
    background: var(--surface-1);
    color: var(--text-color);
    border-color: rgba(255,255,255,0.04);
}

/* tables in dark pages */
body.dark-mode .table {
    background: transparent;
    color: var(--text-color);
}
body.dark-mode .table thead th {
    color: var(--muted);
    background: transparent;
}
body.dark-mode .table tbody tr {
    background: transparent;
}
body.dark-mode .table th,
body.dark-mode .table td {
    border-color: rgba(255,255,255,0.04);
    color: var(--text-color) !important;
}
body.dark-mode .table tbody tr td {
    background: var(--surface-2) !important;
}
body.dark-mode .table-hover tbody tr:hover td {
    background: var(--surface-1) !important;
}

/* ensure hyperlinks are readable */
body.dark-mode a {
    color: #90caf9;
}
body.dark-mode .text-muted {
    color: rgba(230,238,242,0.72) !important;
}
body.dark-mode .badge {
    background: #333 !important;
    color: #eee !important;
}
body.dark-mode .btn-outline-secondary {
    color: #eee;
}

/* ===== TV MODE ===== */
.tv-mode body, .tv-mode .container-fluid {
    background: #000 !important;
}
.tv-mode .sidebar { display: none !important; }
.tv-mode .container-fluid { padding: 8px !important; }
.tv-mode .panel-controls { position: fixed; right: 8px; top: 8px; z-index: 4000; background: rgba(0,0,0,0.6); color: #fff; padding: 6px; border-radius: 6px; }
.tv-mode .panel-controls .btn { margin-left: 4px; }
.tv-mode .list-group-item { font-size: 1.4rem !important; padding: 0.8rem 1rem; }
.tv-mode h2, .tv-mode h4 { font-size: 1.8rem !important; color: #fff; }
.tv-mode .badge { font-size: 1.1rem; padding: 6px 10px; }
.tv-mode .tempo-espera, .tv-mode .tempo-atendimento { font-weight: 700; font-size: 1.6rem; }
.tv-mode .col-md-3, .tv-mode .col-md-4, .tv-mode .col-md-5 { padding: 8px !important; }
.tv-mode .panel-rotate-hidden { display: none !important; }

/* ===== TV MODE + DARK MODE ADJUSTMENTS =====
   When the user enables dark mode, make painel/TV cards and fields
   follow the same dark-surface pattern used across the app so that
   inputs and cards appear on a muted gray surface instead of pure black.
*/
body.tv-mode.dark-mode,
body.dark-mode.tv-mode,
.tv-mode body.dark-mode,
body.dark-mode .tv-mode,
.tv-mode.dark-mode {
    background: var(--surface-2) !important;
    color: var(--text-color) !important;
}

.tv-mode.dark-mode .container-fluid,
.tv-mode.dark-mode .column,
.tv-mode.dark-mode .card,
body.dark-mode .tv-mode .card {
    background: var(--surface-2) !important;
    color: var(--text-color) !important;
    border-color: rgba(255,255,255,0.04) !important;
    box-shadow: none !important;
}

.tv-mode.dark-mode .card.green { background: rgba(16,185,129,0.06) !important; }
.tv-mode.dark-mode .card.red { background: rgba(220,53,69,0.06) !important; }

.tv-mode.dark-mode .label,
.tv-mode.dark-mode .time,
.tv-mode.dark-mode .analyst-item .label,
.tv-mode.dark-mode .analyst-item .time {
    color: var(--text-color) !important;
}

.tv-mode.dark-mode .stats-footer {
    color: var(--muted) !important;
}

/* Ensure timers and small text contrast in dark mode */
.tv-mode.dark-mode .time { color: var(--muted) !important; }

/* Make list items and placeholders match other dark-mode styles */
.tv-mode.dark-mode .list-group-item,
.tv-mode.dark-mode .pending-item,
.tv-mode.dark-mode .attending-item,
.tv-mode.dark-mode .analyst-item {
    background: var(--surface-2) !important;
    border: 1px solid rgba(255,255,255,0.04) !important;
}

/* Inputs shown in TV/admin views should use muted surfaces */
.tv-mode.dark-mode input,
.tv-mode.dark-mode select,
.tv-mode.dark-mode textarea {
    background: var(--surface-2) !important;
    color: var(--text-color) !important;
    border: 1px solid rgba(255,255,255,0.04) !important;
}

/* compact controls for non-tv mode too */
.panel-controls { position: relative; display: inline-flex; gap: 8px; align-items: center; }
.panel-controls .control-label { color: var(--muted); font-size: 0.95rem; margin-right: 6px; }

/* small responsive adjustments for very large screens used by TVs */
@media (min-width: 1600px) {
    .tv-mode .list-group-item { font-size: 1.8rem !important; }
    .tv-mode h2, .tv-mode h4 { font-size: 2.4rem !important; }
}
    border-color: #555;
}
body.dark-mode .btn-outline-secondary:hover {
    background: #555;
}
/* Improve form controls, selects and checkboxes in dark mode for consistent contrast */
body.dark-mode .form-control,
body.dark-mode .form-select,
body.dark-mode textarea,
body.dark-mode .form-control:focus,
body.dark-mode .form-select:focus {
    background: #0f1214;
    color: var(--text-color);
    border: 1px solid rgba(255,255,255,0.06);
    box-shadow: none;
}
body.dark-mode .form-control::placeholder,
body.dark-mode .form-select::placeholder {
    color: rgba(230,238,242,0.45);
}
/* Checkboxes / radios */
body.dark-mode .form-check-input {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.08);
    width: 1.15rem;
    height: 1.15rem;
}
body.dark-mode .form-check-input:checked {
    background: var(--primary-500);
    border-color: var(--primary-500);
    box-shadow: 0 0 0 0.15rem rgba(22,163,74,0.12);
}
body.dark-mode .form-check-input:checked::after {
    background-color: #fff;
    color: #0f1720;
    opacity: 1;
}
/* Select2 compatibility: dark background for dropdowns if select2 is present */
body.dark-mode .select2-container .select2-selection--multiple,
body.dark-mode .select2-container .select2-selection--single {
    background: #0f1214;
    color: var(--text-color);
    border: 1px solid rgba(255,255,255,0.06);
}
body.dark-mode .select2-container--default .select2-results__option[aria-selected=true] {
    background: rgba(22,163,74,0.12);
}
/* Dropdowns and menus */
body.dark-mode .dropdown-menu {
    background: var(--surface-2);
    color: var(--text-color);
    border: 1px solid rgba(255,255,255,0.04);
}
body.dark-mode .dropdown-item {
    color: var(--text-color);
}
body.dark-mode .modal-content {
    background: var(--surface-1);
    color: var(--text-color);
}
/* Modal-specific dark-mode tweaks for certificate upload modal */
body.dark-mode .modal.show {
    background-color: rgba(0,0,0,0.75) !important;
}
body.dark-mode .modal-content {
    border: 1px solid rgba(255,255,255,0.04);
    box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}
body.dark-mode .modal-header {
    background: linear-gradient(135deg, rgba(22,163,74,0.08), rgba(255,193,7,0.06));
    color: var(--text-color);
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
body.dark-mode .modal-title { color: var(--text-color); }
body.dark-mode .modal-body { color: var(--text-color); }
body.dark-mode .modal-footer {
    background: transparent;
    border-top: 1px solid rgba(255,255,255,0.04);
}
body.dark-mode .modal .btn {
    color: var(--text-color);
}
body.dark-mode .modal .btn.btn-success {
    background: linear-gradient(90deg,#16a34a,#15803d);
    color: #fff;
}
body.dark-mode .modal .btn.btn-secondary {
    background: transparent;
    border-color: rgba(255,255,255,0.06);
    color: var(--text-color);
}
body.dark-mode #uploadProgress { background: rgba(255,255,255,0.03); }
body.dark-mode #uploadProgress .progress-bar.bg-success {
    background: linear-gradient(90deg,#16a34a,#15803d) !important;
    color: #fff;
}
body.dark-mode #uploadStatus.alert { background: var(--surface-2); color: var(--text-color); border: 1px solid rgba(255,255,255,0.04); }
/* file input appearance */
body.dark-mode input[type=file], body.dark-mode .form-control[type=file] {
    background: var(--surface-2);
    color: var(--text-color);
    border: 1px solid rgba(255,255,255,0.06);
}

/* Make icons and small text readable */
body.dark-mode .bi { color: #9fdba8 !important; }
/* Ensure tables maintain sufficient contrast */
body.dark-mode .table tbody tr td { background: var(--surface-2) !important; }

body.dark-mode .nav-link,
body.dark-mode .nav-text {
    color: #e0e0e0 !important;
}
body.dark-mode .nav-link.active {
    background: rgba(76,175,80,0.2);
}

/* Logo */
.sidebar-logo {
    padding: 12px 8px;
    text-align: center;
    border-bottom: var(--borda-suave);
    cursor: pointer;
    transition: var(--transicao-padrao);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo:hover {
    background: rgba(76, 175, 80, 0.05);
}

.sidebar-logo span {
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: -0.5px;
    display: inline-block;
    transition: var(--transicao-padrao);
}

.sidebar-logo #logoH {
    color: var(--verde-deep);
    transition: transform 0.3s ease, color 0.3s ease;
    font-size: 1.3rem;
    text-shadow: 0 1px 0 rgba(0,0,0,0.12);
}

/* Container dos itens do menu */
.sidebar .nav {
    padding: 8px 6px;
    display: flex;
    flex-direction: column;
    flex: 1;
    margin: 0;
    list-style: none;
}

/* Itens do menu */
.sidebar .nav-item {
    width: 100%;
    margin-bottom: 2px;
    list-style: none;
}

.sidebar .nav-link {
    color: var(--cinza-escuro);
    padding: 8px 10px;
    border-radius: 6px;
    transition: var(--transicao-padrao);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    font-size: 0.9rem;
}

/* Efeito de hover */
.sidebar .nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    background: var(--gradiente-misto);
    opacity: 0.1;
    transition: width 0.3s ease;
    z-index: -1;
}

.sidebar .nav-link:hover::before {
    width: 100%;
}

.sidebar .nav-link:hover {
    color: var(--verde-deep);
    transform: translateX(5px);
}

/* Ícones */
.sidebar .nav-link i {
    width: 18px;
    text-align: center;
    font-size: 1rem;
    color: var(--verde-deep);
    transition: var(--transicao-padrao);
    flex-shrink: 0;
}

/* Texto do menu */
.sidebar .nav-link .nav-text {
    transition: opacity 0.2s ease;
    font-size: 0.88rem;
}

/* Estado colapsado - esconde textos */
.sidebar-collapsed .nav-link .nav-text {
    opacity: 0;
    width: 0;
    display: none;
}

.sidebar-collapsed .sidebar-logo span:not(#logoH) {
    display: none;
}

.sidebar-collapsed .sidebar-logo {
    padding: 12px 0;
}

.sidebar-collapsed .nav-link {
    padding: 8px 0;
    justify-content: center;
}

/* stronger contrast for sidebar items in dark mode */
body.dark-mode .sidebar .nav-link,
body.dark-mode .sidebar .nav-link .nav-text {
    color: var(--text-color) !important;
    font-weight: 600;
}

/* small bounce on logo when toggled for affordance */
@keyframes logoBounce {
    0%{transform: translateY(0);}50%{transform: translateY(-4px);}100%{transform: translateY(0);}    
}

.sidebar-logo.logo-animate #logoH {
    animation: logoBounce 0.6s ease;
}

.sidebar-collapsed .nav-link i {
    margin: 0;
}

/* Link ativo */
.sidebar .nav-link.active {
    background: var(--gradiente-misto);
    color: white;
}

.sidebar .nav-link.active i {
    color: white;
}

.sidebar .nav-link.active::before {
    display: none;
}

/* Grupo superior - itens principais */
.nav-top {
    flex: 1;
}

/* Grupo inferior - perfil, config, logout */
.nav-bottom {
    margin-top: auto;
    border-top: var(--borda-suave);
    padding-top: 8px;
}

.nav-bottom .nav-item {
    margin-bottom: 2px;
}

.nav-bottom .nav-link {
    color: var(--cinza-escuro);
}

/* Estilo especial para o logout */
.nav-bottom .nav-link:last-child {
    color: #dc3545;
}

.nav-bottom .nav-link:last-child i {
    color: #dc3545;
}

.nav-bottom .nav-link:last-child:hover {
    color: #fff;
    background: linear-gradient(135deg, #dc3545, #c82333);
}

.nav-bottom .nav-link:last-child:hover i {
    color: white;
}

/* ===== CONTEÚDO PRINCIPAL ===== */
.main-content {
    flex: 1;
    margin-left: 220px;
    min-height: 100vh;
    padding: 12px 16px;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
    width: 100% !important;
    margin-right: 0;
    position: relative;
    z-index: 1;
}

/* Ensure main content can scroll independently when content overflows */
.main-content {
    /* do not constrain height here; allow body to scroll naturally */
    max-height: none;
    overflow: visible;
}

/* Ajuste quando sidebar está colapsada */
.sidebar-collapsed {
    width: 60px; /* keep icons only */
    background: #ffffff; /* solid to hide green gradient */
}
.sidebar-collapsed .sidebar-logo span:nth-child(2) {
    display: none; /* hide "automatize" text */
}
/* when collapsed we keep H horizontal; name hidden by other rule */
.sidebar-collapsed ~ .main-content {
    margin-left: 60px;
    width: calc(100% - 60px);
}

/* Container interno para centralizar conteúdo */
.content-container {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* ===== BREADCRUMB ===== */
.breadcrumb {
    background: transparent;
    padding: 0;
    margin: 0 0 10px 0;
}

.breadcrumb-item a {
    color: var(--verde-deep);
    font-weight: 500;
    transition: var(--transicao-padrao);
    text-decoration: none;
    font-size: 0.85rem;
}

.breadcrumb-item a:hover {
    color: var(--amarelo-deep);
}

.breadcrumb-item.active {
    color: #6c757d;
    font-size: 0.85rem;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: ">";
    color: var(--verde-deep);
    font-size: 0.9rem;
    line-height: 1;
    padding: 0 2px;
}

/* ===== TÍTULOS ===== */
h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 2px;
}

h1 i {
    color: var(--verde-deep);
}

h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

/* ===== CARDS GENÉRICOS (para referência) ===== */
.card {
    background: var(--gradiente-card);
    border: none;
    border-radius: 20px;
    box-shadow: var(--sombra-suave);
    transition: var(--transicao-padrao);
    overflow: hidden;
    position: relative;
    border: var(--borda-suave);
}

.card-header {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.1), rgba(255, 193, 7, 0.1));
    border-bottom: var(--borda-suave);
    padding: 10px 12px;
    font-weight: 600;
    color: var(--cinza-escuro);
}

.card-body {
    padding: 12px;
}

/* ===== UTILITÁRIOS ===== */
.text-success-gradient {
    background: var(--gradiente-verde);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Modern list-group styling for side cards (conversor recent items) */
.list-group-flush .list-group-item {
    background: var(--surface-1);
    border: 1px solid rgba(15,23,42,0.03);
    margin: 4px 6px;
    border-radius: 6px;
    padding: 8px 10px;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.list-group-flush .list-group-item + .list-group-item {
    margin-top: 4px;
}
.list-group-flush .list-group-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(16,24,40,0.06);
}
.list-group-flush .list-group-item .bi {
    color: var(--verde-deep);
    font-size: 0.95rem;
    margin-right: 6px;
}

/* dark mode list items */
body.dark-mode .list-group-flush .list-group-item {
    background: var(--surface-2) !important;
    border-color: rgba(255,255,255,0.04) !important;
    color: var(--text-color) !important;
}
body.dark-mode .list-group-flush .list-group-item .bi { color: #9be6a7; }

/* Painel de arquivos (conversor) - avoid empty white bar and style items */
#painelArquivos {
    background: transparent;
    padding: 0 6px 6px 6px;
    min-height: 0;
}

/* hide the element when empty to avoid stray bars */
#painelArquivos:empty {
    display: none;
}

/* file item placeholder styling (JS may inject items here) */
#painelArquivos .file-item,
#painelArquivos .arquivo-row {
    background: var(--surface-1);
    border: 1px solid rgba(15,23,42,0.03);
    border-radius: 6px;
    padding: 6px 8px;
    margin-bottom: 6px;
    box-shadow: 0 4px 12px rgba(15,23,42,0.03);
}

body.dark-mode #painelArquivos .file-item,
body.dark-mode #painelArquivos .arquivo-row {
    background: var(--surface-2) !important;
    border-color: rgba(255,255,255,0.04) !important;
    color: var(--text-color) !important;
}

/* Global upload area styling (works with inline fallback) */
.upload-area {
    border: 2px dashed rgba(148,163,184,0.18);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.18s ease;
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
}
.upload-area:hover {
    border-color: rgba(16,185,129,0.35);
    background-color: rgba(16,185,129,0.03);
}
body.dark-mode .upload-area {
    border: 3px dashed rgba(255,255,255,0.06);
    background: transparent;
}
body.dark-mode .upload-area:hover {
    border-color: rgba(16,185,129,0.35);
    background-color: rgba(16,185,129,0.02);
}

/* Slightly darker card headers in dark mode for separation */
body.dark-mode .card-header {
    background: rgba(255,255,255,0.02);
    color: var(--text-color);
}

/* ===== SCROLLBAR PERSONALIZADA ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.5);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--verde-deep), var(--amarelo-deep));
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #43A047, #FFB300);
}

/* ===== SELEÇÃO DE TEXTO ===== */
::selection {
    background: var(--verde-deep);
    color: white;
}

::-moz-selection {
    background: var(--verde-deep);
    color: white;
}

/* ===== RESPONSIVIDADE ===== */
@media (max-width: 1200px) {
    .main-content {
        padding: 12px 14px;
    }
}

@media (max-width: 992px) {
    .main-content {
        padding: 12px 12px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 180px;
    }
    
    .main-content {
        margin-left: 180px;
        padding: 10px 10px;
        width: calc(100% - 180px);
    }
    
    .sidebar-collapsed ~ .main-content {
        margin-left: 60px;
        width: calc(100% - 60px);
    }
    
    .sidebar .nav-link {
        padding: 6px 8px;
        font-size: 0.85rem;
    }
    
    h1 {
        font-size: 1.2rem;
    }
}

@media (max-width: 576px) {
    .main-content {
        padding: 8px 8px;
    }
    
    .sidebar .nav-link {
        padding: 6px 8px;
    }
    
    h1 {
        font-size: 1.1rem;
    }
    
    h2 {
        font-size: 1rem;
    }
}

/* Accessible focus outlines for keyboard users */
:focus {
    outline: none;
}

:focus-visible {
    outline: 2px solid rgba(76,175,80,0.9);
    outline-offset: 2px;
    box-shadow: 0 4px 12px rgba(76,175,80,0.06);
}

/* Buttons and interactive controls */
.btn:focus-visible,
.nav-link:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible,
.card:focus-visible,
.list-group-item:focus-visible {
    outline: 2px solid rgba(144,202,249,0.95);
    outline-offset: 1px;
}

/* Make table cells keyboard-focusable style when JS adds tabindex */
.table td:focus-visible {
    outline: 2px solid rgba(255,193,7,0.9);
    outline-offset: 1px;
}

/* Skip-link (visible on focus) */
.skip-to-content {
    position: absolute;
    left: -999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}
.skip-to-content:focus,
.skip-to-content:active {
    position: fixed;
    left: 12px;
    top: 12px;
    width: auto;
    height: auto;
    padding: 6px 10px;
    background: var(--surface-1);
    color: var(--text-color);
    border-radius: 4px;
    z-index: 9999;
    box-shadow: 0 6px 18px rgba(16,24,40,0.10);
}

/* Additional responsive enhancements */
/* Use fluid, readable type scaling */
html { font-size: clamp(14px, 1.2vw, 16px); }

/* Off-canvas sidebar for small screens */
@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        transform: translateX(-110%);
        transition: transform 0.22s ease;
        z-index: 2100;
        box-shadow: 0 8px 20px rgba(0,0,0,0.08);
    }
    .sidebar.sidebar-expanded {
        transform: translateX(0);
    }
    /* Main content occupies full width by default on small screens */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 10px !important;
    }
    /* Slight dim overlay when sidebar is visible (use pseudo element on body) */
    .sidebar.sidebar-expanded ~ .main-content::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.32);
        z-index: 2050;
        pointer-events: none;
    }
}

/* Tables: allow horizontal scroll on small screens */
@media (max-width: 768px) {
    .table-responsive, .table-scrollable {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    table.table {
        width: 100%;
        min-width: 560px;
    }
}

/* Transform tables into stacked cards on very small screens for readability */
@media (max-width: 520px) {
    .table-responsive table, .table-scrollable table {
        width: 100%;
    }
    .table-responsive table thead,
    .table-scrollable table thead {
        display: none;
    }
    .table-responsive table tbody tr,
    .table-scrollable table tbody tr {
        display: block;
        background: var(--surface-1);
        border-radius: 6px;
        margin-bottom: 6px;
        padding: 6px 8px;
        box-shadow: 0 4px 12px rgba(15,23,42,0.02);
    }
    .table-responsive table tbody tr td,
    .table-scrollable table tbody tr td {
        display: flex;
        justify-content: space-between;
        padding: 4px 0;
        border: none;
    }
    .table-responsive table tbody tr td::before,
    .table-scrollable table tbody tr td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--cinza-escuro);
        margin-right: 8px;
        flex: 0 0 48%;
        text-align: left;
    }
}

/* Cards and upload area spacing for small screens */
@media (max-width: 576px) {
    .card-header { padding: 8px 10px; }
    .card-body { padding: 8px; }
    .upload-area { padding: 12px; }
    .list-group-flush .list-group-item { margin: 3px 4px; padding: 6px 8px; }
}

/* Ensure forms and selects adapt */
@media (max-width: 480px) {
    .form-control, .form-select { font-size: 0.85rem; }
}

/* Provide a helper class to wrap tables when editing templates gradually */
.table-scrollable { width: 100%; }

/* ===== GLOBAL SCROLL FIX =====
   Ensure pages can scroll vertically by default while preserving
   the TV/painel mode which intentionally hides scrolling. This
   overrides accidental `overflow:hidden` on large containers. */
html, body, .app-wrapper, .main-content {
    height: auto !important;
    min-height: 100vh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

/* Keep TV mode (full-screen panels) non-scrollable as originally intended */
.tv-mode body, .tv-mode .container-fluid, .tv-mode .app-wrapper {
    height: 100vh !important;
    overflow: hidden !important;
}