/* =====================================================================
   Sistema de Ordens de Serviço - Tecbios
   Estilos globais (mobile-first, responsivo)
   ===================================================================== */

:root {
    --azul: #2563eb;
    --azul-escuro: #1d4ed8;
    --cinza-900: #0f172a;
    --cinza-700: #334155;
    --cinza-500: #64748b;
    --cinza-200: #e2e8f0;
    --cinza-100: #f1f5f9;
    --branco: #ffffff;
    --verde: #16a34a;
    --vermelho: #dc2626;
    --amarelo: #d97706;
    --raio: 10px;
    --sombra: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--cinza-100);
    color: var(--cinza-900);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--azul); text-decoration: none; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }

/* ---------------------------------------------------------------------
   Topbar
   --------------------------------------------------------------------- */
.topbar {
    position: sticky; top: 0; z-index: 40;
    display: flex; align-items: center; gap: 12px;
    background: var(--cinza-900);
    color: var(--branco);
    padding: 0 14px;
    height: 56px;
}
.topbar-logo { color: var(--branco); font-weight: 700; font-size: 17px; flex: 1; }
.topbar-usuario { font-size: 13px; color: #cbd5e1; display: none; }
@media (min-width: 640px) { .topbar-usuario { display: inline; } }

.btn-icone {
    background: transparent; border: none; color: var(--branco);
    font-size: 22px; line-height: 1; cursor: pointer; padding: 6px 8px;
}

/* ---------------------------------------------------------------------
   Layout / Sidebar (off-canvas no mobile, fixa no desktop)
   --------------------------------------------------------------------- */
.layout { display: flex; min-height: calc(100vh - 56px); }

.sidebar {
    position: fixed; top: 56px; left: 0; bottom: 0;
    width: 250px;
    background: var(--branco);
    border-right: 1px solid var(--cinza-200);
    display: flex; flex-direction: column;
    padding: 10px 0;
    transform: translateX(-100%);
    transition: transform .2s ease;
    z-index: 45;
    overflow-y: auto;
}
.sidebar.aberta { transform: translateX(0); }

.sidebar a {
    color: var(--cinza-700);
    padding: 13px 20px;
    font-size: 15px;
    border-left: 3px solid transparent;
}
.sidebar a:hover { background: var(--cinza-100); }
.sidebar a.ativo { color: var(--azul); border-left-color: var(--azul); background: #eff6ff; font-weight: 600; }

.overlay {
    display: none;
    position: fixed; inset: 56px 0 0 0; z-index: 44;
    background: rgba(15, 23, 42, .4);
}
.overlay.ativo { display: block; }

.conteudo { flex: 1; padding: 16px; width: 100%; max-width: 100%; }

@media (min-width: 900px) {
    .sidebar { transform: translateX(0); }
    .overlay { display: none !important; }
    .conteudo { margin-left: 250px; padding: 24px 28px; }
    .btn-icone { display: none; }
}

/* ---------------------------------------------------------------------
   Cartões / Painel
   --------------------------------------------------------------------- */
.cartoes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}
.cartao {
    background: var(--branco);
    border-radius: var(--raio);
    box-shadow: var(--sombra);
    padding: 16px;
}
.cartao .rotulo { color: var(--cinza-500); font-size: 13px; margin-bottom: 4px; }
.cartao .valor { font-size: 24px; font-weight: 700; }

.painel {
    background: var(--branco);
    border-radius: var(--raio);
    box-shadow: var(--sombra);
    padding: 18px;
    margin-bottom: 18px;
}

.cabecalho-pagina {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 10px; margin-bottom: 16px;
}
.cabecalho-pagina h1 { font-size: 20px; }

/* ---------------------------------------------------------------------
   Botões
   --------------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 14px; font-weight: 600;
    cursor: pointer;
    background: var(--azul); color: var(--branco);
    text-decoration: none;
}
.btn:hover { background: var(--azul-escuro); }
.btn.secundario { background: var(--branco); color: var(--cinza-700); border-color: var(--cinza-200); }
.btn.secundario:hover { background: var(--cinza-100); }
.btn.perigo { background: var(--vermelho); }
.btn.perigo:hover { background: #b91c1c; }
.btn.pequeno { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------------------------------------------------------------------
   Formulários
   --------------------------------------------------------------------- */
.form-linha { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 14px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--cinza-700); margin-bottom: 5px; }
input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--cinza-200);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    background: var(--branco);
    color: var(--cinza-900);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--azul); outline-offset: 1px; }
textarea { resize: vertical; min-height: 80px; }
.campo-ajuda { font-size: 12px; color: var(--cinza-500); margin-top: 4px; }

/* ---------------------------------------------------------------------
   Tabelas (viram "cards" empilhados no celular)
   --------------------------------------------------------------------- */
.tabela-wrap { overflow-x: auto; }
table.dados { width: 100%; border-collapse: collapse; background: var(--branco); border-radius: var(--raio); overflow: hidden; }
table.dados th, table.dados td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--cinza-200); font-size: 14px; }
table.dados th { background: var(--cinza-100); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--cinza-500); }
table.dados tbody tr:hover { background: #f8fafc; }

@media (max-width: 720px) {
    table.dados thead { display: none; }
    table.dados, table.dados tbody, table.dados tr, table.dados td { display: block; width: 100%; }
    table.dados tr { background: var(--branco); border-radius: var(--raio); box-shadow: var(--sombra); margin-bottom: 12px; padding: 6px 0; }
    table.dados td { border-bottom: none; padding: 6px 14px; }
    table.dados td[data-rotulo]::before {
        content: attr(data-rotulo);
        display: block;
        font-size: 11px; text-transform: uppercase; color: var(--cinza-500); font-weight: 700;
        margin-bottom: 2px;
    }
}

/* ---------------------------------------------------------------------
   Badges de status
   --------------------------------------------------------------------- */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 700; color: var(--branco); white-space: nowrap;
}

/* ---------------------------------------------------------------------
   Alertas / flash messages
   --------------------------------------------------------------------- */
.alerta { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alerta-sucesso { background: #dcfce7; color: #166534; }
.alerta-erro { background: #fee2e2; color: #991b1b; }
.alerta-info { background: #dbeafe; color: #1e3a8a; }

/* ---------------------------------------------------------------------
   Login
   --------------------------------------------------------------------- */
.tela-login {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(160deg, var(--cinza-900), #1e293b);
    padding: 20px;
}
.caixa-login {
    background: var(--branco); border-radius: 14px; padding: 32px 28px;
    width: 100%; max-width: 380px; box-shadow: 0 20px 40px rgba(0,0,0,.25);
}
.caixa-login h1 { text-align: center; font-size: 20px; margin-bottom: 4px; }
.caixa-login .subtitulo { text-align: center; color: var(--cinza-500); font-size: 13px; margin-bottom: 22px; }
.caixa-login .btn { width: 100%; padding: 12px; margin-top: 6px; }

/* ---------------------------------------------------------------------
   Utilidades
   --------------------------------------------------------------------- */
.flex { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.flex-fim { justify-content: flex-end; }
.texto-fraco { color: var(--cinza-500); }
.texto-fim { text-align: right; }
.mt { margin-top: 16px; }
.mb0 { margin-bottom: 0; }
.tag-itens { list-style: none; padding: 0; margin: 0; }
.tag-itens li { padding: 8px 0; border-bottom: 1px dashed var(--cinza-200); display: flex; justify-content: space-between; gap: 8px; }
.busca-filtros { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.busca-filtros select, .busca-filtros input { width: auto; min-width: 150px; }

/* ---------------------------------------------------------------------
   Impressão (OS e Relatório Mensal)
   --------------------------------------------------------------------- */
.imprimir-apenas { display: none; }

@media print {
    .topbar, .sidebar, .overlay, .no-imprimir { display: none !important; }
    .conteudo { margin: 0 !important; padding: 0 !important; }
    body { background: var(--branco); }
    .painel { box-shadow: none; padding: 0; }
    .imprimir-apenas { display: block; margin-bottom: 12px; }
}
