@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Outfit:wght@500;600;700&display=swap');

:root {
    --bg: #f8fafc;
    --card: #ffffff;
    --texto: #0f172a;
    --suave: #64748b;
    --linha: #e2e8f0;
    --primaria: #f97316;
    --primaria-escura: #ea580c;
    --primaria-suave: #fff7ed;
    --primaria-border: #ffedd5;
    --ok: #16a34a;
    --ok-bg: #dcfce7;
    --erro: #ef4444;
    --erro-bg: #fee2e2;
    --destaque: #f59e0b;
    --radius: 12px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--texto);
    font: 14px/1.5 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- Estrutura do App (Sidebar + Conteúdo) ---------- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: #ffffff;
    border-right: 1px solid var(--linha);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 50;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--linha);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--texto);
    text-decoration: none;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.02em;
}

.brand-logo-icon {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: #fff;
    border-radius: 12px;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    font-size: 18px;
    box-shadow: 0 4px 10px rgba(249, 115, 22, 0.3);
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-text .title-main {
    font-size: 15px;
    color: #334155;
    font-weight: 500;
}

.brand-text .title-highlight {
    font-size: 18px;
    color: var(--primaria);
    font-weight: 700;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.sidebar-nav a {
    color: var(--suave);
    text-decoration: none;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
}

.sidebar-nav a:hover {
    background: #f8fafc;
    color: var(--texto);
}

.sidebar-nav a.ativo {
    background: var(--primaria-suave);
    color: var(--primaria);
    font-weight: 600;
}

.sidebar-nav a svg {
    width: 20px;
    height: 20px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--linha);
    background: #fafafa;
}

.usuario-logado {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.usuario-info {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.usuario-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primaria-suave);
    color: var(--primaria);
    display: grid;
    place-items: center;
    font-weight: 600;
    font-size: 14px;
    border: 1px solid var(--primaria-border);
    flex-shrink: 0;
}

.usuario-detalhes {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.usuario-nome {
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.usuario-papel {
    font-size: 11px;
    color: var(--suave);
    text-transform: capitalize;
}

.btn-sair {
    color: var(--suave);
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-sair:hover {
    background: #fee2e2;
    color: #ef4444;
}

/* Área Principal */
.main-content {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: calc(100% - 260px);
}

.mobile-header {
    display: none;
    background: #ffffff;
    border-bottom: 1px solid var(--linha);
    padding: 14px 20px;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 40;
}

.mobile-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--texto);
    padding: 6px;
    border-radius: 8px;
    display: flex;
}

.mobile-toggle:hover {
    background: #f1f5f9;
}

.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 24px; }
main.wrap { padding-top: 32px; padding-bottom: 48px; flex: 1; }

/* ---------- Títulos ---------- */
.cabecalho-pagina { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 24px; flex-wrap: wrap; }
h1 { font-size: 24px; margin: 0; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 18px; margin: 0 0 16px; font-weight: 600; letter-spacing: -0.01em; }
.sub { color: var(--suave); font-size: 14px; margin: 6px 0 0; }

/* ---------- Cards ---------- */
.card {
    background: var(--card); border: 1px solid var(--linha);
    border-radius: var(--radius); padding: 24px; margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* ---------- Indicadores ---------- */
.kpi { 
    background: var(--card); border: 1px solid var(--linha); 
    border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; justify-content: center;
}
.kpi .rotulo { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--suave); display: flex; align-items: center; gap: 8px;}
.kpi .valor { font-size: 26px; font-weight: 700; margin-top: 8px; letter-spacing: -0.02em;}
.kpi .valor.positivo { color: var(--ok); }
.kpi .valor.negativo { color: var(--erro); }

/* ---------- Formulários ---------- */
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: #334155; }
input[type=text], input[type=number], input[type=date], input[type=email],
input[type=password], input[type=file], input[type=url], select, textarea {
    width: 100%; padding: 10px 14px; border: 1px solid var(--linha);
    border-radius: 8px; font: inherit; background: #fff; color: inherit;
    transition: all 0.2s; box-shadow: var(--shadow-sm);
}
input:focus, select:focus, textarea:focus { 
    outline: none; border-color: var(--primaria); 
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15); 
}
textarea { min-height: 80px; resize: vertical; }
.campo { margin-bottom: 18px; }
.dica { font-size: 13px; color: var(--suave); margin-top: 6px; }
.linha-check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.linha-check input { width: auto; box-shadow: none; accent-color: var(--primaria); width: 16px; height: 16px;}
.acoes-form { display: flex; gap: 12px; align-items: center; margin-top: 24px; }

.linha-filamento { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.linha-filamento select { flex: 1 1 auto; min-width: 0; }
.linha-filamento input { flex: 0 0 120px; }

/* ---------- Botões ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px; border-radius: 8px; border: 1px solid transparent;
    background: var(--primaria); color: #fff; font: inherit; font-weight: 600;
    cursor: pointer; text-decoration: none; line-height: 1.3;
    transition: all 0.2s; box-shadow: var(--shadow-sm); font-size: 14px;
}
.btn:hover { background: var(--primaria-escura); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn svg { width: 18px; height: 18px; }

.btn-sec { background: #fff; color: var(--texto); border-color: var(--linha); }
.btn-sec:hover { background: #f8fafc; color: var(--texto); }

.btn-perigo { background: #fff; color: var(--erro); border-color: var(--linha); }
.btn-perigo:hover { background: var(--erro-bg); border-color: #fca5a5; }

.btn-mini { padding: 6px 12px; font-size: 13px; }

/* ---------- Tabelas ---------- */
.tabela-scroll { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--linha); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--linha); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--suave); background: #f8fafc; font-weight: 600; }
tbody tr { transition: background 0.15s; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; }
.forte { font-weight: 600; color: var(--texto); }
.forte a { color: var(--primaria); text-decoration: none; }
.forte a:hover { text-decoration: underline; }
.preco { font-weight: 600; color: var(--ok); }
.vazio { padding: 32px; text-align: center; color: var(--suave); }

/* ---------- Foto do produto ---------- */
.foto-mini {
    width: 48px; height: 48px; border-radius: 10px; object-fit: cover;
    border: 1px solid var(--linha); background: #f1f5f9; vertical-align: middle;
}
.foto-placeholder-mini {
    width: 48px; height: 48px; border-radius: 10px; border: 1px dashed #cbd5e1;
    background: #f8fafc; display: inline-flex; align-items: center; justify-content: center;
    color: var(--suave); font-size: 11px; text-align: center; vertical-align: middle;
}
.foto-grande {
    width: 100%; max-width: 320px; border-radius: var(--radius);
    border: 1px solid var(--linha); object-fit: cover; display: block; margin-bottom: 20px;
    box-shadow: var(--shadow-md);
}
.foto-placeholder-grande {
    width: 100%; max-width: 320px; aspect-ratio: 1 / 1; border-radius: var(--radius);
    border: 2px dashed var(--linha); background: #f8fafc; display: flex;
    align-items: center; justify-content: center; color: var(--suave); font-size: 14px; font-weight: 500;
    margin-bottom: 20px;
}
.galeria-miniaturas {
    display: flex; gap: 10px; flex-wrap: wrap; margin: -12px 0 20px;
}
.foto-mini-galeria {
    width: 72px; height: 72px; border-radius: 10px; object-fit: cover;
    border: 1px solid var(--linha); background: #f1f5f9;
}
.galeria-fotos-form {
    display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px;
}
.foto-form-item {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.foto-form-item img {
    width: 72px; height: 72px; border-radius: 10px; object-fit: cover;
    border: 1px solid var(--linha); background: #f1f5f9;
}
.foto-form-remover {
    display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--suave); font-weight: 400;
}

/* ---------- Etiquetas ---------- */
.tag {
    display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600; background: var(--primaria-suave); color: var(--primaria-escura);
}
.tag-off { background: #f1f5f9; color: var(--suave); }
.tag-status-criado { background: var(--primaria-suave); color: var(--primaria-escura); }
.tag-status-pronto { background: #fef3c7; color: #92400e; }
.tag-status-entregue { background: var(--ok-bg); color: #166534; }

/* ---------- Processo do pedido (Stepper) ---------- */
.processo { display: flex; align-items: center; }
.processo-etapa {
    width: 14px; height: 14px; border-radius: 50%; background: #e2e8f0; flex-shrink: 0;
    position: relative; z-index: 2; transition: all 0.3s;
}
.processo-etapa.ativa { background: var(--ok); }
.processo-etapa.atual { box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.2); }
.processo-linha { width: 24px; height: 3px; background: #e2e8f0; position: relative; z-index: 1; transition: all 0.3s;}
.processo-linha.ativa { background: var(--ok); }

/* ---------- Alertas ---------- */
.alerta { padding: 14px 18px; border-radius: 10px; margin-bottom: 24px; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 10px; border: 1px solid; }
.alerta svg { width: 20px; height: 20px; flex-shrink: 0; }
.alerta-ok { background: var(--ok-bg); border-color: #bbf7d0; color: #166534; }
.alerta-erro { background: var(--erro-bg); border-color: #fecaca; color: #991b1b; }

/* ---------- Resumo de cálculo ---------- */
.resumo { background: #f8fafc; border: 1px solid var(--linha); border-radius: var(--radius); padding: 20px; }
.resumo dl { margin: 0; }
.resumo .item { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px dashed #cbd5e1; font-size: 14px; }
.resumo .item:last-child { border-bottom: 0; }
.resumo .item dt { color: var(--suave); font-weight: 500; }
.resumo .item dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--texto); }
.resumo .total { border-top: 2px solid var(--linha); margin-top: 10px; padding-top: 16px; font-size: 16px; }
.resumo .total dd { font-weight: 700; }
.resumo .final dd { color: var(--ok); font-size: 22px; font-weight: 700; }

.rodape { padding: 24px 0; border-top: 1px solid var(--linha); margin-top: auto; color: var(--suave); font-size: 13px; text-align: center; }

/* ---------- Responsividade ---------- */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    .mobile-header {
        display: flex;
    }
}

@media (max-width: 640px) {
    .cabecalho-pagina { flex-direction: column; align-items: flex-start; }
    h1 { font-size: 20px; }
    .grid-2, .grid-4 { grid-template-columns: 1fr; }
}

/* Utilities */
.text-center { text-align: center; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.flex-col { flex-direction: column; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.w-full { width: 100%; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
