/**
 * R3 Admin — Tabler dark custom (preto/cinza, sem acentos coloridos).
 * Carregar depois de tabler.min.css
 */
:root,
[data-bs-theme="dark"] {
    --r3-bg: #0a0a0a;
    --r3-surface: #141414;
    --r3-surface-2: #1a1a1a;
    --r3-border: #2e2e2e;
    --r3-text: #ececec;
    --r3-muted: #9a9a9a;
    --r3-sidebar-width: 15.5rem;
    --r3-sidebar-width-narrow: 4.5rem;
    --r3-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --tblr-body-bg: var(--r3-bg);
    --tblr-bg-surface: var(--r3-surface);
    --tblr-bg-surface-secondary: var(--r3-surface-2);
    --tblr-border-color: var(--r3-border);
    --tblr-body-color: var(--r3-text);
    --tblr-secondary: var(--r3-muted);
    --tblr-primary: #c4c4c4;
    --tblr-primary-rgb: 196, 196, 196;
    --tblr-link-color: #d0d0d0;
    --tblr-link-hover-color: #ffffff;
}

body.theme-dark {
    background: var(--r3-bg);
    /* Tabler: .page-wrapper usa margin-inline-start = var(--tblr-sidebar-width) */
    --tblr-sidebar-width: var(--r3-sidebar-width);
}

body.theme-dark.r3-sidebar-narrow {
    --tblr-sidebar-width: var(--r3-sidebar-width-narrow);
}

/* —— Sidebar —— */
.navbar-vertical.navbar-dark.r3-sidebar {
    background: var(--r3-surface);
    border-right: 1px solid var(--r3-border);
    width: var(--tblr-sidebar-width);
    transition: width 0.28s var(--r3-ease);
}

.r3-sidebar-inner {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-top: 0.25rem;
    padding-bottom: 0.75rem;
}

.r3-sidebar-head {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.65rem 0.5rem 0.75rem;
    margin-bottom: 0.25rem;
}

.r3-brand-link {
    display: block;
    flex: 1;
    min-width: 0;
    line-height: 0;
}

.r3-brand-logo {
    height: 26px;
    width: auto;
    max-width: 9.5rem;
    display: block;
    object-fit: contain;
}

.r3-brand-logo--mark {
    max-width: 2.25rem;
    margin-inline: auto;
}

.r3-brand-logo--guest {
    height: 32px;
    max-width: 11rem;
    margin-inline: auto;
}

.r3-sidebar-toggle {
    flex-shrink: 0;
    opacity: 0.85;
    transition: opacity 0.15s var(--r3-ease), transform 0.15s var(--r3-ease);
}

.r3-sidebar-toggle:hover {
    opacity: 1;
    transform: scale(1.05);
}

.r3-sidebar-user {
    padding: 0 0.35rem 0.85rem;
    margin-bottom: 0.35rem;
    border-bottom: 1px solid var(--r3-border);
}

.r3-sidebar-user-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.5rem;
    border-radius: 0.375rem;
    transition: background-color 0.18s var(--r3-ease);
}

.r3-sidebar-user-link:hover {
    background: var(--r3-surface-2);
}

.r3-sidebar-user-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.2;
}

.r3-sidebar-user-text {
    min-width: 0;
    flex: 1;
}

.r3-sidebar-nav {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.r3-nav-list {
    flex: 1;
    padding-top: 0.35rem;
    gap: 0.15rem;
}

.r3-nav-list .nav-link {
    padding: 0.5rem 0.65rem;
    margin: 0 0.2rem;
    border-radius: 0.375rem;
    transition: background-color 0.18s var(--r3-ease), color 0.15s ease;
}

.r3-nav-list .nav-link:hover {
    background: var(--r3-surface-2);
}

.r3-nav-list .nav-link.active {
    background: var(--r3-surface-2);
}

.r3-nav-section {
    margin-top: 0.85rem;
    margin-bottom: 0.15rem;
}

.r3-nav-section:first-child {
    margin-top: 0;
}

.r3-nav-section .nav-link {
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
}

.r3-sidebar-foot {
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid var(--r3-border);
}

.r3-sidebar-foot .nav-link {
    padding: 0.55rem 0.65rem;
    margin: 0 0.2rem;
    border-radius: 0.375rem;
}

/* Sidebar recolhida (largura via --tblr-sidebar-width no body) */
.r3-sidebar-narrow .navbar-brand-image-wide,
.r3-sidebar-narrow .nav-link-title,
.r3-sidebar-narrow .nav-link.disabled,
.r3-sidebar-narrow .r3-sidebar-user-text {
    display: none !important;
}

.r3-sidebar-narrow .r3-sidebar-head {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
}

.r3-sidebar-narrow .r3-sidebar-toggle {
    margin-inline: auto;
}

.r3-sidebar-narrow .r3-sidebar-user-link {
    justify-content: center;
    padding: 0.5rem;
}

.r3-sidebar-narrow .navbar-vertical:not(.r3-force) .navbar-brand-image-compact {
    display: block !important;
}

.navbar-vertical:not(.r3-force) .navbar-brand-image-compact {
    display: none;
}

[x-cloak] {
    display: none !important;
}

.r3-bd-explorer-columns-scroll {
    max-height: 16rem;
    overflow-y: auto;
}

/* Atualizações — card “tip” GitHub (lista longa de arquivos) */
.r3-updates-recent-tip {
    max-height: min(32rem, 72vh);
}

.r3-updates-recent-tip-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-inline-end: 0.15rem;
}

.r3-updates-compare-migration {
    background: rgba(var(--tblr-yellow-rgb, 247, 191, 71), 0.12);
}

.r3-updates-compare-migration code {
    color: var(--tblr-yellow, #f59f00);
}

/* Atualizações — colunas PROD/HML (Ambientes) */
.r3-updates-env-column {
    min-height: min(38rem, 78vh);
    max-height: min(42rem, 82vh);
}

.r3-updates-env-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-inline-end: 0.15rem;
}

.r3-deploy-log-view {
    display: block;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    min-height: 12rem;
    max-height: min(36rem, 62vh);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--tblr-bg-surface-secondary, rgba(0, 0, 0, 0.15));
    font-family: var(--tblr-font-monospace, ui-monospace, monospace);
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

.r3-updates-env-actions {
    flex-shrink: 0;
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid var(--tblr-border-color, rgba(255, 255, 255, 0.08));
}

/* Diálogos nativos (<dialog>) — fora do stacking do layout Tabler/Bootstrap */
.r3-native-dialog {
    border: none;
    padding: 0;
    margin: auto;
    max-width: min(32rem, 94vw);
    width: 100%;
    background: transparent;
    color: inherit;
}

.r3-native-dialog.r3-native-dialog-lg {
    max-width: min(48rem, 96vw);
}

.r3-native-dialog.r3-native-dialog-lg .r3-native-dialog-panel {
    max-height: min(92vh, 44rem);
    display: flex;
    flex-direction: column;
}

.r3-native-dialog-lg .r3-native-dialog-body--scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.r3-native-dialog-lg .r3-native-dialog-body--scroll .r3-deploy-log-view {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
}

.r3-native-dialog::backdrop {
    background: rgba(0, 0, 0, 0.62);
}

.r3-native-dialog-panel {
    background: var(--tblr-bg-surface, #1a1d24);
    border: 1px solid var(--tblr-border-color, rgba(255, 255, 255, 0.08));
    border-radius: var(--tblr-border-radius-lg, 0.5rem);
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.45);
    overflow: hidden;
}

.r3-native-dialog-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--tblr-border-color, rgba(255, 255, 255, 0.08));
}

.r3-native-dialog-body {
    padding: 1rem 1.25rem;
}

.r3-native-dialog-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--tblr-border-color, rgba(255, 255, 255, 0.08));
}

.r3-native-dialog-fallback-open {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.62);
}

/* —— Página principal —— */
.page .page-wrapper {
    background: var(--r3-bg);
    transition: margin-inline-start 0.28s var(--r3-ease);
}

.page-header {
    border-bottom: 1px solid var(--r3-border);
    background: var(--r3-surface);
    padding-top: 1.1rem;
    padding-bottom: 1.1rem;
}

.r3-page-header-inner {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.r3-page-header-inner .page-title {
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.r3-page-lede {
    font-size: 0.9rem;
    line-height: 1.45;
    max-width: 42rem;
}

.r3-page-body {
    padding-top: 1.25rem;
}

.r3-page-content {
    animation: r3-content-in 0.35s var(--r3-ease) both;
}

.r3-page-content .alert {
    margin-bottom: 1rem;
}

.r3-page-content .row-cards {
    --tblr-gutter-y: 1.25rem;
}

@keyframes r3-content-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    background: var(--r3-surface);
    border-color: var(--r3-border);
    box-shadow: none;
    transition: border-color 0.2s var(--r3-ease), transform 0.2s var(--r3-ease);
}

.card:hover {
    border-color: #3a3a3a;
}

.btn {
    transition: background-color 0.15s var(--r3-ease), border-color 0.15s var(--r3-ease), transform 0.12s var(--r3-ease);
}

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-primary {
    --tblr-btn-bg: #3a3a3a;
    --tblr-btn-border-color: #4a4a4a;
    --tblr-btn-hover-bg: #4a4a4a;
    --tblr-btn-hover-border-color: #5a5a5a;
    color: var(--r3-text);
}

.btn-outline-primary {
    --tblr-btn-color: var(--r3-text);
    --tblr-btn-border-color: var(--r3-border);
}

.alert-success {
    background: #1a1f1a;
    border-color: #2a352a;
    color: #b8c4b8;
}

.alert-danger,
.alert-error {
    background: #1f1a1a;
    border-color: #352a2a;
    color: #c4b8b8;
}

.r3-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    object-fit: cover;
    background: var(--r3-surface-2);
    color: var(--r3-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.r3-avatar--sidebar {
    width: 2.25rem;
    height: 2.25rem;
    font-size: 0.8rem;
}

.r3-settings-category {
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.15s var(--r3-ease);
}

.r3-settings-category.active,
.r3-settings-category:hover {
    border-color: #5a5a5a;
}

.r3-settings-category:hover {
    transform: translateY(-1px);
}

.r3-bd-tab.active {
    border-bottom: 2px solid #888;
}

.nav-tabs .nav-link {
    transition: color 0.15s ease, border-color 0.2s var(--r3-ease);
}

@media (prefers-reduced-motion: reduce) {
    .navbar-vertical.r3-sidebar,
    .page .page-wrapper,
    .r3-page-content,
    .card,
    .btn,
    .nav-link,
    .r3-sidebar-toggle {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
}
