/**
 * Sistributos — tema admin (sidebar, topbar, conteúdo e componentes).
 * Alinhado ao visual do módulo de protocolos.
 */
:root {
    --sis-bg: #f4f6fb;
    --sis-surface: #ffffff;
    --sis-text: #0f172a;
    --sis-muted: #64748b;
    --sis-border: #e2e8f0;
    --sis-primary: #2563eb;
    --sis-primary-hover: #1d4ed8;
    --sis-primary-soft: #dbeafe;
    --sis-success: #059669;
    --sis-danger: #dc2626;
    --sis-warning: #d97706;
    --sis-radius: 12px;
    --sis-radius-lg: 14px;
    --sis-shadow: 0 10px 40px -12px rgba(15, 23, 42, 0.12);
    --sis-sidebar-bg: #0f172a;
    --sis-sidebar-bg-hover: #1e293b;
    --sis-sidebar-text: #cbd5e1;
    --sis-sidebar-active: #2563eb;
}

/* ---- Shell AdminLTE ---- */
body.admin-theme {
    font-family: 'DM Sans', 'Source Sans Pro', system-ui, sans-serif;
    color: var(--sis-text);
    background: var(--sis-bg);
}

body.admin-theme .wrapper {
    background: var(--sis-bg);
}

body.admin-theme .main-header.navbar {
    background: var(--sis-surface) !important;
    border-bottom: 1px solid var(--sis-border) !important;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    min-height: 56px;
}

body.admin-theme .main-header .nav-link {
    color: var(--sis-text) !important;
    border-radius: 8px;
    font-weight: 500;
}

body.admin-theme .main-header .nav-link:hover {
    background: var(--sis-bg);
    color: var(--sis-primary) !important;
}

body.admin-theme .main-sidebar {
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%) !important;
    border-right: none !important;
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.08);
}

body.admin-theme .brand-link {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    padding: 1rem 0.85rem !important;
}

body.admin-theme .brand-link .brand-text {
    font-weight: 700;
    letter-spacing: -0.02em;
}

body.admin-theme .sidebar .nav-sidebar > .nav-item > .nav-link {
    border-radius: 10px;
    margin: 2px 0.5rem;
    color: var(--sis-sidebar-text);
    font-weight: 500;
    font-size: 0.9rem;
}

body.admin-theme .sidebar .nav-sidebar > .nav-item > .nav-link:hover {
    background: var(--sis-sidebar-bg-hover);
    color: #fff;
}

body.admin-theme .sidebar .nav-sidebar > .nav-item > .nav-link.active,
body.admin-theme .sidebar .nav-sidebar .menu-open > .nav-link {
    background: var(--sis-sidebar-active) !important;
    color: #fff !important;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

body.admin-theme .sidebar .nav-treeview > .nav-item > .nav-link {
    border-radius: 8px;
    margin: 1px 0.5rem 1px 1.25rem;
    font-size: 0.85rem;
}

/* Menu Notificações — destaque quando há não lidas (badge ou classe do AdminLTE) */
body.admin-theme #sidebar-menu-notificacoes > .nav-link.sis-menu-notificacoes--unread,
body.admin-theme #sidebar-menu-notificacoes:has(.badge) > .nav-link {
    position: relative;
    background: rgba(220, 38, 38, 0.22) !important;
    color: #fff !important;
    border-left: 3px solid #f87171;
    box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.25), 0 4px 16px rgba(220, 38, 38, 0.25);
    animation: sis-menu-notify-glow 2s ease-in-out infinite;
}

body.admin-theme #sidebar-menu-notificacoes > .nav-link.sis-menu-notificacoes--unread:hover,
body.admin-theme #sidebar-menu-notificacoes:has(.badge) > .nav-link:hover {
    background: rgba(220, 38, 38, 0.32) !important;
    color: #fff !important;
}

body.admin-theme #sidebar-menu-notificacoes > .nav-link.sis-menu-notificacoes--unread > .fa-bell,
body.admin-theme #sidebar-menu-notificacoes > .nav-link.sis-menu-notificacoes--unread > i.fa-bell,
body.admin-theme #sidebar-menu-notificacoes:has(.badge) > .nav-link > .fa-bell,
body.admin-theme #sidebar-menu-notificacoes:has(.badge) > .nav-link > i.fa-bell {
    position: relative;
    z-index: 1;
    color: #fecaca !important;
    animation: sis-bell-shake 1.25s ease-in-out infinite, sis-bell-sonar 2.2s ease-out infinite;
}

/* Sonar: anel no próprio ícone (não é cortado pelo overflow da sidebar) */
body.admin-theme #sidebar-menu-notificacoes > .nav-link.sis-menu-notificacoes--unread > .fa-bell::after,
body.admin-theme #sidebar-menu-notificacoes > .nav-link.sis-menu-notificacoes--unread > i.fa-bell::after,
body.admin-theme #sidebar-menu-notificacoes:has(.badge) > .nav-link > .fa-bell::after,
body.admin-theme #sidebar-menu-notificacoes:has(.badge) > .nav-link > i.fa-bell::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 2px solid rgba(252, 165, 165, 0.85);
    pointer-events: none;
    animation: sis-sonar-ping 2.2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

body.admin-theme #sidebar-menu-notificacoes > .nav-link.sis-menu-notificacoes--unread .badge,
body.admin-theme #sidebar-menu-notificacoes:has(.badge) > .nav-link .badge {
    font-weight: 700;
    font-size: 0.72rem;
    min-width: 1.4rem;
    padding: 0.2rem 0.45rem;
    box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.35);
    animation: sis-badge-pop 1.5s ease-in-out infinite;
}

@keyframes sis-sonar-ping {
    0% {
        transform: scale(0.85);
        opacity: 0.95;
    }

    100% {
        transform: scale(2.8);
        opacity: 0;
    }
}

@keyframes sis-bell-sonar {
    0% {
        filter: drop-shadow(0 0 0 rgba(248, 113, 113, 0.8));
    }

    55% {
        filter: drop-shadow(0 0 8px rgba(248, 113, 113, 0.45));
    }

    100% {
        filter: drop-shadow(0 0 0 rgba(248, 113, 113, 0));
    }
}

@keyframes sis-menu-notify-glow {
    0%,
    100% {
        box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.2), 0 4px 14px rgba(220, 38, 38, 0.2);
    }

    50% {
        box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.45), 0 4px 20px rgba(220, 38, 38, 0.45);
    }
}

@keyframes sis-bell-shake {
    0%,
    100% {
        transform: rotate(0deg);
    }

    10%,
    30% {
        transform: rotate(-12deg);
    }

    20%,
    40% {
        transform: rotate(12deg);
    }

    50% {
        transform: rotate(0deg);
    }
}

@keyframes sis-badge-pop {
    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.08);
    }
}

@media (prefers-reduced-motion: reduce) {
    body.admin-theme #sidebar-menu-notificacoes > .nav-link.sis-menu-notificacoes--unread,
    body.admin-theme #sidebar-menu-notificacoes:has(.badge) > .nav-link,
    body.admin-theme #sidebar-menu-notificacoes > .nav-link.sis-menu-notificacoes--unread > .fa-bell,
    body.admin-theme #sidebar-menu-notificacoes > .nav-link.sis-menu-notificacoes--unread > .fa-bell::after,
    body.admin-theme #sidebar-menu-notificacoes:has(.badge) > .nav-link > .fa-bell,
    body.admin-theme #sidebar-menu-notificacoes:has(.badge) > .nav-link > .fa-bell::after,
    body.admin-theme #sidebar-menu-notificacoes > .nav-link.sis-menu-notificacoes--unread .badge,
    body.admin-theme #sidebar-menu-notificacoes:has(.badge) > .nav-link .badge {
        animation: none;
    }
}

body.admin-theme .nav-header {
    color: rgba(148, 163, 184, 0.9) !important;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 600;
    margin-top: 0.5rem;
}

body.admin-theme .content-wrapper {
    background: var(--sis-bg) !important;
}

body.admin-theme .content-header {
    padding: 1.25rem 0 0.5rem;
}

body.admin-theme .content-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--sis-text);
    margin: 0 0 0.35rem;
}

body.admin-theme .breadcrumb {
    background: transparent;
    padding: 0;
    margin: 0;
    font-size: 0.875rem;
}

body.admin-theme .breadcrumb-item a {
    color: var(--sis-primary);
}

body.admin-theme .content {
    padding-top: 0.5rem;
    padding-bottom: 2rem;
}

body.admin-theme .main-footer {
    background: var(--sis-surface);
    border-top: 1px solid var(--sis-border);
    color: var(--sis-muted);
    font-size: 0.85rem;
}

/* ---- Cards / boxes ---- */
body.admin-theme .box,
body.admin-theme .card {
    border-radius: var(--sis-radius-lg);
    border: 1px solid var(--sis-border);
    box-shadow: var(--sis-shadow);
    background: var(--sis-surface);
}

body.admin-theme .box-header,
body.admin-theme .card-header {
    border-bottom: 1px solid var(--sis-border);
    padding: 1rem 1.25rem;
}

body.admin-theme .box-title,
body.admin-theme .card-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--sis-text);
}

body.admin-theme .box-body,
body.admin-theme .card-body {
    padding: 1.25rem;
}

body.admin-theme .box.box-primary {
    border-top: 3px solid var(--sis-primary);
}

body.admin-theme .box.box-success {
    border-top: 3px solid var(--sis-success);
}

body.admin-theme .box.box-info {
    border-top: 3px solid #0ea5e9;
}

body.admin-theme .box.box-warning {
    border-top: 3px solid var(--sis-warning);
}

body.admin-theme .box.box-danger {
    border-top: 3px solid var(--sis-danger);
}

/* ---- Botões ---- */
body.admin-theme .btn {
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

body.admin-theme .btn-primary,
body.admin-theme .btn-primary:focus {
    background: var(--sis-primary);
    border-color: var(--sis-primary);
}

body.admin-theme .btn-primary:hover {
    background: var(--sis-primary-hover);
    border-color: var(--sis-primary-hover);
}

body.admin-theme .btn-default,
body.admin-theme .btn-secondary {
    background: var(--sis-surface);
    border-color: var(--sis-border);
    color: var(--sis-text);
}

body.admin-theme .btn-default:hover {
    background: var(--sis-bg);
    border-color: #cbd5e1;
}

/* ---- Formulários ---- */
body.admin-theme .form-control {
    border-radius: 10px;
    border-color: var(--sis-border);
    font-size: 0.9rem;
    min-height: 38px;
}

body.admin-theme .form-control:focus {
    border-color: var(--sis-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

body.admin-theme label {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--sis-muted);
}

/* ---- Tabelas ---- */
body.admin-theme .table {
    font-size: 0.9rem;
}

body.admin-theme .table > thead > tr > th {
    border-bottom: 1px solid var(--sis-border);
    color: var(--sis-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

body.admin-theme .table-striped > tbody > tr:nth-of-type(odd) {
    background: #f8fafc;
}

body.admin-theme .table-hover > tbody > tr:hover {
    background: #f1f5f9;
}

/* ---- Labels / badges ---- */
body.admin-theme .label,
body.admin-theme .badge {
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.75rem;
}

body.admin-theme .label-success,
body.admin-theme .badge-success {
    background: #ecfdf5;
    color: #065f46;
}

body.admin-theme .label-primary,
body.admin-theme .badge-primary {
    background: var(--sis-primary-soft);
    color: #1e40af;
}

/* ---- Alertas ---- */
body.admin-theme .alert {
    border-radius: var(--sis-radius);
    border-width: 1px;
    font-weight: 500;
}

/* ---- Select2 no navbar ---- */
body.admin-theme .main-header .select2-container--default .select2-selection--single {
    border-radius: 10px;
    border-color: var(--sis-border);
    min-height: 34px;
}

/* ---- Módulo protocolos (proto-*) ---- */
.protocol-module {
    --proto-bg: var(--sis-bg);
    --proto-surface: var(--sis-surface);
    --proto-text: var(--sis-text);
    --proto-muted: var(--sis-muted);
    --proto-border: var(--sis-border);
    --proto-primary: var(--sis-primary);
    --proto-primary-hover: var(--sis-primary-hover);
    --proto-success: var(--sis-success);
    --proto-danger: var(--sis-danger);
    --proto-warning: var(--sis-warning);
    --proto-radius: var(--sis-radius-lg);
    --proto-shadow: var(--sis-shadow);
    font-family: inherit;
    color: var(--proto-text);
    line-height: 1.5;
}

.protocol-module a { color: var(--proto-primary); }
.protocol-module a:hover { color: var(--proto-primary-hover); }

.protocol-module .proto-flash {
    padding: 0.85rem 1rem;
    border-radius: var(--proto-radius);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.protocol-module .proto-flash--success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.protocol-module .proto-flash--error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.protocol-module .proto-card {
    background: var(--proto-surface);
    border-radius: var(--proto-radius);
    border: 1px solid var(--proto-border);
    box-shadow: var(--proto-shadow);
    padding: 1.5rem;
}

.protocol-module .proto-card + .proto-card { margin-top: 1rem; }
.protocol-module .proto-card h2 { margin: 0 0 1rem; font-size: 1.1rem; }

.protocol-module .proto-grid { display: grid; gap: 1rem; }

@media (min-width: 640px) {
    .protocol-module .proto-grid--2 { grid-template-columns: 1fr 1fr; }
}

.protocol-module label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--proto-muted);
    margin-bottom: 0.35rem;
}

.protocol-module input[type=text],
.protocol-module input[type=email],
.protocol-module input[type=number],
.protocol-module input[type=tel],
.protocol-module input[type=file],
.protocol-module select,
.protocol-module textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--proto-border);
    border-radius: 10px;
    font: inherit;
    background: #fff;
}

.protocol-module input:focus,
.protocol-module select:focus,
.protocol-module textarea:focus {
    outline: none;
    border-color: var(--proto-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.protocol-module .proto-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem 1.15rem;
    border-radius: 10px;
    font: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: 0.15s ease;
    text-decoration: none;
}

.protocol-module .proto-btn--primary { background: var(--proto-primary); color: #fff; }
.protocol-module .proto-btn--primary:hover { background: var(--proto-primary-hover); color: #fff; }
.protocol-module .proto-btn--ghost { background: transparent; border: 1px solid var(--proto-border); color: var(--proto-text); }
.protocol-module .proto-btn--danger { background: var(--proto-danger); color: #fff; }
.protocol-module .proto-btn--success { background: var(--proto-success); color: #fff; }

.protocol-module .proto-badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.protocol-module .proto-badge--open { background: #dbeafe; color: #1e40af; }
.protocol-module .proto-badge--closed { background: #f1f5f9; color: #475569; }

.protocol-module .proto-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }

.protocol-module .proto-table th,
.protocol-module .proto-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--proto-border);
}

.protocol-module .proto-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--proto-muted);
}

.protocol-module .proto-table tr:hover td { background: #f8fafc; }

.protocol-module .proto-timeline { list-style: none; padding: 0; margin: 0; }

.protocol-module .proto-timeline li {
    position: relative;
    padding-left: 1.5rem;
    padding-bottom: 1.25rem;
    border-left: 2px solid var(--proto-border);
    margin-left: 0.35rem;
}

.protocol-module .proto-timeline li::before {
    content: '';
    position: absolute;
    left: -0.4rem;
    top: 0.2rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--proto-primary);
}

.protocol-module .proto-timeline li:last-child {
    border-left-color: transparent;
    padding-bottom: 0;
}

.protocol-module .proto-item-row {
    border: 1px dashed var(--proto-border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.protocol-module .proto-modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 1050;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.protocol-module .proto-modal-backdrop.is-open { display: flex; }

.protocol-module .proto-modal {
    background: #fff;
    border-radius: var(--proto-radius);
    max-width: 480px;
    width: 100%;
    padding: 1.5rem;
    max-height: 90vh;
    overflow-y: auto;
}

.protocol-module .field-error { color: var(--proto-danger); font-size: 0.8rem; margin-top: 0.25rem; }
.protocol-module .proto-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }
.protocol-module .proto-page-title { font-size: 1.5rem; font-weight: 700; margin: 0 0 0.25rem; }
.protocol-module .proto-page-sub { color: var(--proto-muted); margin: 0 0 1.5rem; font-size: 0.95rem; }

/* ---- Login / auth ---- */
body.login-page,
body.register-page,
body.password-page {
    font-family: 'DM Sans', system-ui, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #2563eb 100%);
    min-height: 100vh;
}

body.login-page .card,
body.register-page .card {
    border-radius: var(--sis-radius-lg);
    border: 1px solid var(--sis-border);
    box-shadow: var(--sis-shadow);
}

body.login-page .btn-primary,
body.register-page .btn-primary {
    background: var(--sis-primary);
    border-color: var(--sis-primary);
    border-radius: 10px;
    font-weight: 600;
}

/* ---- Faixa de impersonate (acima da navbar fixa) ---- */
body.has-impersonation-banner {
    --impersonation-banner-height: 46px;
    --adminlte-navbar-height: 3.5rem;
}

body.has-impersonation-banner .impersonation-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1050;
    margin: 0;
    min-height: var(--impersonation-banner-height);
    padding-left: 250px;
    transition: padding-left 0.3s ease-in-out;
    border-bottom: 1px solid #e0a800 !important;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

body.has-impersonation-banner.sidebar-collapse .impersonation-banner {
    padding-left: 4.6rem;
}

body.has-impersonation-banner.layout-top-nav .impersonation-banner {
    padding-left: 1rem;
}

@media (max-width: 991.98px) {
    body.has-impersonation-banner .impersonation-banner {
        padding-left: 1rem;
    }
}

body.has-impersonation-banner.layout-navbar-fixed .main-header,
body.has-impersonation-banner.layout-fixed .main-header {
    top: var(--impersonation-banner-height) !important;
}

body.has-impersonation-banner.layout-navbar-fixed .main-sidebar,
body.has-impersonation-banner.layout-fixed .main-sidebar {
    top: calc(var(--impersonation-banner-height) + var(--adminlte-navbar-height)) !important;
}

body.has-impersonation-banner.layout-navbar-fixed .content-wrapper,
body.has-impersonation-banner.layout-fixed .content-wrapper {
    margin-top: calc(var(--impersonation-banner-height) + var(--adminlte-navbar-height)) !important;
}
