/* =============================================================================
   auth-system - Design system proprio (CSS puro, sem framework).
   Organizado em: variaveis -> reset -> tipografia -> layout -> componentes ->
   utilitarios -> responsividade.
   ============================================================================= */

/* =============================================================================
   Tema claro/escuro
   -----------------------------------------------------------------------------
   Estrategia (3 estados possiveis):
     1. Nenhuma preferencia salva -> segue prefers-color-scheme do SO.
     2. Usuario clica no botao de tema -> grava "light"/"dark" no localStorage
        e forca via [data-theme] no <html> (ver public/assets/js/app.js e
        views/partials/theme-init.php, que aplica isso ANTES do primeiro
        paint para nao "piscar" o tema errado).
     3. [data-theme] sempre vence sobre prefers-color-scheme, nos dois sentidos.
   ============================================================================= */
/* Paleta alinhada ao AdminLTE 4 (Bootstrap 5.3): azul #0d6efd, fundo
   #f4f6f9, bordas #dee2e6, sidebar escura #343a40. Os nomes das variaveis
   sao mantidos para nao mexer nas ~20 views. */
:root {
    /* Paleta - tema claro (padrao) */
    --color-primary: #0d6efd;
    --color-primary-dark: #0b5ed7;
    --color-primary-light: #e7f1ff;
    --color-primary-text: #0a58ca;
    --color-primary-ring: rgba(13, 110, 253, 0.25);

    --color-success: #198754;
    --color-success-light: #d1e7dd;
    --color-success-text: #0f5132;
    --color-success-border: #badbcc;

    --color-danger: #dc3545;
    --color-danger-dark: #bb2d3b;
    --color-danger-light: #f8d7da;
    --color-danger-text: #842029;
    --color-danger-border: #f5c2c7;

    --color-warning: #ffc107;
    --color-warning-light: #fff3cd;
    --color-warning-text: #664d03;
    --color-warning-border: #ffecb5;

    --color-info: #0dcaf0;
    --color-info-light: #cff4fc;
    --color-info-text: #055160;
    --color-info-border: #b6effb;

    --color-bg: #f4f6f9;
    --color-surface: #ffffff;
    --color-hover-bg: #f2f4f7;
    --color-input-bg: #ffffff;
    --color-border: #dee2e6;
    --color-text: #212529;
    --color-text-muted: #6c757d;
    --color-text-inverse: #ffffff;
    --color-disabled: #adb5bd;

    --color-badge-inactive-bg: #e9ecef;
    --color-badge-inactive-text: #495057;

    --sidebar-bg: #343a40;
    --sidebar-text: #c2c7d0;
    --sidebar-text-active: #ffffff;
    --sidebar-active-bg: #0d6efd;
    --sidebar-hover-bg: rgba(255, 255, 255, 0.1);
    --sidebar-header-text: #868e96;
    --sidebar-border: rgba(255, 255, 255, 0.1);

    --auth-gradient: #e9ecef;

    --radius-sm: 0.375rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;

    --shadow-sm: 0 0 1px rgba(0, 0, 0, 0.125), 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);

    --font-sans: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --color-primary: #3d8bfd;
        --color-primary-dark: #5a9bfd;
        --color-primary-light: rgba(61, 139, 253, 0.2);
        --color-primary-text: #9ec5fe;
        --color-primary-ring: rgba(61, 139, 253, 0.35);

        --color-success: #22c55e;
        --color-success-light: rgba(34, 197, 94, 0.16);
        --color-success-text: #4ade80;
        --color-success-border: rgba(34, 197, 94, 0.35);

        --color-danger: #ef4444;
        --color-danger-dark: #f87171;
        --color-danger-light: rgba(248, 113, 113, 0.16);
        --color-danger-text: #fca5a5;
        --color-danger-border: rgba(248, 113, 113, 0.35);

        --color-warning: #fbbf24;
        --color-warning-light: rgba(251, 191, 36, 0.16);
        --color-warning-text: #fcd34d;
        --color-warning-border: rgba(251, 191, 36, 0.35);

        --color-info: #38bdf8;
        --color-info-light: rgba(56, 189, 248, 0.16);
        --color-info-text: #7dd3fc;
        --color-info-border: rgba(56, 189, 248, 0.35);

        --color-bg: #1a1d21;
        --color-surface: #2b3035;
        --color-hover-bg: #343a40;
        --color-input-bg: #2b3035;
        --color-border: #43494e;
        --color-text: #e9ecef;
        --color-text-muted: #adb5bd;
        --color-text-inverse: #1a1d21;
        --color-disabled: #6c757d;

        --color-badge-inactive-bg: #43494e;
        --color-badge-inactive-text: #ced4da;

        --sidebar-bg: #212529;
        --sidebar-active-bg: #3d8bfd;
        --sidebar-header-text: #6c757d;
        --sidebar-border: rgba(255, 255, 255, 0.08);

        --auth-gradient: #1a1d21;

        --shadow-sm: 0 0 1px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.6);
        --shadow-md: 0 0.5rem 1rem rgba(0, 0, 0, 0.5);
        --shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.6);

        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --color-primary: #3d8bfd;
    --color-primary-dark: #5a9bfd;
    --color-primary-light: rgba(61, 139, 253, 0.2);
    --color-primary-text: #9ec5fe;
    --color-primary-ring: rgba(61, 139, 253, 0.35);

    --color-success: #22c55e;
    --color-success-light: rgba(34, 197, 94, 0.16);
    --color-success-text: #4ade80;
    --color-success-border: rgba(34, 197, 94, 0.35);

    --color-danger: #ef4444;
    --color-danger-dark: #f87171;
    --color-danger-light: rgba(248, 113, 113, 0.16);
    --color-danger-text: #fca5a5;
    --color-danger-border: rgba(248, 113, 113, 0.35);

    --color-warning: #fbbf24;
    --color-warning-light: rgba(251, 191, 36, 0.16);
    --color-warning-text: #fcd34d;
    --color-warning-border: rgba(251, 191, 36, 0.35);

    --color-info: #38bdf8;
    --color-info-light: rgba(56, 189, 248, 0.16);
    --color-info-text: #7dd3fc;
    --color-info-border: rgba(56, 189, 248, 0.35);

    --color-bg: #1a1d21;
    --color-surface: #2b3035;
    --color-hover-bg: #343a40;
    --color-input-bg: #2b3035;
    --color-border: #43494e;
    --color-text: #e9ecef;
    --color-text-muted: #adb5bd;
    --color-text-inverse: #1a1d21;
    --color-disabled: #6c757d;

    --color-badge-inactive-bg: #43494e;
    --color-badge-inactive-text: #ced4da;

    --sidebar-bg: #212529;
    --sidebar-active-bg: #3d8bfd;
    --sidebar-header-text: #6c757d;
    --sidebar-border: rgba(255, 255, 255, 0.08);

    --auth-gradient: #1a1d21;

    --shadow-sm: 0 0 1px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.6);
    --shadow-md: 0 0.5rem 1rem rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.6);

    color-scheme: dark;
}

* { box-sizing: border-box; }

/* Garante que o atributo nativo "hidden" sempre vença qualquer classe que
   defina display (ex.: .btn { display: inline-flex }) -- sem isso, um
   elemento com hidden + uma classe dessas fica visivel mesmo assim, porque
   a especificidade de uma classe e igual a de [hidden] e a ordem de
   cascata (esta folha vem depois da UA stylesheet) decide o empate. */
[hidden] { display: none !important; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.2s ease, color 0.2s ease;
}

h1, h2, h3, h4 { margin: 0 0 0.5em; font-weight: 600; line-height: 1.25; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }
p { margin: 0 0 1em; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

small { color: var(--color-text-muted); font-size: 0.8125rem; }

/* ---------------------------------------------------------------------------
   Layout: pagina de autenticacao (login, esqueci senha, reset, primeiro acesso)
   --------------------------------------------------------------------------- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--auth-gradient);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 32px;
}

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--color-primary);
    color: #fff;
    font-weight: 700;
    font-size: 1.25rem;
    margin: 0 auto 20px;
}

.auth-card h1 {
    text-align: center;
    font-size: 1.375rem;
    margin-bottom: 4px;
}

.auth-subtitle {
    text-align: center;
    color: var(--color-text-muted);
    margin-bottom: 24px;
    font-size: 0.875rem;
}

.auth-footer-links {
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    font-size: 0.8125rem;
}

.theme-toggle-floating {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.theme-toggle-floating:hover { color: var(--color-primary); border-color: var(--color-primary); }

/* ---------------------------------------------------------------------------
   Layout: shell autenticado (sidebar + topbar + conteudo)
   --------------------------------------------------------------------------- */
.app-shell {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 0 0 20px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    /* Barra de rolagem oculta; a rolagem (roda, touch, teclado) continua funcionando */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.sidebar::-webkit-scrollbar { display: none; }

/* Gestao do sistema: dropdown fixado no final da sidebar */
.sidebar-admin {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--sidebar-border);
}

.sidebar-group-toggle {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 9px 12px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--sidebar-text);
    font: inherit;
    font-size: 0.9375rem;
    text-align: left;
    cursor: pointer;
}

.sidebar-group-toggle .icon { width: 18px; height: 18px; opacity: 0.85; }
.sidebar-group-toggle:hover,
.sidebar-group-toggle.is-active { background: var(--sidebar-hover-bg); color: #fff; }
.sidebar-group-toggle:hover .icon { opacity: 1; }

.sidebar-group-toggle .sidebar-group-chevron {
    margin-left: auto;
    width: 14px;
    height: 14px;
    transition: transform 0.15s ease;
}

.sidebar-group-toggle[aria-expanded="true"] .sidebar-group-chevron { transform: rotate(180deg); }

.sidebar-group { padding: 2px 0 0 12px; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    color: #fff;
    font-weight: 600;
    font-size: 1.125rem;
    letter-spacing: 0.02em;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-brand .brand-icon { width: 30px; height: 30px; border-radius: var(--radius-sm); flex: none; }

.sidebar-brand .badge-dot {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.sidebar-section-title {
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--sidebar-header-text);
    padding: 16px 20px 6px;
}

.sidebar-nav { padding: 0 8px; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 0.9375rem;
    margin-bottom: 1px;
}

.sidebar-nav a .icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.85;
}

.sidebar-nav a:hover {
    background: var(--sidebar-hover-bg);
    text-decoration: none;
    color: #fff;
}

.sidebar-nav a:hover .icon { opacity: 1; }

.sidebar-nav a.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-text-active);
    font-weight: 400;
    box-shadow: 0 0 1px rgba(0, 0, 0, 0.125);
}

.sidebar-nav a.active .icon { opacity: 1; }

/* ---------------------------------------------------------------------------
   Icones (SVG inline via App\Helpers\Icon)
   --------------------------------------------------------------------------- */
.icon { width: 18px; height: 18px; vertical-align: -3px; flex-shrink: 0; }
.icon-sm { width: 14px; height: 14px; vertical-align: -2px; }
.icon-lg { width: 24px; height: 24px; }

.topbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 57px;
}

.topbar-title { font-weight: 600; font-size: 1rem; color: var(--color-text); }
.topbar-title .icon { color: var(--color-text-muted); margin-right: 4px; }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8125rem;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-primary-light);
    color: var(--color-primary-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8125rem;
    flex-shrink: 0;
    overflow: hidden;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.avatar-lg { width: 48px; height: 48px; font-size: 1.125rem; }
.avatar-xl { width: 96px; height: 96px; font-size: 2rem; }

/* ---------------------------------------------------------------------------
   Upload de foto de perfil (Meus dados)
   --------------------------------------------------------------------------- */
.avatar-upload {
    position: relative;
    width: 96px;
    height: 96px;
    flex-shrink: 0;
}

.avatar-upload-trigger {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 3px solid var(--color-surface);
    transition: background 0.15s;
}

.avatar-upload-trigger:hover { background: var(--color-primary-dark); }
.avatar-upload-trigger .icon { width: 15px; height: 15px; }

.avatar-upload-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.avatar-upload.is-uploading .avatar { opacity: 0.45; }
.avatar-upload.is-uploading .avatar-upload-trigger { pointer-events: none; opacity: 0.6; }

.avatar-upload.is-uploading::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: var(--color-primary);
    animation: avatar-spin 0.7s linear infinite;
}

@keyframes avatar-spin {
    to { transform: rotate(360deg); }
}

/* ---------------------------------------------------------------------------
   Dropdown do menu do usuario (navbar)
   --------------------------------------------------------------------------- */
.user-menu { position: relative; }

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: 1px solid transparent;
    padding: 4px 10px 4px 4px;
    border-radius: 999px;
    cursor: pointer;
    color: var(--color-text);
    font-family: inherit;
}

.user-menu-trigger:hover { background: var(--color-hover-bg); }
.user-menu-trigger .icon { color: var(--color-text-muted); transition: transform 0.15s; }
.user-menu-trigger[aria-expanded="true"] .icon { transform: rotate(180deg); }

.user-menu-name { font-weight: 600; font-size: 0.8125rem; }

.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 230px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 50;
}

.dropdown-menu.is-open { display: block; }

.dropdown-header { padding: 10px 12px 8px; margin-bottom: 4px; border-bottom: 1px solid var(--color-border); }
.dropdown-name { font-weight: 700; font-size: 0.8125rem; }
.dropdown-email { font-size: 0.75rem; color: var(--color-text-muted); margin-top: 2px; word-break: break-all; }

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    color: var(--color-text);
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}

.dropdown-item:hover { background: var(--color-hover-bg); text-decoration: none; }
.dropdown-item .icon { color: var(--color-text-muted); }

.dropdown-item-danger { color: var(--color-danger); }
.dropdown-item-danger:hover { background: var(--color-danger-light); }
.dropdown-item-danger .icon { color: var(--color-danger); }

.dropdown-divider { height: 1px; background: var(--color-border); margin: 6px 4px; }

/* Dropdown de acoes em linhas de tabela: posicionado via JS (position: fixed)
   para nao ser cortado pelo overflow do .table-responsive. */
.dropdown-menu.dropdown-menu-floating { position: fixed; top: 0; left: 0; right: auto; min-width: 200px; text-align: left; }
.row-actions { display: inline-block; }
.row-actions-trigger { white-space: nowrap; }

.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.list-meta { font-size: 0.8125rem; color: var(--color-text-muted); margin: -4px 0 12px; }
.card-body.pb-0 { padding-bottom: 0; }

.content {
    padding: 24px 32px;
    max-width: 1920px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}

.page-header p { margin: 4px 0 0; color: var(--color-text-muted); }

/* ---------------------------------------------------------------------------
   Cards
   --------------------------------------------------------------------------- */
.card {
    background: var(--color-surface);
    border: 0;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 12px 20px;
    min-height: 48px;
    border-bottom: 1px solid var(--color-border);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.card-header h3,
.card-header .form-section-title { font-size: 1.1rem; font-weight: 500; }

.card-body { padding: 20px; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

/* AdminLTE "info-box": cartao branco com icone quadrado colorido a esquerda. */
.stat-card {
    background: var(--color-surface);
    border: 0;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 0;
    display: flex;
    align-items: stretch;
    gap: 0;
    overflow: hidden;
    min-height: 80px;
}

.stat-icon {
    width: 70px;
    border-radius: 0;
    background: var(--color-info);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon .icon { width: 26px; height: 26px; }

.stat-card > div:last-child {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 8px 16px;
    min-width: 0;
}

.stat-card .stat-label { color: var(--color-text-muted); font-size: 0.8125rem; margin-bottom: 2px; font-weight: 600; }
.stat-card .stat-value { font-size: 1.25rem; font-weight: 700; line-height: 1.3; word-break: break-word; }

/* Cores rotativas dos icones (padrao AdminLTE: info, success, warning, danger). */
.stat-grid > .stat-card:nth-child(4n + 1) .stat-icon { background: var(--color-info); }
.stat-grid > .stat-card:nth-child(4n + 2) .stat-icon { background: var(--color-success); }
.stat-grid > .stat-card:nth-child(4n + 3) .stat-icon { background: var(--color-warning); color: #1f2d3d; }
.stat-grid > .stat-card:nth-child(4n + 4) .stat-icon { background: var(--color-danger); }

/* ---------------------------------------------------------------------------
   Dashboard: banner de boas-vindas
   --------------------------------------------------------------------------- */
.hero-banner {
    background: linear-gradient(135deg, #0b5ed7 0%, #0d6efd 55%, #3d8bfd 100%);
    border-radius: var(--radius-md);
    padding: 24px 28px;
    color: #fff;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.hero-banner::after {
    content: "";
    position: absolute;
    right: -50px;
    top: -60px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
}

.hero-banner::before {
    content: "";
    position: absolute;
    right: 60px;
    bottom: -70px;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
}

.hero-banner h1 { color: #fff; margin-bottom: 4px; position: relative; }
.hero-banner p { color: rgba(255, 255, 255, 0.85); margin-bottom: 0; position: relative; }

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.18);
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 12px;
    position: relative;
}

/* ---------------------------------------------------------------------------
   Dashboard: atalhos como cards com icone
   --------------------------------------------------------------------------- */
.shortcut-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px;
}

.shortcut-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 18px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
    color: var(--color-text);
}

.shortcut-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    text-decoration: none;
    border-color: var(--color-primary);
}

.shortcut-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: var(--color-primary-light);
    color: var(--color-primary-text);
    display: flex;
    align-items: center;
    justify-content: center;
}

.shortcut-title { font-weight: 600; font-size: 0.875rem; }
.shortcut-desc { font-size: 0.75rem; color: var(--color-text-muted); }

/* ---------------------------------------------------------------------------
   Dashboard: feed de atividade recente
   --------------------------------------------------------------------------- */
.activity-list { list-style: none; margin: 0; padding: 0; }

.activity-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
    align-items: flex-start;
}

.activity-item:last-child { border-bottom: none; padding-bottom: 0; }

.activity-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-info-light);
    color: var(--color-info);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.activity-dot .icon { width: 16px; height: 16px; }
.activity-text { font-size: 0.8125rem; }
.activity-time { font-size: 0.75rem; color: var(--color-text-muted); margin-top: 1px; }

/* ---------------------------------------------------------------------------
   Formularios
   --------------------------------------------------------------------------- */
.form-group { margin-bottom: 18px; }

label {
    display: block;
    font-weight: 600;
    font-size: 0.8125rem;
    margin-bottom: 6px;
}

.form-hint { color: var(--color-text-muted); font-size: 0.75rem; margin-top: 4px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    line-height: 1.5;
    font-family: inherit;
    background: var(--color-input-bg);
    color: var(--color-text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 0.25rem var(--color-primary-ring);
}

input.is-invalid, select.is-invalid, textarea.is-invalid { border-color: var(--color-danger); }
input.is-invalid:focus, select.is-invalid:focus, textarea.is-invalid:focus {
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
}

.field-error { color: var(--color-danger); font-size: 0.75rem; margin-top: 4px; }

.password-field { position: relative; }

/* Reserva espaco para o botao Mostrar/Ocultar nao ficar sobre o texto digitado. */
.password-field input { padding-right: 72px; }
.password-field.input-icon input { padding-left: 38px; }

.password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 0.75rem;
    padding: 4px 8px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    font-weight: 400;
}

.checkbox-row input { width: auto; }

fieldset { border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 16px; margin: 0 0 18px; }
legend { font-weight: 600; font-size: 0.875rem; padding: 0 6px; }

.permission-module { margin-bottom: 18px; }
.permission-module:last-child { margin-bottom: 0; }
.permission-module h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    padding-bottom: 6px;
    border-bottom: 1px solid var(--color-border);
}

.permission-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }

/* Checkbox "chip": label vira um cartao clicavel, destacado quando marcado
   (via :has() -- degrada graciosamente para o checkbox comum em navegadores
   sem suporte, sem quebrar nada). */
.permission-grid label.checkbox-row {
    margin: 0;
    padding: 8px 10px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s, background 0.15s;
    cursor: pointer;
}

.permission-grid label.checkbox-row:hover { border-color: var(--color-primary); }
.permission-grid label.checkbox-row:has(input:checked) { border-color: var(--color-primary); background: var(--color-primary-light); font-weight: 600; }

/* ---------------------------------------------------------------------------
   Seletor de perfis (cards clicaveis) -- usado em users/create.php e users/edit.php
   --------------------------------------------------------------------------- */
.role-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.role-option {
    position: relative;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 14px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.role-option:hover { border-color: var(--color-primary); box-shadow: var(--shadow-sm); }
.role-option:has(input:checked) { border-color: var(--color-primary); background: var(--color-primary-light); }

.role-option input[type="checkbox"] {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 16px;
    height: 16px;
}

.role-option-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--color-text-muted);
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.role-option:has(input:checked) .role-option-icon { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.role-option-title { display: block; font-weight: 600; font-size: 0.8125rem; padding-right: 20px; }
.role-option-desc { display: block; font-size: 0.75rem; color: var(--color-text-muted); margin-top: 3px; line-height: 1.4; padding-right: 20px; }

/* ---------------------------------------------------------------------------
   Campos com icone a esquerda
   --------------------------------------------------------------------------- */
.input-icon { position: relative; }

.input-icon .icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    pointer-events: none;
}

.input-icon input { padding-left: 38px; }

/* ---------------------------------------------------------------------------
   Secoes de formulario (varios cards empilhados formando um unico fluxo)
   --------------------------------------------------------------------------- */
.form-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-section-title .icon { color: var(--color-primary); }

.form-sections { display: flex; flex-direction: column; gap: 16px; }

/* ---------------------------------------------------------------------------
   Botoes
   --------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.5;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.15s, background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 0.25rem var(--color-primary-ring); }

.btn-block { width: 100%; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.8125rem; }

.btn-primary { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); color: #fff; }

.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { background: var(--color-hover-bg); border-color: var(--color-disabled); color: var(--color-text); }

.btn-danger { background: var(--color-danger); border-color: var(--color-danger); color: #fff; }
.btn-danger:hover { background: var(--color-danger-dark); border-color: var(--color-danger-dark); color: #fff; }

.btn-ghost { background: transparent; color: var(--color-text-muted); }
.btn-ghost:hover { background: var(--color-hover-bg); }

/* ---------------------------------------------------------------------------
   Alertas / flash messages
   --------------------------------------------------------------------------- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.alert-success { background: var(--color-success-light); color: var(--color-success-text); border-color: var(--color-success-border); }
.alert-error { background: var(--color-danger-light); color: var(--color-danger-text); border-color: var(--color-danger-border); }
.alert-warning { background: var(--color-warning-light); color: var(--color-warning-text); border-color: var(--color-warning-border); }
.alert-info { background: var(--color-info-light); color: var(--color-info-text); border-color: var(--color-info-border); }

/* ---------------------------------------------------------------------------
   Badges (status)
   --------------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.35em 0.65em;
    border-radius: var(--radius-sm);
    font-size: 0.75em;
    font-weight: 700;
    line-height: 1;
}

.badge-active { background: var(--color-success); color: #fff; }
.badge-inactive { background: var(--color-badge-inactive-bg); color: var(--color-badge-inactive-text); }
.badge-blocked { background: var(--color-danger); color: #fff; }
.badge-pending { background: var(--color-warning); color: #1f2d3d; }

/* ---------------------------------------------------------------------------
   Tabelas
   --------------------------------------------------------------------------- */
.table-responsive { overflow-x: auto; }

table.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table th, .table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
    vertical-align: middle;
}

.table thead th {
    color: var(--color-text);
    font-weight: 600;
    border-bottom-width: 2px;
}

.table tbody tr:hover { background: rgba(0, 0, 0, 0.03); }
:root[data-theme="dark"] .table tbody tr:hover { background: rgba(255, 255, 255, 0.05); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .table tbody tr:hover { background: rgba(255, 255, 255, 0.05); }
}

.table-actions { display: flex; gap: 6px; }

.empty-state {
    text-align: center;
    padding: 48px 16px;
    color: var(--color-text-muted);
}

.empty-state .icon-lg { display: block; margin: 0 auto 10px; color: var(--color-border); }

/* ---------------------------------------------------------------------------
   Paginacao / filtros
   --------------------------------------------------------------------------- */
.filters-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.filters-bar input, .filters-bar select { width: auto; min-width: 160px; }

.pagination {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
    padding: 14px 20px;
    border-top: 1px solid var(--color-border);
}

.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    color: var(--color-text);
}

.pagination a:hover { background: var(--color-hover-bg); text-decoration: none; }
.pagination .current { background: var(--color-primary); color: #fff; font-weight: 700; }
.pagination .disabled { color: var(--color-disabled); }

/* ---------------------------------------------------------------------------
   Paginas de erro (403/404/419/429/500)
   --------------------------------------------------------------------------- */
.error-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
}

.error-page .code {
    font-size: 4rem;
    font-weight: 800;
    color: var(--color-primary);
    margin-bottom: 4px;
}

.error-page p { color: var(--color-text-muted); max-width: 420px; margin: 0 auto 24px; }

.error-debug {
    text-align: left;
    max-width: 640px;
    margin: 0 auto;
    background: #111827;
    color: #f3f4f6;
    padding: 16px;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    overflow-x: auto;
    white-space: pre-wrap;
}

/* ---------------------------------------------------------------------------
   Utilitarios
   --------------------------------------------------------------------------- */
.text-muted { color: var(--color-text-muted); }
.text-center { text-align: center; }
.text-sm { font-size: 0.8125rem; }
.text-right { text-align: right; }
.fw-600 { font-weight: 600; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.d-flex { display: flex; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.m-0 { margin: 0; }
.mt-2 { margin-top: 2px; }
.mt-4 { margin-top: 4px; }
.mt-6 { margin-top: 6px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-10 { margin-bottom: 10px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.shortcut-icon-lg { width: 44px; height: 44px; }

.role-card-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.role-card { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.role-card .shortcut-title { font-size: 0.9375rem; }
.role-card .shortcut-desc { margin-top: 4px; }

/* ---------------------------------------------------------------------------
   Responsividade
   --------------------------------------------------------------------------- */
@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 240px;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 100;
    }
    .sidebar.is-open { transform: translateX(0); }
    .content { padding: 16px; }
    .topbar { padding: 12px 16px; }
}

/* ---------------------------------------------------------------------------
   Editor de templates de e-mail (/admin/email-templates)
   --------------------------------------------------------------------------- */
.email-editor-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
    gap: 20px;
    align-items: start;
}
.email-editor-main { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.email-editor-main #template-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}
.email-editor-side {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: sticky;
    top: 16px;
}

/* Segmented control das abas Corpo / HTML completo */
.editor-tabs {
    display: inline-flex;
    padding: 3px;
    gap: 3px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}
.editor-tab {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border: 0;
    background: transparent;
    color: var(--color-text-muted);
    border-radius: 4px;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.editor-tab:hover { color: var(--color-text); }
.editor-tab.is-active {
    background: var(--color-surface);
    color: var(--color-primary-text);
    box-shadow: var(--shadow-sm);
}

.editor-panel { margin-top: 4px; }
.editor-panel > label { color: var(--color-text-muted); }

.code-area {
    width: 100%;
    min-height: 340px;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8125rem;
    line-height: 1.6;
    tab-size: 2;
    white-space: pre;
    overflow-wrap: normal;
    overflow: auto;
}
.editor-panel[data-panel="body"] .code-area { min-height: 260px; }

.var-chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.var-chip {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    color: var(--color-text);
    border-radius: 999px;
    padding: 4px 10px;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.4;
    transition: border-color 0.12s, background 0.12s;
}
.var-chip:hover { border-color: var(--color-primary); background: var(--color-primary-light); }
.var-chip code {
    background: none;
    padding: 0;
    font-size: 0.75rem;
    color: var(--color-primary-text);
}

.email-preview-shell {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #ffffff;
}
.email-preview-frame {
    display: block;
    width: 100%;
    height: 520px;
    border: 0;
    background: #ffffff;
}

@media (max-width: 1080px) {
    .email-editor-grid { grid-template-columns: 1fr; }
    .email-editor-side { position: static; }
    .email-preview-frame { height: 420px; }
}

/* ---------------------------------------------------------------------------
   Detalhe de permissao (/permissions/{slug})
   --------------------------------------------------------------------------- */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}
.detail-grid > div { display: flex; flex-direction: column; gap: 3px; }
.detail-grid .detail-wide { grid-column: 1 / -1; }
.detail-label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-muted);
}

/* Chips de "como recebeu / o que foi anulado" na tabela de usuarios. */
.origin-tags { flex-wrap: wrap; }
.origin-tags .badge { font-weight: 600; text-transform: none; letter-spacing: 0; }

.super-admin-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px 16px;
    margin-top: 12px;
}

.stack-product { display: flex; align-items: center; gap: 10px; }
.stack-product .aff-thumb { flex-shrink: 0; }

/* ---------------------------------------------------------------------------
   Tabelas responsivas: em telas estreitas, cada linha de .table-stack vira
   um card; o rotulo de cada celula vem de data-label.
   --------------------------------------------------------------------------- */
@media (max-width: 760px) {
    .table-stack thead { display: none; }
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; box-sizing: border-box; }
    .table-stack tr {
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        margin: 0 0 12px;
        padding: 6px 12px;
        background: var(--color-surface);
    }
    .table-stack td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        padding: 7px 0;
        border: 0;
        border-bottom: 1px solid var(--color-border);
        text-align: right;
        white-space: normal;
        min-width: 0;
        max-width: none;
    }
    .table-stack td:last-child { border-bottom: 0; }
    .table-stack td[data-label]::before {
        content: attr(data-label);
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--color-text-muted);
        text-align: left;
        flex-shrink: 0;
    }
    /* Celulas "cabecalho" do card (produto, imagem) e estados vazios ocupam a largura toda */
    .table-stack td.stack-full, .table-stack td:not([data-label]) { display: block; text-align: left; }
    .table-responsive:has(.table-stack) { overflow-x: visible; padding: 0 12px; }
    .table-stack .row-actions, .table-stack .row-actions-trigger { width: 100%; }
    .table-stack .row-actions-trigger { justify-content: center; }
    .filters-bar input, .filters-bar select { flex: 1 1 100%; min-width: 0; }
    .page-header-actions { width: 100%; }
    .page-header-actions .btn { flex: 1 1 auto; justify-content: center; }
}

/* Aviso rapido (ex.: "Link copiado") */
.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%) translateY(20px);
    background: #212529;
    color: #fff;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.2));
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 1000;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.dropdown-item[aria-disabled="true"] { color: var(--color-text-muted); cursor: default; }
.dropdown-item[aria-disabled="true"]:hover { background: none; }

.auth-logo-img { display: block; width: 56px; height: 56px; background: none; }
