/* ============================================================
   Moink BI — style.css v2
   Cores: Preto #111 | Vermelho #C8281A | Dourado #E8A020
   ============================================================ */

:root {
    /* Paleta Moink */
    --moink-preto:      #0f0f0f;
    --moink-vermelho:   #C8281A;
    --moink-vermelho-h: #a81f14;
    --moink-dourado:    #E8A020;
    --moink-dourado-h:  #c98a18;

    /* Layout */
    --sidebar-bg:      #000000;
    --sidebar-width:    248px;
    --header-height:    58px;

    /* Superfícies */
    --bg-page:          #f5f4f2;
    --bg-card:          #ffffff;
    --bg-sidebar-item:  rgba(232,160,32,.1);

    /* Texto */
    --text-primary:     #1a1a1a;
    --text-secondary:   #6b6760;
    --text-muted:       #9b9890;

    /* Bordas */
    --border:           #e8e5e0;
    --border-strong:    #d0ccc6;

    /* Semânticos */
    --success:  #22a85a;
    --warning:  #d97706;
    --danger:   #dc2626;
    --info:     #2563eb;

    /* Efeitos */
    --shadow-sm: 0 1px 4px rgba(0,0,0,.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,.09);
    --radius:    8px;
    --radius-lg: 12px;

    --font: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg-page); color: var(--text-primary); line-height: 1.55; min-height: 100vh; }
a { color: var(--moink-vermelho); text-decoration: none; }
a:hover { color: var(--moink-vermelho-h); }
img { max-width: 100%; }

/* ============================================================
   LAYOUT
   ============================================================ */

.app-layout { display: flex; min-height: 100vh; }

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 200;
    overflow-y: auto;
    transition: transform .25s ease;
}

/* Logo */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px 16px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-logo img {
    width: 42px;
    height: 26px;
    object-fit: contain;
}

.sidebar-logo-text {
    font-size: .78rem;
    font-weight: 600;
    color: rgba(255,255,255,.5);
    letter-spacing: .08em;
    text-transform: uppercase;
}

/* Nav */
.sidebar-nav { flex: 1; padding: 10px 0 8px; }

.nav-section {
    font-size: .64rem;
    font-weight: 700;
    color: rgba(255,255,255,.25);
    text-transform: uppercase;
    letter-spacing: .1em;
    padding: 14px 16px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 16px;
    color: rgba(255,255,255,.58);
    font-size: .84rem;
    font-weight: 500;
    transition: background .12s, color .12s;
    cursor: pointer;
    border-left: 3px solid transparent;
    margin: 1px 0;
}

.nav-item:hover { background: rgba(255,255,255,.06); color: rgba(255,255,255,.88); }

.nav-item.ativo {
    background: rgba(232,160,32,.12);
    color: var(--moink-dourado);
    border-left-color: var(--moink-dourado);
}

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .75; }
.nav-item.ativo svg { opacity: 1; }

/* Usuário no rodapé */
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,.06);
}

.sidebar-user { display: flex; align-items: center; gap: 9px; }

.sidebar-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--moink-vermelho);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .75rem; color: #fff;
    flex-shrink: 0;
}

.sidebar-user-nome { font-size: .8rem; font-weight: 600; color: rgba(255,255,255,.85); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-perfil { font-size: .68rem; color: rgba(255,255,255,.35); }

.sidebar-user-logout { color: rgba(255,255,255,.3); transition: color .12s; margin-left: auto; flex-shrink: 0; }
.sidebar-user-logout:hover { color: var(--moink-vermelho); }

/* --- Main content --- */
.main-content { margin-left: var(--sidebar-width); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* --- Topbar --- */
.topbar {
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0; z-index: 100;
    gap: 12px;
}

.topbar-titulo { font-size: .95rem; font-weight: 700; color: var(--text-primary); flex: 1; }

.topbar-mes select {
    font-size: .8rem;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-page);
    color: var(--text-primary);
    cursor: pointer;
}

.btn-menu-mobile { display: none; background: none; border: none; cursor: pointer; padding: 4px; color: var(--text-primary); }

/* Conteúdo */
.page-content { flex: 1; padding: 24px; }

/* ============================================================
   COMPONENTES
   ============================================================ */

/* --- KPI Cards --- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.kpi-card::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 3px;
    background: var(--moink-dourado);
}

.kpi-card.kpi-red::after    { background: var(--moink-vermelho); }
.kpi-card.kpi-success::after{ background: var(--success); }
.kpi-card.kpi-warning::after{ background: var(--warning); }
.kpi-card.kpi-info::after   { background: var(--info); }
.kpi-card.kpi-danger::after { background: var(--danger); }

.kpi-label {
    font-size: .69rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 5px;
}

.kpi-valor {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
}

.kpi-valor.menor { font-size: 1.15rem; }

.kpi-rodape {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 6px;
    font-size: .71rem;
    color: var(--text-muted);
}

.variacao {
    display: inline-flex;
    align-items: center;
    font-size: .7rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 20px;
}
.variacao.positiva { background: #d1fae5; color: #065f46; }
.variacao.negativa { background: #fee2e2; color: #991b1b; }
.variacao.neutra   { background: #f3f4f6; color: #6b7280; }

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 14px 18px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.card-title { font-size: .88rem; font-weight: 700; color: var(--text-primary); }
.card-subtitle { font-size: .73rem; color: var(--text-muted); margin-top: 1px; }
.card-body { padding: 18px; }

/* --- Grid de gráficos --- */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}

.chart-container { position: relative; height: 250px; }
.chart-container.alto { height: 310px; }
.chart-container.medio { height: 200px; }

/* --- Tabelas --- */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }

table { width: 100%; border-collapse: collapse; font-size: .83rem; }

th {
    background: #f9f8f6;
    padding: 10px 13px;
    font-weight: 700;
    font-size: .7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td { padding: 11px 13px; border-bottom: 1px solid #f2f0ec; color: var(--text-primary); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #faf9f7; }

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    font-size: .69rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    white-space: nowrap;
}

.badge-success  { background: #d1fae5; color: #065f46; }
.badge-danger   { background: #fee2e2; color: #991b1b; }
.badge-warning  { background: #fef3c7; color: #92400e; }
.badge-info     { background: #dbeafe; color: #1e40af; }
.badge-secondary{ background: #f3f4f6; color: #4b5563; }
.badge-moink    { background: var(--moink-vermelho); color: #fff; }
.badge-gold     { background: var(--moink-dourado); color: #fff; }

.bg-red-100    { background: #fee2e2; } .text-red-700  { color: #b91c1c; }
.bg-purple-100 { background: #ede9fe; } .text-purple-700{color: #6d28d9; }
.bg-blue-100   { background: #dbeafe; } .text-blue-700  { color: #1d4ed8; }
.bg-gray-100   { background: #f3f4f6; } .text-gray-700  { color: #374151; }

/* --- Botões --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 15px;
    border-radius: var(--radius);
    font-size: .83rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background .13s, transform .09s;
    white-space: nowrap;
    text-decoration: none;
}
.btn:active { transform: scale(.98); }

.btn-primary { background: var(--moink-vermelho); color: #fff; }
.btn-primary:hover { background: var(--moink-vermelho-h); color: #fff; }

.btn-gold { background: var(--moink-dourado); color: #fff; }
.btn-gold:hover { background: var(--moink-dourado-h); color: #fff; }

.btn-outline { background: transparent; color: var(--text-primary); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg-page); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }

.btn-sm { padding: 5px 10px; font-size: .76rem; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* --- Formulários --- */
.form-group { margin-bottom: 16px; }

label { display: block; font-size: .8rem; font-weight: 600; color: var(--text-primary); margin-bottom: 5px; }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="month"],
select, textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .85rem;
    font-family: var(--font);
    color: var(--text-primary);
    background: #fff;
    transition: border-color .13s, box-shadow .13s;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--moink-vermelho);
    box-shadow: 0 0 0 3px rgba(200,40,26,.1);
}

.form-hint { font-size: .71rem; color: var(--text-muted); margin-top: 3px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

/* --- Alertas --- */
.alert {
    padding: 11px 15px;
    border-radius: var(--radius);
    font-size: .85rem;
    margin-bottom: 18px;
    display: flex;
    align-items: flex-start;
    gap: 9px;
    border-left: 4px solid;
}
.alert ul { margin: 3px 0 0 15px; }
.alert-sucesso { background: #d1fae5; color: #065f46; border-color: var(--success); }
.alert-erro    { background: #fee2e2; color: #991b1b; border-color: var(--danger); }
.alert-aviso   { background: #fef3c7; color: #92400e; border-color: var(--warning); }
.alert-info    { background: #dbeafe; color: #1e40af; border-color: var(--info); }

/* --- Paginação --- */
.paginacao { display: flex; align-items: center; gap: 5px; justify-content: center; margin-top: 18px; }
.paginacao a, .paginacao span { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; border-radius: var(--radius); font-size: .8rem; font-weight: 500; color: var(--text-muted); border: 1px solid var(--border); transition: background .12s; }
.paginacao a:hover { background: var(--bg-page); color: var(--text-primary); }
.paginacao .atual { background: var(--moink-vermelho); color: #fff; border-color: var(--moink-vermelho); }

/* --- Login --- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--moink-preto);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(200,40,26,.15) 0%, transparent 70%);
    top: -200px; right: -200px;
    pointer-events: none;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(232,160,32,.08) 0%, transparent 70%);
    bottom: -100px; left: -100px;
    pointer-events: none;
}

.login-card {
    background: #1a1a1a;
    border-radius: 16px;
    padding: 40px 36px;
    width: 100%;
    max-width: 390px;
    box-shadow: 0 24px 64px rgba(0,0,0,.6);
    border: 1px solid rgba(255,255,255,.08);
    position: relative;
    z-index: 1;
}

.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo img { height: 40px; }
.login-logo-sub { font-size: .75rem; color: rgba(255,255,255,.35); margin-top: 8px; letter-spacing: .08em; text-transform: uppercase; }

.login-card label { color: rgba(255,255,255,.65); }

.login-card input {
    background: rgba(255,255,255,.07);
    border-color: rgba(255,255,255,.12);
    color: #fff;
}

.login-card input:focus {
    border-color: var(--moink-vermelho);
    box-shadow: 0 0 0 3px rgba(200,40,26,.2);
    background: rgba(255,255,255,.09);
}

.login-card input::placeholder { color: rgba(255,255,255,.25); }

.login-card .btn-primary {
    background: var(--moink-vermelho);
    width: 100%;
    justify-content: center;
    padding: 11px;
    font-size: .9rem;
}

.login-card .btn-primary:hover { background: var(--moink-vermelho-h); }

.login-hint { text-align: center; margin-top: 18px; font-size: .74rem; color: rgba(255,255,255,.25); }

/* --- Alerta da tela de login --- */
.login-card .alert-erro { background: rgba(220,38,38,.15); color: #fca5a5; border-color: var(--moink-vermelho); }

/* --- Empty state --- */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state-icon { font-size: 2.2rem; margin-bottom: 10px; opacity: .4; }
.empty-state p { font-size: .88rem; }

/* --- Utilitários --- */
.mt-1{margin-top:8px} .mt-2{margin-top:16px} .mt-3{margin-top:24px}
.mb-1{margin-bottom:8px} .mb-2{margin-bottom:16px} .mb-3{margin-bottom:24px}
.text-right{text-align:right} .text-center{text-align:center}
.text-muted{color:var(--text-muted)} .text-small{font-size:.78rem}
.text-danger{color:var(--danger)} .text-success{color:var(--success)}
.text-warning{color:var(--warning)} .text-red{color:var(--moink-vermelho)}
.d-flex{display:flex} .align-center{align-items:center}
.justify-between{justify-content:space-between}
.gap-1{gap:8px} .gap-2{gap:16px} .flex-1{flex:1} .w-100{width:100%}
.fw-bold{font-weight:700}

/* Tag de classificação de rota */
.tag-classe-a { background: #fef3c7; color: #92400e; padding: 2px 8px; border-radius: 4px; font-size: .69rem; font-weight: 700; }
.tag-classe-b { background: #dbeafe; color: #1e40af; padding: 2px 8px; border-radius: 4px; font-size: .69rem; font-weight: 700; }
.tag-classe-c { background: #f3f4f6; color: #4b5563; padding: 2px 8px; border-radius: 4px; font-size: .69rem; font-weight: 700; }

/* Barra de progresso de estoque */
.progress-bar-wrap { background: #f0ece6; border-radius: 4px; height: 7px; overflow: hidden; }
.progress-bar-fill { height: 7px; border-radius: 4px; background: var(--moink-dourado); transition: width .4s; }
.progress-bar-fill.danger { background: var(--moink-vermelho); }
.progress-bar-fill.ok { background: var(--success); }

/* ============================================================
   RESPONSIVO
   ============================================================ */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.aberta { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .btn-menu-mobile { display: flex; }
    .page-content { padding: 14px; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .charts-grid { grid-template-columns: 1fr; }
    .topbar { padding: 0 14px; }
}

@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .login-card { padding: 30px 22px; }
}

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 150; }
@media (max-width: 768px) { .sidebar-overlay.visivel { display: block; } }

/* ─── CSS de Impressão ──────────────────────────────────── */
@media print {
    .sidebar, .topbar, .btn, a[href*="export"], button,
    .nav-item, #sidebar, .sidebar-overlay,
    [onclick], [href*="javascript"] { display: none !important; }
    .main-content { margin-left: 0 !important; padding: 10px !important; }
    .kpi-card { border: 1px solid #ddd !important; break-inside: avoid; }
    .card { border: 1px solid #ddd !important; break-inside: avoid; page-break-inside: avoid; }
    .kpi-grid { grid-template-columns: repeat(3, 1fr) !important; }
    canvas { max-width: 100% !important; }
    body { font-size: 11px !important; color: #000 !important; background: #fff !important; }
    h1, h2, .card-title { color: #000 !important; }
    .kpi-valor { color: #000 !important; }
    @page { margin: 1.5cm; size: A4 landscape; }
}
