/* ═══════════════════════════════════════════════════════════════
   NorteERP Enterprise — Cloud ERP, WMS, SPED & Controladoria v10.4
   Design System & Componentes: Dual-Theme (Dark Slate & Crisp Light)
   Polo Tecnológico: Montes Claros / MG
   ═══════════════════════════════════════════════════════════════ */

:root {
    color-scheme: dark;
    --erp-primary: #0284c7;
    --erp-primary-hover: #0369a1;
    --erp-primary-light: #38bdf8;
    --erp-accent: #6366f1;
    --erp-success: #10b981;
    --erp-warning: #f59e0b;
    --erp-danger: #ef4444;
    --erp-info: #06b6d4;

    /* Tema Escuro Padrão */
    --erp-bg: #070c18;
    --erp-surface: #0c1427;
    --erp-card: #101c36;
    --erp-card-hover: #162445;
    --erp-border: rgba(255, 255, 255, 0.08);
    --erp-border-subtle: rgba(255, 255, 255, 0.04);
    --erp-text: #f8fafc;
    --erp-text-muted: #94a3b8;
    --erp-input-bg: #091020;
    --erp-header-bg: rgba(12, 20, 39, 0.92);
    --erp-sidebar-bg: #080e1d;
    --erp-table-stripe: rgba(255, 255, 255, 0.02);
    --erp-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

[data-bs-theme="light"],
body.theme-light {
    color-scheme: light;
    --erp-primary: #0284c7;
    --erp-primary-hover: #0369a1;
    --erp-primary-light: #0284c7;
    --erp-accent: #4f46e5;
    --erp-success: #059669;
    --erp-warning: #d97706;
    --erp-danger: #dc2626;
    --erp-info: #0891b2;

    /* Tema Claro */
    --erp-bg: #f8fafc;
    --erp-surface: #ffffff;
    --erp-card: #ffffff;
    --erp-card-hover: #f1f5f9;
    --erp-border: #e2e8f0;
    --erp-border-subtle: #f1f5f9;
    --erp-text: #0f172a;
    --erp-text-muted: #64748b;
    --erp-input-bg: #f8fafc;
    --erp-header-bg: rgba(255, 255, 255, 0.95);
    --erp-sidebar-bg: #0a0f1d; /* Sidebar mantém elegância corporativa escura */
    --erp-table-stripe: #f8fafc;
    --erp-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

body {
    font-family: 'Space Grotesk', system-ui, -apple-system, sans-serif;
    background-color: var(--erp-bg);
    color: var(--erp-text);
    font-size: 13px;
    overflow-x: hidden;
    transition: background-color 0.25s ease, color 0.25s ease;
}

.font-monospace {
    font-family: 'JetBrains Mono', 'IBM Plex Mono', monospace !important;
}

/* ═══════════════════════════════════════════════════════════════
   1. Demo Bar do Topo
   ═══════════════════════════════════════════════════════════════ */
.difrativa-demo-bar {
    background: #060a14;
    color: #ffffff;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    z-index: 1050;
    font-size: 13px;
}

.demo-bar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.demo-back-btn {
    color: #94a3b8;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    transition: color 0.2s;
}

.demo-back-btn:hover { color: #ffffff; }

.demo-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(2, 132, 199, 0.15);
    border: 1px solid rgba(2, 132, 199, 0.35);
    padding: 3px 10px;
    border-radius: 999px;
    color: #38bdf8;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 600;
}

.demo-pulse {
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 6px #10b981;
    animation: pulseGlow 1.8s infinite;
}

@keyframes pulseGlow {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.demo-cta-btn {
    background: #25D366;
    color: #ffffff;
    text-decoration: none;
    font-weight: 700;
    padding: 6px 16px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.25s;
}

.demo-cta-btn:hover {
    background: #1EBE5A;
    color: #ffffff;
    transform: translateY(-1px);
}

.erp-theme-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #f1f5f9;
    border-radius: 8px;
    padding: 5px 10px;
    transition: all 0.2s;
}

.erp-theme-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #38bdf8;
}

/* ═══════════════════════════════════════════════════════════════
   2. Layout da Aplicação ERP
   ═══════════════════════════════════════════════════════════════ */
.erp-app {
    display: flex;
    min-height: calc(100vh - 46px);
    position: relative;
}

.erp-sidebar {
    width: 275px;
    background: var(--erp-sidebar-bg);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    position: sticky;
    top: 46px;
    height: calc(100vh - 46px);
    overflow-y: auto;
    z-index: 1040;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.erp-sidebar-top {
    padding: 18px 16px 8px;
}

.erp-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.erp-brand-icon {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: linear-gradient(135deg, #0284c7, #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 18px;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.erp-brand-name {
    font-weight: 800;
    font-size: 16px;
    color: #ffffff;
    letter-spacing: -0.02em;
}

.erp-brand-badge {
    font-size: 9.5px;
    text-transform: uppercase;
    background: rgba(2, 132, 199, 0.25);
    color: #38bdf8;
    border: 1px solid rgba(2, 132, 199, 0.4);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.erp-brand-sub {
    font-size: 11px;
    color: #64748b;
    display: block;
}

/* User Card */
.erp-user-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.erp-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #ffffff;
    font-weight: 700;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.erp-user-status {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: #10b981;
    border: 2px solid #080e1d;
    border-radius: 50%;
}

.erp-user-info {
    overflow: hidden;
}

.erp-user-name {
    font-size: 12px;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.erp-user-role {
    font-size: 10.5px;
    color: #94a3b8;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.erp-user-branch {
    font-size: 10px;
    color: #38bdf8;
    margin-top: 2px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Nav Items */
.erp-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.erp-nav-section {
    padding: 12px 12px 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    text-transform: uppercase;
    color: #64748b;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.erp-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8.5px 12px;
    border-radius: 8px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 500;
    transition: all 0.18s ease;
    border-left: 3px solid transparent;
    white-space: nowrap;
}

.erp-nav-link > span:first-of-type {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.erp-nav-link i {
    font-size: 15px;
    width: 18px;
    text-align: center;
    color: #64748b;
    transition: color 0.18s ease;
}

.erp-nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
}

.erp-nav-link:hover i {
    color: #38bdf8;
}

.erp-nav-link.active {
    background: rgba(2, 132, 199, 0.18);
    color: #ffffff;
    border-left-color: #38bdf8;
    font-weight: 700;
}

.erp-nav-link.active i {
    color: #38bdf8;
}

.erp-nav-pill {
    margin-left: auto;
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 999px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    white-space: nowrap !important;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1.3;
    letter-spacing: 0.02em;
}

.erp-nav-pill .erp-status-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background-color: currentColor;
    display: inline-block;
    flex-shrink: 0;
}

.erp-nav-pill.badge-primary { background: rgba(2, 132, 199, 0.25); color: #38bdf8; }
.erp-nav-pill.badge-secondary { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; }
.erp-nav-pill.badge-success { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.erp-nav-pill.badge-info { background: rgba(6, 182, 212, 0.2); color: #22d3ee; }

.erp-sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.2);
}

/* ═══════════════════════════════════════════════════════════════
   3. Main Wrapper & Header
   ═══════════════════════════════════════════════════════════════ */
.erp-main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.erp-header {
    background: var(--erp-header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--erp-border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 46px;
    z-index: 1030;
    transition: background-color 0.25s ease;
}

.erp-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
}

.erp-global-search {
    position: relative;
    width: 380px;
}

.erp-global-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--erp-text-muted);
    font-size: 13px;
}

.erp-global-search input {
    width: 100%;
    background: var(--erp-input-bg);
    border: 1px solid var(--erp-border);
    color: var(--erp-text);
    border-radius: 8px;
    padding: 7px 75px 7px 34px;
    font-size: 12.5px;
    transition: all 0.2s ease;
}

.erp-global-search input:focus {
    outline: none;
    border-color: var(--erp-primary);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.2);
}

.erp-search-kbd {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--erp-surface);
    border: 1px solid var(--erp-border);
    color: var(--erp-text-muted);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-family: monospace;
}

.erp-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.erp-branch-btn {
    background: var(--erp-surface);
    border: 1px solid var(--erp-border);
    color: var(--erp-text);
    border-radius: 8px;
    font-weight: 600;
    font-size: 12px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.erp-icon-btn {
    background: var(--erp-surface);
    border: 1px solid var(--erp-border);
    color: var(--erp-text);
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.erp-icon-btn:hover {
    background: var(--erp-card-hover);
    color: var(--erp-primary);
}

.erp-notify-dropdown {
    width: 320px;
    border: 1px solid var(--erp-border);
    background: var(--erp-surface);
}

/* ═══════════════════════════════════════════════════════════════
   4. Viewport & Páginas
   ═══════════════════════════════════════════════════════════════ */
.erp-viewport {
    padding: 24px 32px;
    flex: 1;
}

.erp-page {
    display: none;
    animation: fadeInPage 0.25s ease-out;
}

.erp-page.active {
    display: block;
}

@keyframes fadeInPage {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.erp-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.erp-page-title {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 2px;
    letter-spacing: -0.02em;
    color: var(--erp-text);
}

.erp-page-subtitle {
    font-size: 12.5px;
    color: var(--erp-text-muted);
    margin-bottom: 0;
}

/* ═══════════════════════════════════════════════════════════════
   5. Cards & KPIs
   ═══════════════════════════════════════════════════════════════ */
.erp-card {
    background: var(--erp-card);
    border: 1px solid var(--erp-border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--erp-shadow);
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

.erp-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--erp-border);
}

.erp-card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--erp-text);
}

.erp-card-body {
    padding: 20px;
}

.erp-kpi-card {
    background: var(--erp-card);
    border: 1px solid var(--erp-border);
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: var(--erp-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}

.erp-kpi-card:hover {
    transform: translateY(-2px);
}

.erp-kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.card-kpi-blue::before { background: #0284c7; }
.card-kpi-emerald::before { background: #10b981; }
.card-kpi-amber::before { background: #f59e0b; }
.card-kpi-purple::before { background: #8b5cf6; }

.erp-kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.erp-kpi-label {
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--erp-text-muted);
}

.erp-kpi-icon {
    font-size: 18px;
    opacity: 0.85;
}

.card-kpi-blue .erp-kpi-icon { color: #0284c7; }
.card-kpi-emerald .erp-kpi-icon { color: #10b981; }
.card-kpi-amber .erp-kpi-icon { color: #f59e0b; }
.card-kpi-purple .erp-kpi-icon { color: #8b5cf6; }

.erp-kpi-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--erp-text);
    line-height: 1.1;
    margin-bottom: 8px;
}

.erp-kpi-footer {
    font-size: 11.5px;
    display: flex;
    align-items: center;
}

/* Metric Tiles */
.erp-metric-tile {
    background: var(--erp-card);
    border: 1px solid var(--erp-border);
    border-radius: 10px;
    padding: 14px 16px;
    text-align: center;
}

.erp-tile-num {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 2px;
}

.erp-tile-text {
    font-size: 11px;
    color: var(--erp-text-muted);
}

/* Warehouse Card */
.erp-warehouse-card {
    background: var(--erp-card);
    border: 1px solid var(--erp-border);
    border-radius: 12px;
    padding: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.erp-warehouse-card:hover {
    border-color: var(--erp-primary);
    transform: translateY(-2px);
}

.erp-warehouse-card.active {
    border-color: var(--erp-primary);
    box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.25);
    background: var(--erp-card-hover);
}

.erp-wh-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(2, 132, 199, 0.15);
    color: var(--erp-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

/* Finance Stats */
.erp-finance-stat {
    background: var(--erp-card);
    border: 1px solid var(--erp-border);
    border-radius: 10px;
    padding: 16px;
}

.erp-fin-label {
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--erp-text-muted);
}

.erp-fin-val {
    font-size: 19px;
    font-weight: 800;
    margin: 4px 0 2px;
}

.erp-fin-sub {
    font-size: 11px;
}

.erp-bank-badge {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.erp-sefaz-badge {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

/* ═══════════════════════════════════════════════════════════════
   6. Tabelas do ERP
   ═══════════════════════════════════════════════════════════════ */
.erp-table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--erp-text);
    margin-bottom: 0;
}

.erp-table th {
    background: var(--erp-table-stripe);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--erp-text-muted);
    padding: 12px 16px;
    border-bottom: 1px solid var(--erp-border);
    white-space: nowrap;
}

.erp-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--erp-border);
    font-size: 12.5px;
    color: var(--erp-text);
}

.erp-table tbody tr:hover td {
    background: var(--erp-card-hover);
}

/* DRE Table */
.erp-dre-table th {
    background: var(--erp-table-stripe);
    font-size: 11px;
    font-weight: 700;
    color: var(--erp-text-muted);
    padding: 10px 16px;
    border-bottom: 1px solid var(--erp-border);
}

.erp-dre-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--erp-border);
    font-size: 13px;
    color: var(--erp-text);
}

.dre-row-header td {
    background: rgba(2, 132, 199, 0.08);
}

.dre-row-subtotal td {
    background: rgba(255, 255, 255, 0.03);
    border-top: 1px dashed var(--erp-border);
    border-bottom: 1px dashed var(--erp-border);
}

.dre-sub-row td {
    color: var(--erp-text-muted);
    font-size: 12.5px;
}

/* Tabs */
.erp-tabs {
    border-bottom: 1px solid var(--erp-border);
}

.erp-tabs .nav-link {
    color: var(--erp-text-muted);
    border: none;
    border-bottom: 2px solid transparent;
    font-weight: 600;
    font-size: 13px;
    padding: 10px 18px;
    background: transparent;
    transition: all 0.2s;
}

.erp-tabs .nav-link:hover {
    color: var(--erp-text);
}

.erp-tabs .nav-link.active {
    color: var(--erp-primary);
    border-bottom-color: var(--erp-primary);
    background: transparent;
}

/* ═══════════════════════════════════════════════════════════════
   7. DANFE Preview Estilizado
   ═══════════════════════════════════════════════════════════════ */
.danfe-document {
    background: #ffffff;
    color: #111827;
    font-family: 'Arial', sans-serif;
    border: 2px solid #000000;
    padding: 16px;
    font-size: 11px;
    line-height: 1.25;
}

.danfe-box {
    border: 1px solid #000000;
    padding: 4px 6px;
    margin-bottom: 4px;
}

.danfe-label {
    font-size: 8px;
    text-transform: uppercase;
    font-weight: bold;
    color: #374151;
    display: block;
}

.danfe-value {
    font-size: 11px;
    font-weight: bold;
    color: #000000;
}

.danfe-barcode {
    height: 48px;
    background: repeating-linear-gradient(
        90deg,
        #000000,
        #000000 2px,
        #ffffff 2px,
        #ffffff 4px,
        #000000 4px,
        #000000 7px,
        #ffffff 7px,
        #ffffff 9px
    );
    margin: 4px 0;
}

/* Modal Icons */
.erp-modal-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

/* ═══════════════════════════════════════════════════════════════
   8. Responsividade
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {
    .erp-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        height: 100vh;
        transform: translateX(-100%);
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
    }

    .erp-sidebar.show {
        transform: translateX(0);
    }

    .erp-viewport {
        padding: 16px;
    }
}
