/* CEU - estilo seguindo o NEaD Online (nead.quadrangular.online) */
@import url('https://fonts.googleapis.com/css?family=Roboto:300,400,500,300italic');
:root {
    --primary: #3f51b5;
    --primary-dark: #32408f;
    --primary-light: #e8eaf6;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --bg: #f3f4f6;
    --surface: #ffffff;
    --border: #e5e7eb;
    --text: #1f2937;
    --text-muted: #6b7280;
    --sidebar-w: 240px;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    font-weight: 300;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
small, .muted { color: var(--text-muted); }

/* ---------- topbar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center; gap: .75rem;
    background: var(--primary); color: #fff;
    padding: 0 1rem; height: 54px;
    box-shadow: var(--shadow);
}
.brand { color: #fff; font-weight: 700; font-size: 1.15rem; letter-spacing: .5px; }
.brand:hover { text-decoration: none; }
.menu-toggle {
    display: none; background: none; border: 0; color: #fff;
    font-size: 1.4rem; cursor: pointer; padding: .25rem .5rem;
}
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.user-name small { opacity: .75; }

/* ---------- layout ---------- */
.wrapper { display: flex; min-height: calc(100vh - 54px); }
.sidebar {
    width: var(--sidebar-w); flex-shrink: 0;
    background: var(--surface); border-right: 1px solid var(--border);
    padding: 1rem 0;
}
.nav-section {
    padding: .9rem 1.25rem .35rem;
    font-size: .72rem; font-weight: 700; letter-spacing: .08em;
    color: var(--text-muted); text-transform: uppercase;
}
.nav-item {
    display: flex; align-items: center; gap: .6rem;
    padding: .55rem 1.25rem; color: var(--text);
    border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--primary-light); text-decoration: none; }
.nav-item.active { background: var(--primary-light); border-left-color: var(--primary); color: var(--primary); font-weight: 600; }
.nav-icon { width: 1.4em; text-align: center; }
.content { flex: 1; padding: 1.5rem; min-width: 0; }

/* ---------- cards & page head ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1.25rem; margin-bottom: 1.25rem;
}
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: 1.1rem; }
.page-head h1 { flex: 1 1 auto; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1rem; }
.stat-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1.1rem; text-align: center; color: var(--text);
    transition: transform .12s ease, box-shadow .12s ease;
}
.stat-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.stat-icon { font-size: 1.8rem; }
.stat-value { font-size: 1.7rem; font-weight: 700; color: var(--primary); }
.stat-label { color: var(--text-muted); font-size: .85rem; }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: .4rem;
    border: 1px solid transparent; border-radius: 8px;
    padding: .5rem .95rem; font-size: .9rem; font-weight: 600;
    cursor: pointer; white-space: nowrap;
    background: var(--surface); color: var(--text);
    text-decoration: none !important;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.9); }
.btn-outline { background: transparent; border-color: rgba(255,255,255,.6); color: #fff; }
.btn-outline:hover { background: rgba(255,255,255,.12); }
.btn-light { border-color: var(--border); }
.btn-light:hover { background: var(--bg); }
.btn-sm { padding: .3rem .65rem; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .9rem; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=email],
select, textarea {
    width: 100%; margin-top: .25rem;
    padding: .5rem .65rem; font-size: .95rem; font-family: inherit;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); color: var(--text);
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--primary-light); border-color: var(--primary);
}
textarea { min-height: 90px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 0 1rem; }
.col-12 { grid-column: span 12; } .col-8 { grid-column: span 8; }
.col-6 { grid-column: span 6; } .col-4 { grid-column: span 4; }
.col-3 { grid-column: span 3; } .col-2 { grid-column: span 2; }
.form-actions { display: flex; gap: .6rem; margin-top: .5rem; flex-wrap: wrap; }
.check-inline { display: inline-flex; align-items: center; gap: .4rem; font-weight: 400; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
table.list { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.list th, table.list td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--border); }
table.list th { background: #f9fafb; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
table.list tbody tr:hover { background: var(--primary-light); }
table.list tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
td.actions { text-align: right; white-space: nowrap; }

/* ---------- badges / alerts ---------- */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 99px; font-size: .72rem; font-weight: 700; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-muted { background: var(--border); color: var(--text-muted); }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: var(--primary-light); color: var(--primary-dark); }
.alert { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-danger { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }

/* ---------- filter bar / pagination ---------- */
.filter-bar { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; align-items: center; }
.filter-bar input[type=text], .filter-bar select { width: auto; margin-top: 0; }
.filter-bar input[type=text] { min-width: 220px; }
.filter-bar label { display: flex; align-items: center; gap: .3rem; font-size: .85rem; color: var(--text-muted); }
.filter-bar input[type=date] { width: auto; margin-top: 0; }
.list th a { color: inherit; text-decoration: none; }
.list th a:hover { text-decoration: underline; }
.input-error { border-color: #c00 !important; background: #fff5f5; }
.pagination { display: flex; gap: .3rem; margin-top: 1rem; flex-wrap: wrap; align-items: center; }
.pagination a, .pagination span.cur {
    padding: .3rem .7rem; border: 1px solid var(--border); border-radius: 6px;
    background: var(--surface); font-size: .85rem;
}
.pagination span.cur { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.pagination .total { margin-left: auto; color: var(--text-muted); font-size: .85rem; }

/* ---------- itens (pedidos / etiquetas) ---------- */
.item-table input { margin-top: 0; }
.item-table td { vertical-align: middle; }
.autocomplete-wrap { position: relative; }
.autocomplete-list {
    position: absolute; z-index: 40; left: 0; right: 0; top: 100%;
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0,0,0,.12); max-height: 260px; overflow-y: auto;
}
.autocomplete-list div { padding: .5rem .7rem; cursor: pointer; font-size: .88rem; }
.autocomplete-list div:hover, .autocomplete-list div.sel { background: var(--primary-light); }

/* ---------- login ---------- */
.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}
.login-box {
    width: 100%; max-width: 380px; margin: 1rem;
    background: var(--surface); border-radius: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.3);
    padding: 2rem 2rem 1.6rem; text-align: center;
}
.login-logo { font-size: 3rem; }
.login-box h1 { margin: .25rem 0 0; }
.login-sub { color: var(--text-muted); margin: 0 0 1.4rem; }
.login-box form { text-align: left; }

/* ---------- permissões (grupos) ---------- */
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }

/* ---------- DataTables: skin copiado do NEaD (ceu_datatable.css + alunos.php) ---------- */
.grid-panel { background-color: ghostwhite; padding: 0 10px 10px; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }

/* sem "flash" de dados crus: a tabela só aparece com o grid pronto;
   enquanto isso, a ampulheta "Processando..." do NEaD */
.js .grid-panel:not(.dt-ready) table.ceugrid { display: none; }
.js .grid-panel .table-responsive { position: relative; min-height: 140px; }
.js .grid-panel:not(.dt-ready) .table-responsive::after {
    content: 'Processando...';
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background: rgba(255, 255, 159, 0.9);
    padding: 18px 22px; font-weight: bold; color: #3f51b5; font-size: 14px;
    z-index: 5; white-space: nowrap;
}
.js .grid-panel:not(.dt-ready) .table-responsive::before {
    content: '';
    position: absolute; top: calc(50% - 34px); left: 50%; transform: translateX(-50%);
    width: 22px; height: 22px; border: 3px solid #3f51b5; border-top-color: transparent;
    border-radius: 50%; z-index: 6;
    animation: ceu-spin .7s linear infinite;
}
@keyframes ceu-spin { to { transform: translateX(-50%) rotate(360deg); } }
/* sem overflow lateral: o Responsive do DataTables colapsa as colunas
   excedentes para dentro da linha expansível (setinha), como no NEaD */
.grid-panel .table-responsive { margin-top: 10px; }

table.dataTable {
    border: 0 solid #aaa;
    box-shadow: none;
    margin-top: 6px !important;
    margin-bottom: 6px !important;
    max-width: none !important;
    border-collapse: separate !important;
    border-radius: 5px;
    border-spacing: 1px;
    background: thistle;
    overflow: hidden;
    width: 99.5%;
}
table.dataTable th, table.dataTable td { padding: 10px; border-bottom: 1px solid #ddd; }
table.dataTable.compact thead th { padding: 4px; }
table.dataTable > thead > tr { background-color: lavender; }
table.dataTable > tfoot > tr { background-color: lavender; }
table.dataTable thead th, table.dataTable tfoot th {
    font-size: 12px;
    font-weight: normal;
    color: #3f51b5;
    text-transform: none;
    letter-spacing: 0;
}
table.dataTable tfoot th { padding: 5px 5px 5px 10px; }
table.dataTable tbody { color: #000; font-size: 12px; }
table.dataTable tbody td { padding: 6px 10px 8px 5px; font-size: 12px; border-bottom: 1px solid #ccc; background: transparent; }
table.dataTable tr.odd { background-color: white; }
table.dataTable tr.even { background-color: #fdf2f6; }
table.dataTable.order-column.stripe > tbody > tr.odd > .sorting_1,
table.dataTable.order-column.stripe > tbody > tr.even > .sorting_1 { font-weight: bolder; }
table.dataTable tbody tr:hover { background-color: lavender; color: #000; }
table.dataTable tbody tr.selected > * { box-shadow: inset 0 0 0 9999px rgb(255, 255, 204) !important; color: #000; }
table.dataTable a { text-decoration: none; }
table.dataTable .badge { font-size: 11px; padding: 5px 10px; border-radius: 4px; font-weight: 400; }
table.dataTable td.dt-control { cursor: pointer; }
table.dataTable td.child { background: #fdf2f6; }
table.dataTable td.child p { margin: 0; padding: 10px; font-size: 12px; }

/* barra de busca / paginação / info (cores e tamanhos do NEaD) */
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info { font-size: 11px; color: #3f51b5 !important; }
.dataTables_wrapper .dataTables_length { margin: 10px 0 0 10px; float: right; }
.dataTables_wrapper .dataTables_filter { margin: 10px 10px 0 0; float: left; text-align: left; position: relative; }
.dataTables_wrapper .dataTables_info { padding: 10px; clear: none; float: left; }
.dataTables_wrapper .dataTables_paginate { padding: 10px; float: right; }
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter select { font-size: 11px; font-weight: bold; width: auto; margin: 0; padding: 2px; border: 1px solid #aaa; border-radius: 3px; background: #fcfcfc; }
.dataTables_wrapper .dataTables_length select { display: inline-block; }
.dataTables_wrapper .dataTables_paginate .paginate_button { padding: .1em .3em; font-size: 11px; border-radius: 3px; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current { color: #fff !important; background: #3f51b5; border: 1px solid #3f51b5; }
.dataTables_wrapper .dataTables_filter input {
    width: 500px; max-width: 60vw; height: 25px;
    background: #fcfcfc; border: 1px solid #aaa; border-radius: 3px;
    text-indent: 5px; font-size: 12px; margin: 0 0 0 6px; padding: 0; display: inline-block;
}
.dataTables_wrapper .dataTables_processing { color: #3f51b5; font-size: 12px; }
.dataTables_wrapper .dt-buttons { display: flex; justify-content: center; align-items: center; margin: 10px 0; float: none; }

/* filtros por coluna no cabeçalho (linha .filterhead) */
table.dataTable thead th select { font-size: 11px; padding: 5px 0; }
table.dataTable thead .filterhead { padding: 4px; background-color: lavender; }
table.dataTable thead .filterhead input[type=text] {
    position: relative; width: 100%; height: 28px; margin: 0;
    background: #fcfcfc; border: 1px solid #aaa; border-radius: 3px;
    box-shadow: 0 0 3px #ccc, 0 10px 15px #fff inset;
    padding: 5px; font-size: .8rem; color: brown;
}
table.dataTable thead .filterhead input[type=text]::placeholder { color: #757575; }
table.dataTable thead .filterhead select {
    width: 100%; height: 28px; margin: 0; font-size: .8rem;
    background: #fcfcfc; border: 1px solid #aaa; border-radius: 3px; color: #333;
}
table.dataTable thead .filterhead input[type=checkbox] { width: unset; margin: 0; }

/* botões de exportação (colvis/copiar/excel/pdf/imprimir) */
.btn-showall-color { background-color: #3f51b5; color: lavender; }
.btn-showall-color:hover { color: #3f51b5; background-color: lavender; }
.dt-buttons .dt-button {
    border: 1px solid #3f51b5; border-radius: 4px; margin: 0 2px;
    padding: 4px 10px; font-size: 12px; cursor: pointer;
}
div.dt-button-collection { background: #fff; border: 1px solid #ccc; border-radius: 4px; box-shadow: 0 8px 10px -5px rgba(0,0,0,.5); padding: 4px; z-index: 2002; }
div.dt-button-collection .dt-button { display: block; width: 100%; text-align: left; background: #fff; color: #333; border: 0; margin: 0; padding: 5px 10px; }
div.dt-button-collection .dt-button:hover { background: lavender; color: #3f51b5; }
div.dt-button-collection .dt-button.dt-button-active { background: var(--primary-light); }
div.dt-button-background { position: fixed; inset: 0; z-index: 2001; background: transparent; }

/* fixedHeader deve ficar sob os modais */
table.dataTable.fixedHeader-floating { z-index: 45; }

.grid-topo::after, .grid-rodape::after { content: ''; display: block; clear: both; }
.dataTables_wrapper .selected .badge { background: transparent; }
table.dataTable thead .filterhead .select2-container { margin: 0; width: 100% !important; }
table.dataTable thead .filterhead .select2-container--default .select2-selection--single {
    height: 28px; border: 1px solid #aaa; border-radius: 3px; background: #fcfcfc;
}
table.dataTable thead .filterhead .select2-selection__rendered { line-height: 26px; font-size: .8rem; color: #333; }
table.dataTable thead .filterhead .select2-selection__arrow { height: 26px; }

/* ---------- responsivo ---------- */
@media (max-width: 900px) {
    .menu-toggle { display: block; }
    .sidebar {
        position: fixed; top: 54px; bottom: 0; left: 0; z-index: 60;
        transform: translateX(-100%); transition: transform .2s ease;
        overflow-y: auto; box-shadow: 4px 0 18px rgba(0,0,0,.15);
    }
    .sidebar.open { transform: translateX(0); }
    .content { padding: 1rem; }
    .user-name small { display: none; }
    .form-grid .col-2, .form-grid .col-3, .form-grid .col-4, .form-grid .col-6, .form-grid .col-8 { grid-column: span 12; }
    .filter-bar input[type=text] { min-width: 0; flex: 1; }
}
@media print {
    .topbar, .sidebar, .page-actions, .filter-bar, .pagination, .no-print { display: none !important; }
    .content { padding: 0; }
    body { background: #fff; }
    .card, .table-wrap { border: 0; box-shadow: none; }
}
