/* ══════════════════════════════════════════
   PAINEL DO ADMINISTRADOR
   Reaproveita tokens e o layout base de style.css.
   Classes próprias para não colidir com outras páginas.
   ══════════════════════════════════════════ */

/* ── Cabeçalho da página (mesmo padrão das outras áreas) ── */
.page-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
}

.page-header-bar .page-title-group {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.page-header-bar .page-icon {
    font-size: 2.2rem;
}

.title-text-col {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.page-header-bar h1 {
    font-family: var(--font-heading);
    font-size: clamp(1.4rem, 3vw, 1.8rem);
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.1;
    margin: 0;
}

.page-header-bar .page-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 2px;
    line-height: 1.2;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.4rem;
    background: linear-gradient(135deg, var(--accent-blue), #2a7bd4);
    color: #fff;
    border: none;
    border-radius: var(--radius-lg);
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    white-space: nowrap;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-blue-glow);
}

/* ── Cartões de resumo ── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.stat-card .stat-icon {
    font-size: 1.3rem;
}

.stat-card .stat-value {
    font-family: var(--font-heading);
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.stat-card .stat-label {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ── Lista vazia ── */
.lista-vazia {
    text-align: center;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2.5rem 1rem;
    margin-top: 1rem;
}

/* ── Botões de ação (usados nos cartões mobile) ── */
.act-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.act-btn:hover {
    background: var(--bg-hover);
    transform: translateY(-1px);
}

/* ── Toolbar ── */
.toolbar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 1.2rem;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.55rem 0.8rem;
    flex: 1;
    min-width: 220px;
}

.search-box .search-icon {
    opacity: 0.7;
}

.search-box input {
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: var(--text-base);
    width: 100%;
}

.filter-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    padding: 0.55rem 0.9rem;
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent-blue);
}

.filter-btn.active {
    background: var(--accent-blue-glow);
    color: var(--accent-blue);
    border-color: var(--accent-blue);
}

/* ── Tabela de usuários ── */
.table-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table thead th {
    text-align: left;
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 600;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.admin-table tbody td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: var(--text-base);
    vertical-align: middle;
}

.admin-table tbody tr:last-child td {
    border-bottom: none;
}

.admin-table tbody tr:hover {
    background: var(--bg-hover);
}

.cel-usuario {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.mini-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-circle);
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.78rem;
    color: #fff;
    flex-shrink: 0;
}

.cel-usuario .u-nome {
    font-weight: 600;
}

.cel-usuario .u-email {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.voce-tag {
    font-size: 0.62rem;
    background: var(--accent-blue-glow);
    color: var(--accent-blue);
    padding: 0.05rem 0.4rem;
    border-radius: var(--radius-pill);
    margin-left: 0.35rem;
    vertical-align: middle;
    font-weight: 700;
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: var(--text-xs);
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-pill);
    white-space: nowrap;
}

.badge-tipo-admin    { background: rgba(142, 45, 226, 0.16); color: #b98cff; }
.badge-tipo-advogado { background: rgba(61, 155, 233, 0.16); color: var(--accent-blue); }
.badge-tipo-assistente { background: var(--bg-tertiary); color: var(--text-secondary); }

.badge-status-ativo    { background: rgba(13, 178, 107, 0.16); color: var(--accent-green); }
.badge-status-suspenso { background: rgba(255, 59, 48, 0.16); color: var(--accent-red); }

.badge-master { background: rgba(255, 149, 0, 0.16); color: var(--accent-orange); }

.master-lock {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-style: italic;
    padding: 0.2rem 0.4rem;
}

.resumo-acesso {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.resumo-acesso.total {
    color: #b98cff;
    font-weight: 600;
}

/* ── Menu de ações na linha ── */
.row-actions {
    display: flex;
    gap: 0.35rem;
    justify-content: flex-end;
}

.icon-btn {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.95rem;
    transition: all var(--transition-fast);
}

.icon-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent-blue);
    background: var(--bg-hover);
}

.icon-btn.perigo:hover {
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.icon-btn.ok:hover {
    border-color: var(--accent-green);
    color: var(--accent-green);
}

/* ── Linha da senha no drawer (input + gerar) ── */
.senha-row {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.senha-row input {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.6rem 0.8rem;
    color: var(--text-primary);
    font-size: var(--text-base);
    font-family: var(--font-mono);
    outline: none;
}

.senha-row input:focus {
    border-color: var(--accent-blue);
}

.senha-row .mini-btn {
    white-space: nowrap;
}

/* ── Cartões mobile ── */
.mobile-cards {
    display: none;
    flex-direction: column;
    gap: 0.8rem;
}

.user-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.user-card-top {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.user-card-badges {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.user-card-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

/* ══════════════════════════════════════════
   DRAWER — editor de acesso / permissões
   ══════════════════════════════════════════ */
.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
    z-index: var(--z-overlay);
}

.drawer-overlay.active {
    opacity: 1;
    visibility: visible;
}

.acesso-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    width: min(520px, 100%);
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    box-shadow: -8px 0 40px var(--shadow);
    transform: translateX(100%);
    transition: transform var(--transition-smooth);
    z-index: var(--z-modal);
    display: flex;
    flex-direction: column;
}

.acesso-drawer.active {
    transform: translateX(0);
}

.drawer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.2rem 1.3rem;
    border-bottom: 1px solid var(--border-color);
}

.drawer-header h2 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    color: var(--text-primary);
}

.drawer-close {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.9rem;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.drawer-close:hover {
    color: var(--text-primary);
    border-color: var(--accent-red);
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.3rem;
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
}

.form-section {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.form-section-title {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-group label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.form-group input,
.form-section select {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.6rem 0.8rem;
    color: var(--text-primary);
    font-size: var(--text-base);
    font-family: var(--font-body);
    outline: none;
    transition: border-color var(--transition-fast);
    width: 100%;
}

.form-group input:focus,
.form-section select:focus {
    border-color: var(--accent-blue);
}

.tipo-hint {
    font-size: var(--text-xs);
    color: var(--text-muted);
    line-height: 1.4;
    margin: 0;
}

.perm-atalhos {
    display: flex;
    gap: 0.4rem;
}

.mini-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: var(--text-xs);
    font-weight: 600;
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.mini-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent-blue);
}

/* ── Matriz de permissões ── */
.perm-matrix-wrap {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.perm-matrix {
    width: 100%;
    border-collapse: collapse;
}

.perm-matrix thead th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: 600;
    padding: 0.6rem 0.4rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.perm-matrix thead th:first-child {
    text-align: left;
    padding-left: 0.8rem;
}

.perm-matrix tbody td {
    padding: 0.55rem 0.4rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.perm-matrix tbody tr:last-child td {
    border-bottom: none;
}

.perm-matrix tbody td:first-child {
    text-align: left;
    padding-left: 0.8rem;
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: 500;
    white-space: nowrap;
}

.perm-area-icon {
    margin-right: 0.4rem;
}

.perm-matrix input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-blue);
    cursor: pointer;
}

.perm-matrix.bloqueada {
    opacity: 0.45;
    pointer-events: none;
}

.perm-nota {
    font-size: var(--text-xs);
    color: var(--text-muted);
    line-height: 1.4;
    margin: 0;
}

.perm-nota strong {
    color: var(--text-secondary);
}

/* ── Rodapé do drawer ── */
.drawer-footer {
    display: flex;
    gap: 0.6rem;
    padding: 1rem 1.3rem;
    border-top: 1px solid var(--border-color);
}

.btn-cancel {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.7rem;
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-cancel:hover {
    color: var(--text-primary);
}

.btn-save {
    flex: 2;
    background: linear-gradient(135deg, var(--accent-green), #0a8f56);
    border: none;
    color: #fff;
    padding: 0.7rem;
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-size: var(--text-base);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-save:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(13, 178, 107, 0.3);
}

/* ══════════════════════════════════════════
   RESPONSIVO (auditado a 390px)
   ══════════════════════════════════════════ */
@media (max-width: 900px) {
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 720px) {
    .table-container {
        display: none;
    }

    .mobile-cards {
        display: flex;
    }
}

@media (max-width: 480px) {
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
    }

    .stat-card .stat-value {
        font-size: 1.5rem;
    }

    .page-header-bar .btn-primary {
        width: 100%;
        justify-content: center;
    }
}

/* ── Cópia de segurança ──────────────────────────────────────────────────────
   Classe própria (.btn-backup) em vez de .btn-primary: cada página redefine os
   botões genéricos com valores diferentes, então reaproveitar aqui deixaria o
   botão à mercê de um ajuste feito em outra tela. */
.backup-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-lg);
    flex-wrap: wrap;
    margin-top: var(--space-xl);
    padding: var(--space-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
}

.backup-texto {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    min-width: 0;            /* deixa o texto quebrar em vez de esticar o cartão */
    flex: 1 1 320px;
}

.backup-icone {
    font-size: var(--text-2xl);
    line-height: 1;
    flex-shrink: 0;
}

.backup-titulo {
    margin: 0 0 var(--space-xs);
    font-family: var(--font-heading);
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--text-primary);
}

.backup-desc {
    margin: 0;
    font-size: var(--text-sm);
    line-height: 1.5;
    color: var(--text-secondary);
}

.backup-desc code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    padding: 0.1em 0.35em;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.backup-aviso {
    margin: var(--space-sm) 0 0;
    font-size: var(--text-xs);
    line-height: 1.5;
    color: var(--text-muted);
}

.btn-backup {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 0.7rem 1.4rem;
    background: linear-gradient(135deg, var(--accent-green), #0a8f56);
    color: #fff;
    border: none;
    border-radius: var(--radius-lg);
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    white-space: nowrap;
}

.btn-backup:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(13, 178, 107, 0.25);
}

.btn-backup:disabled {
    opacity: 0.6;
    cursor: progress;
    transform: none;
    box-shadow: none;
}

/* A 390px o cartão vira coluna e o botão ocupa a largura toda — alvo de toque
   confortável, mesmo padrão das outras telas. */
@media (max-width: 600px) {
    .backup-card {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-backup {
        justify-content: center;
        width: 100%;
    }
}
