/* --- VARIÁVEIS E RESET --- */
:root {
  --bg: #101014;
  --panel: #18181A;
  --panel-border: #2a2a2e;
  --muted: #a1a1aa;
  --accent: #B81636;
  --accent-dark: #a3132f;
  --gold: #facc15;
  --cyan: #06b6d4;
  --radius: 8px;
  --container-padding: 20px;
  --card-gap: 15px;
  --card-margin: calc(var(--card-gap) / 2);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100vh;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg);
  color: #E4E4E7;
  overflow: hidden;
}

/* --- ESTILO DE SCROLLBAR GLOBAL --- */
#sidebar .sidebar-menu-scrollable::-webkit-scrollbar,
#content-area::-webkit-scrollbar,
.modal-content::-webkit-scrollbar,
.featured-drag-area::-webkit-scrollbar {
  width: 8px;
}

#sidebar .sidebar-menu-scrollable::-webkit-scrollbar-track,
#content-area::-webkit-scrollbar-track,
.modal-content::-webkit-scrollbar-track,
.featured-drag-area::-webkit-scrollbar-track {
  background: transparent;
}

#sidebar .sidebar-menu-scrollable::-webkit-scrollbar-thumb,
#content-area::-webkit-scrollbar-thumb,
.modal-content::-webkit-scrollbar-thumb,
.featured-drag-area::-webkit-scrollbar-thumb {
  background-color: #444;
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: content-box;
}
#sidebar .sidebar-menu-scrollable::-webkit-scrollbar-thumb:hover,
#content-area::-webkit-scrollbar-thumb:hover,
.modal-content::-webkit-scrollbar-thumb:hover,
.featured-drag-area::-webkit-scrollbar-thumb:hover {
    background-color: #555;
}


/* --- ESTRUTURA PRINCIPAL --- */
#app-container {
  display: flex;
  height: 100vh;
}
#content-area {
  flex-grow: 1;
  padding: var(--container-padding);
  overflow-y: auto;
}

/* --- SIDEBAR --- */
#sidebar {
  width: 260px;
  background-color: #1f1f23;
  padding: 0; /* Removido para controle total dos filhos */
  border-right: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

/* -- CABEÇALHO DA SIDEBAR (COM LOGO) -- */
.sidebar-header-link {
    display: block;
    text-decoration: none;
    padding: 20px 10px 0 10px;
    flex-shrink: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px 20px 10px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--panel-border);
}
.sidebar-header img {
  width: 32px;
  height: 32px;
}
.sidebar-header h1 {
  color: #ffffff;
  font-size: 1.5rem;
  font-weight: 700;
}

/* -- ÁREA DE MENU ROLÁVEL -- */
.sidebar-menu-scrollable {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

/* -- ITENS DO MENU (REFORMULADO) -- */
.menu-category {
    margin-bottom: 5px;
}

.menu-category h2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 15px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.menu-category h2:hover {
    background-color: var(--panel-border);
    color: #E4E4E7;
}

.menu-category .chevron-icon {
    width: 18px;
    height: 18px;
    stroke-width: 2.5;
    transition: transform 0.3s ease-out;
    color: var(--muted);
}

/* Estado Expandido */
.menu-category.expanded > h2 {
    background-color: #2a2a2e;
    color: #ffffff;
}

.menu-category.expanded > h2 .chevron-icon {
    transform: rotate(90deg);
    color: #ffffff;
}

.menu-category .submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease-in-out, padding 0.35s ease-in-out; /* Animação mais suave */
    border-radius: var(--radius);
}

.menu-category.expanded .submenu {
    padding: 8px;
    margin-top: 4px;
    background-color: rgba(0, 0, 0, 0.15); /* Cor de destaque para o conteúdo */
    max-height: 500px;
}

/* Itens dentro do submenu */
.submenu .menu-item a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 15px 10px 25px; /* Aumenta o padding esquerdo para indentar */
    margin: 2px 0;
    border-radius: var(--radius);
    text-decoration: none;
    color: #E4E4E7;
    font-weight: 500;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.submenu .menu-item a:hover {
    background-color: var(--accent);
    color: #ffffff;
}

/* -- ITEM ATIVO -- */
.submenu .menu-item a.active {
    background-color: var(--accent);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 0 15px rgba(184, 22, 54, 0.4);
}

.submenu .menu-item a.active::before {
    content: '';
    position: absolute;
    left: 8px; /* Ajusta a posição da barra amarela */
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 60%;
    background-color: var(--gold);
    border-radius: 0 4px 4px 0;
}


/* --- Rodapé da Sidebar (Botão Sair) --- */
.sidebar-footer {
    padding: 10px;
    flex-shrink: 0;
    border-top: 1px solid var(--panel-border);
}

#logout-btn {
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    padding: 0;
    margin: 0;
}
#logout-btn a {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 15px; /* Padding interno do link */
    background-color: var(--accent);
    color: #ffffff;
    font-weight: 600;
    border-radius: var(--radius);
    transition: background-color 0.2s ease;
}
#logout-btn a:hover {
    background-color: var(--accent-dark);
    color: #ffffff;
}


/* --- ESTILOS GLOBAIS DE COMPONENTES --- */
.page-header {
  font-size: 1.8rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 16px;
}
.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.header-container .page-header {
  margin-bottom: 0;
  border-bottom: none;
  padding-bottom: 0;
}

/* --- CARD --- */
.card {
  background-color: var(--panel);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--panel-border);
  margin: var(--card-margin);
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: auto;
  box-sizing: border-box;
}

.card > *:last-child { 
    margin-bottom: 0; 
}

.card-header { font-size: 1.2rem; color: #ffffff; }
.card ul { list-style-type: none; padding: 0; margin: 0; }
.card li { padding: 12px 0; border-bottom: 1px solid var(--panel-border); font-size: 0.9rem; color: var(--muted); }
.card li:last-child { border-bottom: none; }

/* REGRA GLOBAL PARA VALORES DE ESTATÍSTICAS */
.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--cyan);
    margin-top: 8px;
    display: block;
    line-height: 1;
}

/* --- GRID DE CARDS --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 0;
  padding: var(--card-margin);
  align-items: start;
  align-content: start;
  grid-auto-rows: auto;
}

.card-grid > .card { align-self: stretch; }

/* --- BOTÕES --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, opacity 0.2s;
  text-decoration: none;
}
.btn-primary {
  background-color: var(--accent);
  color: white;
}
.btn-primary:hover {
  background-color: var(--accent-dark);
}
.btn-secondary {
  background-color: #2a2a2e;
  color: white;
}
.btn-secondary:hover {
  background-color: #4a4a50;
}
.btn-danger {
  background-color: #ef4444;
  color: white;
}
.btn-danger:hover {
  background-color: #dc2626;
}

/* --- FORMULÁRIOS --- */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
  font-size: 0.9rem;
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px;
  background-color: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  color: #E4E4E7;
  font-size: 1rem;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184, 22, 54, 0.3);
}
.form-group.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
}
.form-group.checkbox input {
  width: auto;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.form-actions {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* --- SVG ICON SYSTEM (GLOBAL) --- */
.icon {
  width: 20px;
  height: 20px;
  display: inline-block;
  vertical-align: middle;
  fill: currentColor;
  flex-shrink: 0;
}
.icon--stroke {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}
.icon--sm { width: 16px; height: 16px; }
.icon--md { width: 20px; height: 20px; }
.icon--lg { width: 24px; height: 24px; }


/* --- MODAL --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 100;
}
.modal-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: #1f1f23;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  z-index: 101;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
}
.modal-header h3 {
  font-size: 1.2rem;
  margin: 0;
}
.modal-header button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
}
.modal-content {
  padding: 24px;
  max-height: 70vh;
  overflow-y: auto;
}

/* --- TOASTS --- */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
}
.toast {
  background-color: #2a2a2e;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 8px;
  margin-bottom: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  opacity: 0;
  animation: toast-in 0.3s ease forwards;
}
@keyframes toast-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
.toast.error {
    background-color: var(--accent);
}

@keyframes toast-out {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.hidden {
  display: none !important;
}

/* --- LOADER --- */
#app-loader {
  position: fixed;
  inset: 0;
  background-color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.spinner {
  width: 50px;
  height: 50px;
  border: 6px solid var(--panel-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.content-loader-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 50vh;
}

.card > .table-wrapper {
    margin: 0 -24px -24px;
    border-radius: var(--radius);
    overflow: hidden; 
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; 
}

.data-table thead {
    background-color: #1f1f23;
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    border-bottom: 1px solid var(--panel-border);
}

.data-table td {
    padding: 12px 16px;
    vertical-align: middle;
    white-space: nowrap;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--panel-border);
    transition: background-color 0.2s ease;
}

.data-table tbody tr:last-child {
    border-bottom: none;
}

.data-table tbody tr:nth-of-type(even) {
    background-color: rgba(0, 0, 0, 0.15);
}

.data-table tbody tr:hover {
    background-color: #2a2a2e;
}


/* ==== ANTI-SELECT / ANTI-DRAG / FIX CURSOR ==== */
:where(html, body, *):not(a):not(button):not(input):not(textarea):not(select):not([contenteditable]) {
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
  cursor: default !important; 
}

input, textarea, select, [contenteditable] {
  -webkit-user-select: text !important;
  -moz-user-select: text !important;
  -ms-user-select: text !important;
  user-select: text !important;
  cursor: text !important;
}

a, button, [role="button"], .btn {
  cursor: pointer !important;
}

img {
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}
