/* ======================================================================
   app-tabela.css — padrão visual unificado para telas de listagem
   Hero + KPIs + filtros + card + tabela + DataTables polish.

   Para usar em uma tela:
     <div class="app-hero">...</div>
     <div class="app-filter-card">...</div>
     <div class="app-card">
       <div class="app-card-head">...</div>
       <div class="table-responsive">
         <table class="table app-table" id="...">...</table>
       </div>
     </div>

   Carregado globalmente via includes/head.php — não duplicar nestes
   blocos no <style> das páginas; só CSS específico daquela tela.
   ====================================================================== */

/* ── Hero ── */
.app-hero {
    position: relative;
    border-radius: 18px;
    padding: 22px 26px;
    margin-bottom: 18px;
    background: #fff;
    border: 1px solid #ecedf2;
    box-shadow: 0 1px 3px rgba(20,24,50,.04);
    overflow: hidden;
}
.app-hero::before {
    content: ''; position: absolute; right: -120px; top: -120px;
    width: 320px; height: 320px; border-radius: 50%;
    background: radial-gradient(circle, rgba(115,102,255,.06) 0%, rgba(115,102,255,0) 70%);
    pointer-events: none;
}
.app-hero-top {
    display: flex; gap: 22px; flex-wrap: wrap;
    align-items: flex-start; justify-content: space-between;
    position: relative;
}
.app-hero-left { min-width: 0; flex: 1 1 360px; }
.app-eyebrow {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase;
    color: #8592a3; margin-bottom: 6px;
}
.app-eyebrow i { color: #7366ff; }
.app-hero h1 {
    color: #2c323f; font-weight: 700; font-size: 22px;
    margin: 0 0 4px 0; letter-spacing: -.2px;
}
.app-hero-sub {
    color: #5a6478; font-size: 13px; margin: 0;
    max-width: 720px; line-height: 1.5;
}
.app-hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.app-btn-primary {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 16px; font-size: 13px; font-weight: 600;
    border-radius: 9px; text-decoration: none;
    background: linear-gradient(135deg, #7366ff, #5a4dff);
    color: #fff !important; border: none;
    box-shadow: 0 2px 8px rgba(115,102,255,.24);
    transition: all .15s;
}
.app-btn-primary:hover {
    box-shadow: 0 4px 14px rgba(115,102,255,.32);
    transform: translateY(-1px); color: #fff !important;
}

/* ── KPI row ── */
.app-kpi-row {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
    margin-top: 16px; position: relative;
}
@media (max-width: 991px) { .app-kpi-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 575px) { .app-kpi-row { grid-template-columns: 1fr; } }
.app-kpi {
    background: #fafbff; border: 1px solid #f1f3f9; border-radius: 12px;
    padding: 14px 16px;
    display: flex; align-items: center; gap: 12px;
}
.app-kpi-icon {
    flex-shrink: 0; width: 42px; height: 42px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.app-kpi-icon.k-primary { background: #f1efff; color: #7366ff; }
.app-kpi-icon.k-success { background: #e6f6e4; color: #2f8a26; }
.app-kpi-icon.k-info    { background: #e1f0fc; color: #1d6fb8; }
.app-kpi-icon.k-warning { background: #fdf3cf; color: #8a6e00; }
.app-kpi-icon.k-danger  { background: #fde2e0; color: #b92e25; }
.app-kpi-body { min-width: 0; flex: 1; }
.app-kpi-label {
    font-size: 10.5px; font-weight: 700; letter-spacing: .5px;
    text-transform: uppercase; color: #7d8597; margin-bottom: 2px;
}
.app-kpi-value {
    font-size: 19px; font-weight: 700; color: #2c323f; line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.app-kpi-value.sm { font-size: 15px; }
.app-kpi-foot { font-size: 11px; color: #7d8597; margin-top: 3px; line-height: 1.3; }

/* ── Card de filtros ── */
.app-filter-card {
    border-radius: 14px; border: 1px solid #ecedf2;
    box-shadow: 0 1px 2px rgba(26,34,77,.03);
    margin-bottom: 18px; background: #fff; overflow: hidden;
}
.app-filter-head {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 22px; border-bottom: 1px solid #f1f3f9;
}
.app-filter-head .app-section-icon {
    width: 28px; height: 28px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    background: #f1efff; color: #7366ff; font-size: 12px; flex-shrink: 0;
}
.app-filter-head h5 { margin: 0; font-size: 13px; font-weight: 700; color: #2c323f; }
.app-filter-tag {
    margin-left: auto;
    font-size: 11px; font-weight: 700; color: #5d52d9;
    background: #f1efff; padding: 3px 10px; border-radius: 999px;
}
.app-filter-body { padding: 14px 22px 16px; }
.app-filter-body .form-label {
    font-size: 11px; font-weight: 700; color: #5a6478;
    letter-spacing: .3px; text-transform: uppercase; margin-bottom: 5px;
}
.app-filter-body .form-control,
.app-filter-body .form-select {
    border: 1px solid #ecedf2; border-radius: 9px;
    font-size: 13px; padding: 7px 12px;
}
.app-filter-body .form-control:focus,
.app-filter-body .form-select:focus {
    border-color: #7366ff; box-shadow: 0 0 0 3px rgba(115,102,255,.12);
}

/* ── Card lista ── */
.app-card {
    border-radius: 14px; border: 1px solid #ecedf2;
    box-shadow: 0 1px 2px rgba(26,34,77,.03);
    margin-bottom: 18px; background: #fff; overflow: hidden;
}
.app-card-head {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 14px 22px; border-bottom: 1px solid #f1f3f9;
}
.app-card-head .app-section-icon {
    width: 32px; height: 32px; border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center;
    background: #f1efff; color: #7366ff; font-size: 13px; flex-shrink: 0;
}
.app-card-head h5 { margin: 0; font-size: 14px; font-weight: 700; color: #2c323f; }
.app-card-head .app-count {
    background: #ecedf2; color: #5a6478;
    padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.app-card-head .ms-auto { margin-left: auto !important; }

/* Toggle inativos (botão fantasma usado no header do card) */
.app-toggle-inativos {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 12px; font-weight: 600; padding: 6px 11px;
    background: transparent; border: 1px solid #ecedf2; color: #5a6478;
    border-radius: 8px; text-decoration: none; transition: all .12s;
}
.app-toggle-inativos:hover { border-color: #7366ff; color: #7366ff; background: #f5f3ff; }
.app-toggle-inativos.is-on { background: #f5f3ff; border-color: #7366ff; color: #7366ff; }

/* ── Tabela ── */
.app-table { margin-bottom: 0; }
.app-table thead th {
    background: #fafbfe; color: #5a6478; font-size: 11px;
    font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
    border-bottom: 1px solid #e7eaf3; padding: 12px 14px;
}
.app-table tbody td {
    padding: 14px; vertical-align: middle; border-color: #f1f3f9;
    font-size: 13.5px; color: #2c323f;
}
.app-table tbody tr { transition: background .12s; }
.app-table tbody tr:hover { background: #fbfbff; }
.app-table tbody tr.app-row-inactive {
    color: #95a0b3; background: #fafbfc;
}
.app-table tbody tr.app-row-inactive .app-person-nome {
    text-decoration: line-through; opacity: .8;
}

/* ── Célula Pessoa (avatar + nome + sublabel) ── */
.app-person { display: flex; align-items: center; gap: 12px; }
.app-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, #7366ff 0%, #5d52d9 100%);
    color: #fff; font-weight: 700; font-size: 13px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    letter-spacing: -.3px;
}
.app-avatar.is-inactive { background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%); }
.app-person-info { min-width: 0; line-height: 1.35; }
.app-person-nome { font-weight: 600; color: #2c323f; font-size: 13.5px; display: block; }
.app-person-sub {
    display: block; font-size: 11.5px; color: #7d8597; margin-top: 1px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px;
}
.app-person-sub i { width: 11px; margin-right: 3px; color: #95a0b3; }

/* ── Tags, metas, badges ── */
.app-tag {
    display: inline-block; font-size: 11px; padding: 2px 9px; border-radius: 999px;
    background: #f1efff; color: #5d52d9; font-weight: 700; letter-spacing: .2px;
}
.app-meta { color: #5a6478; font-size: 12.5px; }
.app-meta strong { color: #2c323f; font-weight: 600; }
.app-valor { font-variant-numeric: tabular-nums; font-weight: 700; color: #2c323f; }
.app-valor-soft { font-variant-numeric: tabular-nums; color: #5a6478; }

/* ── Status pill ── */
.app-status {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px; border-radius: 999px;
    font-size: 11.5px; font-weight: 700;
}
.app-status.is-on { background: #e6f6e4; color: #2f8a26; }
.app-status.is-off { background: #fde2e0; color: #b92e25; }
.app-status.is-warn { background: #fdf3cf; color: #8a6e00; }
.app-status.is-none { background: #ecedf2; color: #5a6478; }
.app-status.is-info { background: #e1f0fc; color: #1d6fb8; }

/* ── Ações ── */
.app-acoes { display: flex; justify-content: flex-end; gap: 5px; flex-wrap: wrap; }
.app-acoes .btn { padding: 5px 9px; font-size: 12px; font-weight: 600; }

/* ── Empty state ── */
.app-empty {
    text-align: center; padding: 36px 16px;
    background: #fff; border: 1px solid #ecedf2; border-radius: 14px;
}
.app-empty-icon {
    width: 56px; height: 56px; border-radius: 14px;
    background: #f1efff; color: #7366ff;
    display: flex; align-items: center; justify-content: center; font-size: 22px;
    margin: 0 auto 14px;
}
.app-empty.is-success .app-empty-icon { background: #e6f6e4; color: #2f8a26; }
.app-empty.is-warning .app-empty-icon { background: #fdf3cf; color: #8a6e00; }
.app-empty h4 { font-size: 15px; font-weight: 700; color: #2c323f; margin: 0 0 4px; }
.app-empty p { font-size: 13px; color: #5a6478; margin: 0; }

/* ── Form body (para telas de adicionar/editar) ── */
.app-form-body { padding: 18px 22px 22px; }
.app-form-body .form-label {
    font-size: 11px; font-weight: 700; color: #5a6478;
    letter-spacing: .3px; text-transform: uppercase; margin-bottom: 5px;
}
.app-form-body .form-control,
.app-form-body .form-select {
    border: 1px solid #ecedf2; border-radius: 9px;
    font-size: 13.5px; padding: 8px 12px;
    transition: border-color .12s, box-shadow .12s;
}
.app-form-body .form-control:focus,
.app-form-body .form-select:focus {
    border-color: #7366ff; box-shadow: 0 0 0 3px rgba(115,102,255,.12);
}
.app-form-body .form-control.is-valid { border-color: #2f8a26; }
.app-form-body .form-control.is-invalid { border-color: #b92e25; }

/* input-group com ícone à esquerda — radius coerente */
.app-form-body .input-group .input-group-text {
    border: 1px solid #ecedf2;
    background: #f5f3ff;
    color: #7366ff;
    border-right: 0;
    border-radius: 9px 0 0 9px;
    min-width: 42px; justify-content: center;
}
.app-form-body .input-group > .form-control,
.app-form-body .input-group > .form-select {
    border-radius: 0 9px 9px 0;
}
.app-form-body .input-group .input-group-text.bg-light-success {
    background: #e6f6e4; color: #2f8a26;
}

/* Título de seção dentro do form (substitui <hr> simples) */
.app-form-section {
    font-size: 11px; font-weight: 700; letter-spacing: .5px;
    text-transform: uppercase; color: #7d8597;
    margin: 8px 0 6px;
    display: flex; align-items: center; gap: 8px;
}
.app-form-section::before {
    content: ''; flex: 0 0 14px; height: 2px; background: #7366ff; border-radius: 2px;
}
.app-form-section::after {
    content: ''; flex: 1; height: 1px; background: #f1f3f9;
}

/* Botões padrão no rodapé do form */
.app-form-actions {
    display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
    margin-top: 14px; padding-top: 16px; border-top: 1px solid #f1f3f9;
}

/* ── DataTables polish (aplica sempre que a tabela estiver dentro de .app-card) ── */
.app-card .dataTables_wrapper { padding: 14px 22px 16px; }
.app-card .dataTables_wrapper .dataTables_length,
.app-card .dataTables_wrapper .dataTables_filter { margin-bottom: 12px; }
.app-card .dataTables_wrapper .dataTables_info,
.app-card .dataTables_wrapper .dataTables_paginate { margin-top: 14px; }
.app-card .dataTables_wrapper .table-responsive {
    border: 1px solid #f1f3f9; border-radius: 10px; overflow: hidden;
}

/* Controles do DataTables — escopo amplo, não precisa do .app-card pai
   (também afeta páginas legadas, mas só refina visual sem quebrar) */
.dataTables_filter input {
    border: 1px solid #ecedf2; border-radius: 8px;
    padding: 6px 12px; font-size: 13px; outline: none;
    transition: border-color .12s;
    margin-left: 8px;
}
.dataTables_filter input:focus { border-color: #7366ff; }
.dataTables_length select {
    border: 1px solid #ecedf2; border-radius: 8px;
    padding: 5px 10px; font-size: 12.5px;
    margin: 0 6px;
}
.dataTables_info, .dataTables_length, .dataTables_filter, .dataTables_paginate {
    color: #5a6478; font-size: 12.5px;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 8px !important; margin: 0 2px !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: linear-gradient(135deg, #7366ff, #5a4dff) !important;
    color: #fff !important; border-color: transparent !important;
}
