/* =============================================================================
   NEXUS ENHANCE — Camada Premium de Efeitos Visuais & Micro-interações
   =============================================================================
   Arquivo complementar ao app.css para o ERP OKAYAMA.
   Adiciona micro-interações, animações de entrada, efeitos de profundidade e
   polimento estético sem alterar nenhuma regra de negócio ou lógica do sistema.

   ✅ 100% CSS — Zero alteração em lógica PHP/JS ou no site institucional
   ✅ Hardware-Accelerated (transform & opacity) para máxima fluidez a 60fps
   ✅ Compatibilidade total com Modo Dark e Modo Light
   ✅ Suporte integral a prefers-reduced-motion e impressão (@media print)
   ============================================================================= */

/* ---------------------------------------------------------------------------
   1. TIPOGRAFIA & SUAVIZAÇÃO
   --------------------------------------------------------------------------- */
body.dashboard-shell {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.dashboard-shell.theme-dark .main-content > .d-flex:first-of-type h1,
body.dashboard-shell.theme-dark .main-content > .d-flex:first-of-type .h4 {
    background: linear-gradient(135deg, #ffffff 0%, rgba(var(--nexus-accent-rgb), 0.9) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.01em;
}

body.dashboard-shell.theme-light .main-content > .d-flex:first-of-type h1,
body.dashboard-shell.theme-light .main-content > .d-flex:first-of-type .h4 {
    background: linear-gradient(135deg, #0b152a 0%, var(--nexus-accent) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.01em;
}

/* ---------------------------------------------------------------------------
   2. ANIMAÇÕES DE ENTRADA — STAGGER REVEAL FLUIDO
   --------------------------------------------------------------------------- */
@keyframes nexus-reveal {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes nexus-reveal-scale {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(12px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

body.dashboard-shell .main-content > .card,
body.dashboard-shell .main-content > .d-flex,
body.dashboard-shell .main-content > .alert,
body.dashboard-shell .main-content > .row,
body.dashboard-shell .main-content > .table-responsive,
body.dashboard-shell .main-content > .mb-3,
body.dashboard-shell .main-content > .mb-4 {
    animation: nexus-reveal 0.42s cubic-bezier(0.16, 1, 0.3, 1) both;
}

body.dashboard-shell .main-content > :nth-child(1) { animation-delay: 0s; }
body.dashboard-shell .main-content > :nth-child(2) { animation-delay: 0.05s; }
body.dashboard-shell .main-content > :nth-child(3) { animation-delay: 0.1s; }
body.dashboard-shell .main-content > :nth-child(4) { animation-delay: 0.15s; }
body.dashboard-shell .main-content > :nth-child(5) { animation-delay: 0.19s; }
body.dashboard-shell .main-content > :nth-child(6) { animation-delay: 0.23s; }
body.dashboard-shell .main-content > :nth-child(n+7) { animation-delay: 0.27s; }

/* Modais com abertura suave e elástica */
body.dashboard-shell .modal.fade .modal-dialog {
    transform: scale(0.94) translateY(20px);
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.28s ease;
}

body.dashboard-shell .modal.show .modal-dialog {
    transform: scale(1) translateY(0);
}

/* ---------------------------------------------------------------------------
   3. CARDS — REALCE DE BORDA & HOVER SUAVE
   --------------------------------------------------------------------------- */
body.dashboard-shell .main-content .card:not(.stock-metric-card):not(.stock-filter-card):not(.stock-alert-panel):not(.stock-rules-panel):not(.stock-table-card):not(.kpi-card):not(.alerta-card) {
    position: relative;
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.22s ease, border-color 0.22s ease;
}

body.dashboard-shell.theme-dark .main-content .card:not(.stock-metric-card):not(.stock-filter-card):not(.stock-alert-panel):not(.stock-rules-panel):not(.stock-table-card):not(.kpi-card):not(.alerta-card)::after {
    content: "";
    position: absolute;
    top: 0;
    left: 12%;
    right: 12%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(var(--nexus-accent-rgb), 0.5), transparent);
    border-radius: 999px;
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
    z-index: 2;
}

body.dashboard-shell.theme-dark .main-content .card:not(.stock-metric-card):not(.stock-filter-card):not(.stock-alert-panel):not(.stock-rules-panel):not(.stock-table-card):not(.kpi-card):not(.alerta-card):hover::after {
    opacity: 1;
}

/* ---------------------------------------------------------------------------
   4. SIDEBAR — GLOW & INDICADOR ATIVO
   --------------------------------------------------------------------------- */
.sidebar {
    position: fixed;
    z-index: 1040;
}

/* Ícone de item ativo na sidebar pulsa sutilmente */
.sidebar .nav-link.active i {
    animation: nexus-icon-pulse 2.4s ease-in-out infinite;
}

@keyframes nexus-icon-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Indicador luminoso vertical no menu ativo */
.sidebar .nav-link.active {
    position: relative;
}

.sidebar .nav-link.active::before {
    content: "";
    position: absolute;
    left: -0.65rem;
    top: 50%;
    transform: translateY(-50%);
    width: 3.5px;
    height: 55%;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--nexus-accent), var(--nexus-accent-alt));
    box-shadow: 0 0 8px rgba(var(--nexus-accent-rgb), 0.55);
}

/* ---------------------------------------------------------------------------
   5. TABELAS — INDICADOR LATERAL NO HOVER
   --------------------------------------------------------------------------- */
body.dashboard-shell .table tbody tr {
    transition: background-color 0.18s ease;
}

body.dashboard-shell .table tbody tr td {
    transition: box-shadow 0.18s ease, color 0.18s ease;
}

body.dashboard-shell .table tbody tr:hover td:first-child {
    box-shadow: inset 3.5px 0 0 var(--nexus-accent);
}

/* ---------------------------------------------------------------------------
   6. BOTÕES — MICRO-INTERAÇÕES & VARREDURA DE LUZ
   --------------------------------------------------------------------------- */
body.dashboard-shell .btn:not(.dropdown-toggle):not(.btn-link):not(.btn-close) {
    position: relative;
    overflow: hidden;
}

body.dashboard-shell .btn:not(.dropdown-toggle):not(.btn-link):not(.btn-close)::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    transition: left 0.55s ease;
    pointer-events: none;
    z-index: 1;
}

body.dashboard-shell .btn:not(.dropdown-toggle):not(.btn-link):not(.btn-close):hover::before {
    left: 100%;
}

/* ---------------------------------------------------------------------------
   7. INPUTS — FOCO REFINADO COM ANEL LUMINOSO
   --------------------------------------------------------------------------- */
body.dashboard-shell .form-control,
body.dashboard-shell .form-select,
body.dashboard-shell textarea {
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

body.dashboard-shell .form-control:focus,
body.dashboard-shell .form-select:focus,
body.dashboard-shell textarea:focus {
    border-color: var(--nexus-accent);
    box-shadow: 0 0 0 0.2rem rgba(var(--nexus-accent-rgb), 0.22), 0 4px 16px rgba(var(--nexus-accent-rgb), 0.15);
}

/* ---------------------------------------------------------------------------
   8. BADGES — EFEITO SHIMMER DISCRETO
   --------------------------------------------------------------------------- */
@keyframes nexus-badge-shimmer {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

body.dashboard-shell .badge.bg-primary,
body.dashboard-shell .badge.bg-success,
body.dashboard-shell .badge.bg-warning,
body.dashboard-shell .badge.bg-danger,
body.dashboard-shell .badge.bg-info {
    background-size: 200% 100%;
    animation: nexus-badge-shimmer 4.5s ease-in-out infinite;
}

body.dashboard-shell .badge.bg-primary {
    background-image: linear-gradient(90deg, var(--nexus-accent) 0%, rgba(var(--nexus-accent-rgb), 0.72) 50%, var(--nexus-accent) 100%);
}

body.dashboard-shell .badge.bg-success {
    background-image: linear-gradient(90deg, #198754 0%, #20c997 50%, #198754 100%);
}

body.dashboard-shell .badge.bg-danger {
    background-image: linear-gradient(90deg, #dc3545 0%, #e65c6a 50%, #dc3545 100%);
}

body.dashboard-shell .badge.bg-warning {
    background-image: linear-gradient(90deg, #ffc107 0%, #ffcd39 50%, #ffc107 100%);
}

body.dashboard-shell .badge.bg-info {
    background-image: linear-gradient(90deg, #0dcaf0 0%, #3dd5f3 50%, #0dcaf0 100%);
}

/* ---------------------------------------------------------------------------
   9. KPI CARDS — ELEVAÇÃO & BRILHO AMBIENTE
   --------------------------------------------------------------------------- */
body.dashboard-shell .kpi-card {
    transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.24s ease;
    position: relative;
    overflow: hidden;
}

body.dashboard-shell .kpi-card::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(var(--nexus-accent-rgb), 0.07), transparent 60%);
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
}

body.dashboard-shell .kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 1.5rem 3.5rem rgba(var(--nexus-accent-rgb), 0.16);
}

body.dashboard-shell .kpi-card:hover::before {
    opacity: 1;
}

/* ---------------------------------------------------------------------------
   10. SCROLLBAR ELEGANTE NA NAVEGAÇÃO
   --------------------------------------------------------------------------- */
body.dashboard-shell .sidebar nav::-webkit-scrollbar {
    width: 4px;
}

body.dashboard-shell .sidebar nav::-webkit-scrollbar-thumb {
    background: rgba(var(--nexus-accent-rgb), 0.35);
    border-radius: 999px;
}

body.dashboard-shell .sidebar nav::-webkit-scrollbar-track {
    background: transparent;
}

body.dashboard-shell .sidebar nav {
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--nexus-accent-rgb), 0.35) transparent;
}

/* ---------------------------------------------------------------------------
   11. LOADING OVERLAY APRIMORADO
   --------------------------------------------------------------------------- */
.loading-overlay.show .loading-spinner {
    filter: drop-shadow(0 0 24px rgba(var(--nexus-accent-rgb, 13, 110, 253), 0.55));
}

.loading-overlay .loading-spinner span {
    background: linear-gradient(135deg, rgba(var(--nexus-accent-rgb, 13, 110, 253), 0.95), #d3dcff);
}

/* ---------------------------------------------------------------------------
   12. ALERTAS — LINHA LATERAL DE STATUS
   --------------------------------------------------------------------------- */
body.dashboard-shell .alert-success {
    border-left: 4px solid #22c55e !important;
}

body.dashboard-shell .alert-danger {
    border-left: 4px solid #ef4444 !important;
}

body.dashboard-shell .alert-warning {
    border-left: 4px solid #f59e0b !important;
}

body.dashboard-shell .alert-info,
body.dashboard-shell .alert-primary {
    border-left: 4px solid var(--nexus-accent) !important;
}

/* ---------------------------------------------------------------------------
   13. NAV TABS & PILLS
   --------------------------------------------------------------------------- */
body.dashboard-shell .nav-pills .nav-link.active,
body.dashboard-shell .nav-tabs .nav-link.active {
    position: relative;
}

body.dashboard-shell .nav-pills .nav-link.active::after,
body.dashboard-shell .nav-tabs .nav-link.active::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 20%;
    right: 20%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--nexus-accent), transparent);
    border-radius: 999px;
    box-shadow: 0 0 8px rgba(var(--nexus-accent-rgb), 0.45);
}

/* ---------------------------------------------------------------------------
   14. DROPDOWNS & TOASTS
   --------------------------------------------------------------------------- */
body.dashboard-shell .dropdown-menu {
    animation: nexus-dropdown-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: top center;
}

@keyframes nexus-dropdown-in {
    from {
        opacity: 0;
        transform: scaleY(0.9) translateY(-6px);
    }
    to {
        opacity: 1;
        transform: scaleY(1) translateY(0);
    }
}

@keyframes nexus-toast-in {
    from {
        opacity: 0;
        transform: translateX(40px) scale(0.94);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

body.dashboard-shell .toast.show {
    animation: nexus-toast-in 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ---------------------------------------------------------------------------
   15. MODAL HEADER — LINHA SUPERIOR COM COR DA MARCA
   --------------------------------------------------------------------------- */
body.dashboard-shell .modal-header {
    border-top: 3px solid transparent;
    background-image: linear-gradient(90deg, var(--nexus-accent), var(--nexus-accent-alt));
    background-size: 100% 3px;
    background-repeat: no-repeat;
    background-position: top;
}

/* ---------------------------------------------------------------------------
   16. LOGIN PAGE — GLOW & PULSO DINÂMICO
   --------------------------------------------------------------------------- */
body.login-page .login-card__header-icon {
    animation: nexus-login-icon-glow 3s ease-in-out infinite;
}

@keyframes nexus-login-icon-glow {
    0%, 100% {
        box-shadow: 0 18px 38px rgba(var(--login-accent-rgb, 13, 110, 253), 0.42);
    }
    50% {
        box-shadow:
            0 18px 38px rgba(var(--login-accent-rgb, 13, 110, 253), 0.55),
            0 0 50px rgba(var(--login-accent-rgb, 13, 110, 253), 0.25);
    }
}

body.login-page .login-card {
    animation: nexus-reveal-scale 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}

body.login-page .login-card .btn-primary {
    position: relative;
    overflow: hidden;
    transition: transform 0.22s ease, box-shadow 0.22s ease;
}

body.login-page .login-card .btn-primary:hover {
    transform: translateY(-2px);
}

/* ---------------------------------------------------------------------------
   17. FOLDER CARDS & FILTRO DE STATUS
   --------------------------------------------------------------------------- */
.folder-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.folder-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 1rem 2rem rgba(var(--nexus-accent-rgb), 0.16);
}

.folder-card .folder-icon {
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.folder-card:hover .folder-icon {
    transform: scale(1.08);
}

/* ---------------------------------------------------------------------------
   18. CHECKBOX / RADIO / SWITCH
   --------------------------------------------------------------------------- */
body.dashboard-shell .form-check-input {
    transition: background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

body.dashboard-shell .form-check-input:checked {
    box-shadow: 0 0 0 0.15rem rgba(var(--nexus-accent-rgb), 0.2), 0 3px 10px rgba(var(--nexus-accent-rgb), 0.28);
}

/* ---------------------------------------------------------------------------
   19. SELEÇÃO DE TEXTO
   --------------------------------------------------------------------------- */
body.dashboard-shell ::selection {
    background: rgba(var(--nexus-accent-rgb), 0.28);
    color: #ffffff;
}

body.dashboard-shell ::-moz-selection {
    background: rgba(var(--nexus-accent-rgb), 0.28);
    color: #ffffff;
}

/* ---------------------------------------------------------------------------
   20. PAGINAÇÃO REFINADA
   --------------------------------------------------------------------------- */
body.dashboard-shell .pagination .page-link {
    border-radius: 0.6rem;
    border: 1px solid var(--nexus-border);
    background: var(--nexus-surface);
    color: var(--nexus-text);
    margin: 0 2px;
    transition: transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

body.dashboard-shell .pagination .page-item.active .page-link {
    background: linear-gradient(135deg, var(--nexus-accent), var(--nexus-accent-alt)) !important;
    border-color: transparent !important;
    box-shadow: 0 8px 18px rgba(var(--nexus-accent-rgb), 0.32);
}

body.dashboard-shell .pagination .page-link:hover {
    background: rgba(var(--nexus-accent-rgb), 0.16);
    border-color: var(--nexus-accent);
    transform: translateY(-1px);
}

/* ---------------------------------------------------------------------------
   21. EMPTY STATES & PROGRESS BARS
   --------------------------------------------------------------------------- */
body.dashboard-shell .progress-bar {
    position: relative;
    overflow: hidden;
}

body.dashboard-shell .progress-bar::after {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
    animation: nexus-progress-shine 2.8s ease-in-out infinite;
}

@keyframes nexus-progress-shine {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* ---------------------------------------------------------------------------
   22. PREFERS-REDUCED-MOTION (Acessibilidade)
   --------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    body.dashboard-shell .main-content > .card,
    body.dashboard-shell .main-content > .d-flex,
    body.dashboard-shell .main-content > .alert,
    body.dashboard-shell .main-content > .row,
    body.dashboard-shell .main-content > .table-responsive,
    body.dashboard-shell .main-content > .mb-3,
    body.dashboard-shell .main-content > .mb-4 {
        animation: none !important;
    }

    body.dashboard-shell .modal.fade .modal-dialog {
        transition: none !important;
    }

    body.dashboard-shell .dropdown-menu,
    body.dashboard-shell .toast.show {
        animation: none !important;
    }

    .sidebar .nav-link.active i,
    body.login-page .login-card__header-icon,
    body.login-page .login-card,
    body.dashboard-shell .badge,
    body.dashboard-shell .progress-bar::after {
        animation: none !important;
    }

    body.dashboard-shell .kpi-card {
        transition: none !important;
    }
}

/* ---------------------------------------------------------------------------
   23. PRINT (Impressão sem artefatos gráficos)
   --------------------------------------------------------------------------- */
@media print {
    body.dashboard-shell .main-content > * {
        animation: none !important;
    }

    body.dashboard-shell .kpi-card::before,
    body.dashboard-shell .main-content .card::after {
        display: none !important;
    }
}
