/* ==========================================================================
   CSS CUSTOMIZADO - TEMA DARK XUI (XUI FINANCE)
   Salvar em: /css/style.css
   ========================================================================== */

/* 1. Customização da Scrollbar (Barra de Rolagem) para se misturar ao Tema Dark */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #09090b; /* bg-darkBg (Zinco 950) */
}

::-webkit-scrollbar-thumb {
    background: #27272a; /* Zinco 800 */
    border-radius: 9999px;
    border: 1px solid #09090b;
}

::-webkit-scrollbar-thumb:hover {
    background: #3f3f46; /* Zinco 700 */
}

/* 2. Reset e Comportamento de Rolagem Fluida */
html {
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent; /* Remove o flash azul ao clicar no mobile */
    box-sizing: border-box;
}

*, *:before, *:after {
    box-sizing: inherit;
}

body {
    background-color: #09090b;
    color: #f4f4f5;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    padding: 0;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: #09090b;
    color: #f4f4f5;
    font-family: sans-serif;
}

.app-main {
    flex: 1;
    padding: 5rem 1rem 5.5rem;
}

.page-wrap {
    max-width: 72rem;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.page-wrap--wide {
    max-width: 80rem;
}

.page-wrap--compact {
    max-width: 36rem;
}

.page-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.page-header--inline {
    align-items: flex-start;
    justify-content: space-between;
}

/* MODIFICADO: Adaptação automática para 5 colunas caso o botão "Menu" esteja presente */
.mobile-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr)); /* Atualizado nativamente para 5 colunas */
    height: 4rem;
    padding: 0 0.5rem;
    background: rgba(24, 24, 27, 0.95);
    border-top: 1px solid #27272a;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.modal-shell {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.8);
}

.modal-card {
    width: 100%;
    max-width: 32rem;
    padding: 1.5rem;
    border: 1px solid #27272a;
    border-radius: 1rem;
    background: #18181b;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 28rem;
    padding: 2rem;
    border: 1px solid #27272a;
    border-radius: 1rem;
    background: #18181b;
}

.admin-shell {
    min-height: 100vh;
    padding: 1rem;
}

.admin-wrap {
    max-width: 64rem;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.admin-wrap--wide {
    max-width: 80rem;
}

.toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.surface-card {
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 1rem;
}

.surface-card--pad {
    padding: 1rem;
}

.metric-grid-3,
.metric-grid-4 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.metric-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 1rem;
}

.metric-card-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.875rem;
}

.table-panel {
    padding: 1rem;
}

.table-compact th,
.table-compact td {
    white-space: nowrap;
}

.table-stack td[data-label]::before {
    content: attr(data-label);
    color: #71717a;
    font-size: 0.675rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.db-error-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: #09090b;
}

.db-error-card {
    width: 100%;
    max-width: 32rem;
    padding: 1.25rem;
    border: 1px solid #3f3f46;
    border-radius: 0.75rem;
    background: #18181b;
    color: #ef4444;
    text-align: center;
    font-family: sans-serif;
}

.db-error-copy {
    color: #a1a1aa;
}

/* 3. Ajuste Estrutural Master para a Sidebar Fixa (Desktop) */
@media (min-width: 768px) {
    body {
        display: flex;
        flex-direction: row;
    }
    
    /* Empurra o conteúdo do main para a direita, deixando espaço para a sidebar (16rem / w-64) */
    main {
        flex: 1;
        margin-left: 16rem;
        min-height: 100vh;
    }

    .app-main {
        padding: 5rem 1.5rem 2rem;
    }

    .page-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .auth-shell {
        padding: 1.5rem;
    }

    .admin-shell {
        padding: 3rem;
    }

    .form-grid-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .metric-grid-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .metric-grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .metric-grid-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .app-main {
        padding: 4.5rem 0.75rem 5rem;
    }

    .page-wrap,
    .admin-wrap {
        gap: 1rem;
    }

    .mobile-tabbar {
        height: 3.75rem;
        padding: 0 0.25rem;
    }

    .mobile-tabbar span {
        font-size: 9px;
    }

    .modal-card,
    .auth-card,
    .db-error-card {
        padding: 1rem;
        border-radius: 0.875rem;
    }

    .admin-shell,
    .auth-shell {
        padding: 0.75rem;
    }

    .surface-card--pad,
    .table-panel,
    .metric-card {
        padding: 0.875rem;
    }

    .metric-card-row {
        padding: 0.75rem;
    }

    .table-stack thead {
        display: none;
    }

    .table-stack,
    .table-stack tbody,
    .table-stack tr,
    .table-stack td {
        display: block;
        width: 100%;
    }

    .table-stack-body {
        display: flex !important;
        flex-direction: column;
        gap: 0.75rem;
    }

    .table-stack-body tr {
        padding: 0.875rem;
        border: 1px solid #27272a;
        border-radius: 1rem;
        background: rgba(24, 24, 27, 0.92);
    }

    .table-stack-body td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 0.75rem;
        padding: 0.35rem 0;
        white-space: normal;
        text-align: right;
    }

    .table-stack-body td[data-label]::before {
        flex: 0 0 42%;
        text-align: left;
    }

    .table-stack-body td[data-label] > *:first-child {
        margin-left: auto;
    }

    .table-stack-body td[colspan] {
        display: block;
        padding: 0;
        text-align: center;
    }

    .table-stack-body td[colspan]::before {
        content: none;
    }

    .table-stack-cell-start,
    .table-stack-cell-start > * {
        text-align: left;
    }

    .table-stack-cell-actions {
        align-items: stretch;
        text-align: left;
    }

    .table-stack-cell-actions > div {
        justify-content: flex-start;
        flex-wrap: wrap;
        width: 100%;
    }
}

/* 4. Efeitos de Transição Globais para Elementos Interativos (Cards e Botões) */
.transition-all-custom {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 5. Estilização para Inputs e Textareas no Foco (XUI Glow Effect) */
input:focus, 
select:focus, 
textarea:focus {
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2); /* Sombra suave Indigo */
    border-color: #6366f1 !important;
    outline: none;
}

/* 6. Correção de visualização para inputs de data no Chrome/Safari Dark */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1); /* Deixa o ícone de calendário branco */
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* 7. Efeito de Desfoque de Vidro (Glassmorphism) para Header Fixo e Navegação Mobile */
.backdrop-blur-md {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* 8. Melhoria na legibilidade de Tabelas Longas no Mobile */
.overflow-x-auto {
    mask-image: linear-gradient(to right, black 95%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black 95%, transparent 100%);
}

/* 9. Animação suave para abertura do Sidebar Mobile */
#sidebar {
    will-change: transform;
}

.hidden {
    display: none !important;
}

/* 10. Utilitário de Acessibilidade */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}