/**
 * CSS Customizado - Sistema de Métricas
 * Estilos compartilhados para todas as páginas do sistema
 */

/* ========== SELEÇÃO DE TEXTO ========== */
::selection {
    background-color: #f8a0a0;
    color: #000;
}

/* ========== PRELOADER ========== */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

[data-bs-theme="dark"] #preloader {
    background-color: #1a1a1a;
}

#preloader.fade-out {
    opacity: 0;
    visibility: hidden;
}

.preloader-content {
    text-align: center;
    min-width: 280px;
}

.preloader-spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 4px solid rgba(102, 126, 234, 0.1);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

[data-bs-theme="dark"] .preloader-spinner {
    border: 4px solid rgba(134, 160, 255, 0.1);
    border-top-color: #86a0ff;
}

.preloader-text {
    color: #667eea;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.5px;
    margin-bottom: 15px;
}

[data-bs-theme="dark"] .preloader-text {
    color: #86a0ff;
}

.preloader-progress {
    width: 100%;
    height: 4px;
    background-color: rgba(102, 126, 234, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

[data-bs-theme="dark"] .preloader-progress {
    background-color: rgba(134, 160, 255, 0.1);
}

.preloader-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
}

[data-bs-theme="dark"] .preloader-progress-bar {
    background: linear-gradient(90deg, #86a0ff 0%, #9575cd 100%);
}

.preloader-percentage {
    color: #667eea;
    font-size: 12px;
    font-weight: 600;
}

[data-bs-theme="dark"] .preloader-percentage {
    color: #86a0ff;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========== VARIÁVEIS E TEMAS ========== */
:root {
    color-scheme: light dark;
}

[data-bs-theme="dark"] {
    --tblr-bg-surface: #1a1a1a;
    --tblr-bg-surface-secondary: #252525;
    --tblr-border-color: #3a3a3a;
}

/* ========== LAYOUT GERAL ========== */
html, body {
    height: 100%;
}

body {
    background-color: var(--tblr-bg-surface-secondary);
    display: flex;
    flex-direction: column;
}

.navbar {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.wrapper {
    flex: 1;
    /* Tabler dá .page{min-height:100%}: o .page.wrapper ficava com a altura inteira do
       body + a navbar, e o body ganhava uma barra de rolagem que só movia o título. */
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.page {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.page-header {
    border-bottom: 1px solid var(--tblr-border-color);
}

.page-body {
    flex: 1;
   
}

.container-fluid {
    max-width: 100%;
}

.card {
    background-color: var(--tblr-bg-surface);
    border-color: var(--tblr-border-color);
}

/* ========== TABELAS ========== */
.table {
    color: var(--tblr-body-color);
}

/* Zebrado */
.table-vcenter tbody tr:nth-of-type(even) {
    background-color: rgba(102, 126, 234, 0.05);
}

[data-bs-theme="dark"] .table-vcenter tbody tr:nth-of-type(even) {
    background-color: rgba(102, 126, 234, 0.08);
}

/* Hover effect */
.table-vcenter tbody tr {
    transition: background-color 0.2s ease;
}

.table-vcenter tbody tr:hover {
    background-color: rgba(102, 126, 234, 0.12) !important;
}

[data-bs-theme="dark"] .table-vcenter tbody tr:hover {
    background-color: rgba(102, 126, 234, 0.2) !important;
}

.table-vcenter tbody tr td {
    border-top: 1px solid var(--tblr-border-color);
}

/* Divisores verticais */
.table thead th,
.table tbody td {
    border-right: 1px solid var(--tblr-border-color);
}

.table thead th:last-child,
.table tbody td:last-child {
    border-right: none;
}

[data-bs-theme="dark"] .table thead th,
[data-bs-theme="dark"] .table tbody td {
    border-right-color: rgba(255, 255, 255, 0.1);
}

/* ========== COLUNAS ORDENÁVEIS ========== */
.table thead th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 2rem;
}

.table thead th.sortable:hover {
    background-color: rgba(102, 126, 234, 0.1);
}

.table thead th.sortable::after {
    content: '⇅';
    position: absolute;
    right: 0.5rem;
    opacity: 0.3;
    font-size: 0.9rem;
}

.table thead th.sortable.asc::after {
    content: '▲';
    opacity: 1;
    color: var(--tblr-primary);
}

.table thead th.sortable.desc::after {
    content: '▼';
    opacity: 1;
    color: var(--tblr-primary);
}

/* ========== SCROLL E ELEMENTOS FIXOS ========== */
.table-responsive {
    max-height: calc(100vh - 300px);
    overflow-y: auto !important;
    overflow-x: auto;
}

/* Cabeçalho fixo */
.table-vcenter thead th {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 0 !important;
    background-color: #f8f9fa !important;
    border-bottom: 2px solid rgba(0, 0, 0, 0.1) !important;
    z-index: 1000 !important;
    font-weight: 600 !important;
    color: rgba(0, 0, 0, 0.7) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

[data-bs-theme="dark"] .table-vcenter thead th {
    background-color: #2a2a2a !important;
    color: rgba(255, 255, 255, 0.8) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;
}

/* Colunas da Meta - DEVE vir DEPOIS do cabeçalho fixo para sobrescrever */
.table-vcenter thead th.bg-meta-col {
    background-color: #d0dcfb !important;
}

[data-bs-theme="dark"] .table-vcenter thead th.bg-meta-col {
    background-color: #3a4a7a !important;
}

/* Colunas de Pedidos - fundo amarelo clarinho */
.table-vcenter thead th.bg-pedidos-col {
    background-color: #fff8dc !important;
}

[data-bs-theme="dark"] .table-vcenter thead th.bg-pedidos-col {
    background-color: #4a4420 !important;
}

/* Rodapé fixo */
.table tfoot {
    position: sticky;
    bottom: 0;
    z-index: 98;
}

.table tfoot tr {
    background-color: #ffffff !important;
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.05);
}

[data-bs-theme="dark"] .table tfoot tr {
    background-color: #1a1a1a !important;
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.3);
}

.table tfoot td {
    border-top: 2px solid rgba(0, 0, 0, 0.1) !important;
}

[data-bs-theme="dark"] .table tfoot td {
    border-top: 2px solid rgba(255, 255, 255, 0.1) !important;
}

.table-footer {
    background-color: #ffffff !important;
    border-top: 1px solid rgba(0, 0, 0, 0.1) !important;
    font-size: 0.85rem;
    color: rgba(0, 0, 0, 0.6);
    position: sticky;
    bottom: 0;
    z-index: 100;
    font-weight: 500;
}

[data-bs-theme="dark"] .table-footer {
    background-color: #1a1a1a !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: rgba(255, 255, 255, 0.7);
}

.table-footer td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
}

/* ========== UTILITÁRIOS ========== */
.text-center-col {
    text-align: center !important;
}

.input-icon {
    position: relative;
    width: 280px;
    min-width: 250px;
}

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

.input-icon .form-control {
    padding-left: 40px;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    font-weight: 500;
}

.input-icon .form-control:focus {
    border-color: var(--tblr-primary);
    box-shadow: 0 0 0 0.2rem rgba(86, 112, 234, 0.1);
}

[data-bs-theme="dark"] .input-icon .form-control {
    background-color: #2a2a2a;
    border-color: #3a3a3a;
    color: rgba(255, 255, 255, 0.8);
}

[data-bs-theme="dark"] .input-icon .form-control:focus {
    background-color: #2a2a2a;
    border-color: var(--tblr-primary);
}

/* ========== DATERANGEPICKER ========== */
.daterangepicker {
    border-radius: 0.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border: none;
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 9999 !important;
}

.daterangepicker.show {
    display: block !important;
}

/* ========== BOTÕES E DROPDOWNS ========== */
.btn-ghost-primary {
    color: var(--tblr-primary);
}

[data-bs-theme="dark"] .btn-ghost-primary {
    color: #86a0ff;
}

.dropdown-menu {
    min-width: 220px;
    padding: 0.5rem 0;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    border-radius: 0.5rem;
    border-color: var(--tblr-border-color);
    background-color: var(--tblr-bg-surface);
}

.dropdown-header {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.5rem 1rem;
    color: var(--tblr-muted);
}

.dropdown-item {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    color: var(--tblr-body-color);
}

.dropdown-item:hover {
    background-color: rgba(102, 126, 234, 0.08);
    transform: translateX(2px);
    color: var(--tblr-body-color);
}

.dropdown-divider {
    margin: 0.5rem 0;
    border-color: var(--tblr-border-color);
}

#dropdownPeriodo {
    font-weight: 500;
    white-space: nowrap;
}

.btn-primary.dropdown-toggle::after {
    margin-left: 0.5rem;
}

/* ========== ESTADOS VAZIOS ========== */
.empty {
    padding: 3rem 1rem;
    text-align: center;
}

.empty-header {
    font-size: 6rem;
    font-weight: 700;
    color: var(--tblr-border-color);
}

.empty-title {
    font-size: 1.5rem;
    margin-top: 1rem;
}

.empty-subtitle {
    margin-top: 0.5rem;
}

/* ========== GRID E CARDS ========== */
.row-deck {
    margin-bottom: -1rem;
}

.row-cards > [class*='col-'] {
    margin-bottom: 1rem;
}

.nav-link {
    color: var(--tblr-body-color);
}

/* ========== NOTIFICAÇÕES ========== */
#notificacoes-bell {
    overflow: visible !important;
}

.badge-notification {
    position: absolute !important;
    top: -2px;
    right: -14px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #fff !important;
    background: #d63939 !important;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    border: 2px solid var(--tblr-body-bg, #1a2234);
    animation: notif-pulse 2s ease-in-out infinite;
    z-index: 100;
    white-space: nowrap;
    letter-spacing: 0;
}

@keyframes notif-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.9; }
}

#notificacoes-dropdown .dropdown-item {
    transform: none !important;
}

#notificacoes-dropdown .notif-item {
    white-space: normal;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

#notificacoes-dropdown .notif-item:last-of-type {
    border-bottom: none;
}

#notificacoes-dropdown .notif-unread {
    background-color: rgba(32, 107, 196, 0.06);
    border-left: 3px solid var(--tblr-azure);
}

[data-bs-theme="dark"] #notificacoes-dropdown .notif-item {
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

[data-bs-theme="dark"] #notificacoes-dropdown .notif-unread {
    background-color: rgba(32, 107, 196, 0.12);
}

/* ========== DOUBLE-CLICK ROW HIGHLIGHT ========== */
.table tbody tr.row-highlighted,
.table-striped > tbody > tr.row-highlighted {
    --bs-table-striped-bg: #fff3cd;
    --bs-table-bg: #fff3cd;
    background-color: #fff3cd !important;
}

.table tbody tr.row-highlighted > td,
.table-striped > tbody > tr.row-highlighted > td {
    background-color: #fff3cd !important;
    box-shadow: none !important;
}

[data-bs-theme="dark"] .table tbody tr.row-highlighted,
[data-bs-theme="dark"] .table-striped > tbody > tr.row-highlighted {
    --bs-table-striped-bg: #4a3a10;
    --bs-table-bg: #4a3a10;
    background-color: #4a3a10 !important;
}

[data-bs-theme="dark"] .table tbody tr.row-highlighted > td,
[data-bs-theme="dark"] .table-striped > tbody > tr.row-highlighted > td {
    background-color: #4a3a10 !important;
    box-shadow: none !important;
}
