/* =========================================================
   CAMPO DO GADO — STYLE.CSS FINAL (PARTE 1/3)
   Layout restaurado + tabelas antigas + sidebar + topbar
   ========================================================= */

/* ROOT VARIABLES */
:root {
    --bg: #f3f7f4;
    --green-900: #0b5e33;
    --green-800: #1b7f42;
    --green-700: #0d542c;
    --green-500: #198754;
    --muted: #e9f5ee;
    --card: #ffffff;
    --shadow: 0 8px 28px rgba(9, 34, 18, 0.06);
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --red: #d62828;
}

/* RESET */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
    width: 100%;
    min-height: 100%;
    font-family: "Inter", sans-serif;
    background: var(--bg);
    color: #083b1d;
}

/* GLOBAL CONTAINER */
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }

/* =========================================================
   SIDEBAR BUTTON (LOGO BOLA VERDE)
   ========================================================= */
.menu-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    background: #0b5727;
    color: white;
    border: none;
    padding: 10px 14px;
    font-size: 26px;
    border-radius: 8px;
    cursor: pointer;
    z-index: 999;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

.menu-toggle:hover {
    background: #0a4a22;
}


/* =========================================================
   SIDEBAR
   ========================================================= */
.sidebar {
    position: fixed;
    top: 20px;
    left: -340px;
    width: 320px;
    height: calc(100vh - 40px);
    background: linear-gradient(180deg, var(--green-900), var(--green-800));
    color: #fff;
    padding: 26px 20px;
    border-radius: 18px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.16);
    transition: left .36s cubic-bezier(.22, .9, .25, 1);
    z-index: 3000;
}
.sidebar.open { left: 20px; }

.logo-area { display: flex; align-items: center; gap: 12px; }
.logo {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border-radius: 12px;
    padding: 6px;
    background: rgba(255, 255, 255, .06);
}

.menu {
    list-style: none;
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    text-decoration: none;
    color: #fff;
    border-radius: 12px;
    font-weight: 700;
    transition: .16s;
}
.menu a:hover { background: rgba(255, 255, 255, .10); transform: translateX(6px); }
.menu a.active { background: rgba(255, 255, 255, .18); }

/* =========================================================
   TOP BAR SUPERIOR (PESQUISA + USUÁRIO)
   ========================================================= */
.top-bar {
    width: calc(100% - 40px);
    margin: 20px auto;
    padding: 14px 22px;
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.top-title { font-size: 20px; font-weight: 800; color: var(--green-900); }

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.search-box {
    display: flex;
    align-items: center;
    background: #f3f7f4;
    padding: 6px 10px;
    border-radius: 12px;
    border: 1px solid #cde7d7;
}
.search-box input {
    border: none;
    background: transparent;
    outline: none;
    width: 150px;
}
.search-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 16px;
    color: var(--green-900);
}

.user-box {
    background: #e8f5ee;
    padding: 8px 14px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    color: var(--green-900);
    border: 1px solid #cde7d7;
}

/* =========================================================
   MAIN CONTENT
   ========================================================= */
.main-content {
    padding: 34px;
    transition: margin-left .36s;
}
.main-content.menu-open { margin-left: 420px; }

/* TITULOS */
.page-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 26px;
    font-weight: 800;
    margin-bottom: 18px;
    color: var(--green-900);
}

/* =========================================================
   CARD PADRÃO
   ========================================================= */
.card {
    background: #ffffff;
    padding: 18px;
    border-radius: 14px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}
/* =========================================================
   TABELAS — VISUAL RESTAURADO (estrutura antiga)
   ========================================================= */

.tabela {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.tabela th {
    background: #e9f5ee;
    font-weight: 700;
    text-align: left;
    padding: 10px 14px;
    font-size: 14px;
    color: #0d4d2c;
}

.tabela td {
    padding: 10px 14px;
    font-size: 14px;
    vertical-align: middle !important;
    border-bottom: 1px solid #f0f7f2;
}

.tabela tr:nth-child(even) {
    background: #f8fdf9;
}

.tabela tr:hover {
    background: #eefaf2;
}

/* Miniatura da foto */
.thumb {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #d0ead9;
    display: block;
}


/* =================================================================
   BOTÕES DE AÇÕES — VISUAL ANTIGO (pequenos, coloridos vertical)
   ================================================================= */

.actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: center;
}

.action-btn {
    width: 60px;
    height: 50px;
    padding: 6px 4px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    transition: .15s;
}

.action-btn:hover {
    transform: translateY(-3px);
    opacity: .9;
}

.action-btn i {
    font-size: 14px;
}

/* Botões coloridos */
.btn-edit  { background: #198754; }
.btn-qr    { background: #0d6efd; }
.btn-hist  { background: #6c757d; }
.btn-corr  { background: #78c2a5; color: #083b1d; }
.btn-del   { background: #d62828; }

/* =================================================================
   FORMULÁRIOS — ALINHAMENTO PADRÃO DO SISTEMA
   ================================================================= */

.formulario label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
    color: #0b4b2a;
}

.formulario input,
.formulario select,
.formulario textarea {
    width: 100%;
    display: block;
    padding: 12px 14px;
    margin-bottom: 12px;
    border-radius: 10px;
    border: 1px solid #d7efe0;
    background: #f7fff8;
    font-size: 15px;
}

/* Grid automático para campos lado a lado */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
}

/* Inputs de arquivo */
.formulario input[type="file"] {
    padding: 6px;
    background: transparent;
    border: none;
}

/* Card de formulário */
.card.form-card {
    padding: 20px;
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--shadow);
}

/* Botão de salvar */
.btn-full {
    width: 100%;
    justify-content: center;
}

/* =================================================================
   BOTÕES PADRÃO
   ================================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: .2s;
}

.btn-verde-claro {
    background: var(--green-800);
    color: white;
}
.btn-verde-claro:hover {
    background: var(--green-900);
}

.btn-verde-escuro {
    background: var(--green-700);
    color: white;
}

.btn-cinza-escuro {
    background: #6c757d;
    color: white;
}
.btn-cinza-escuro:hover {
    background: #565e63;
}

/* Botões menores do PDF e relatórios */
.relatorio-actions {
    display: flex;
    gap: 14px;
    margin-top: 14px;
}

/* =================================================================
   COMPONENTES EXTRAS (alertas, caixas, empty states)
   ================================================================= */

.alert-error {
    background: #f5c4c4;
    padding: 10px;
    border-left: 6px solid #b30000;
    color: #8a0000;
    border-radius: 8px;
    margin-bottom: 14px;
}

.empty {
    text-align: center;
    padding: 14px;
    color: #777;
    font-style: italic;
}

/* Caixa de voltar */
.voltar-box {
    margin-top: 14px;
}
/* =========================================================
   RESPONSIVIDADE — AJUSTES GERAIS
   ========================================================= */

@media (max-width: 900px) {

    .menu-toggle {
        top: 14px;
        left: 14px;
        width: 58px;
        height: 58px;
    }

    .sidebar {
        left: -100%;
        width: 82%;
        max-width: 340px;
    }

    .sidebar.open {
        left: 12px;
    }

    .main-content.menu-open {
        margin-left: 0 !important;
        filter: blur(2px);
    }

    .top-bar {
        width: calc(100% - 20px);
    }
}


@media (max-width: 600px) {

    .page-title {
        font-size: 22px;
        justify-content: center;
    }

    .actions {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px;
    }

    .tabela th,
    .tabela td {
        font-size: 13px;
        padding: 8px;
    }

    .thumb {
        width: 65px;
        height: 52px;
    }

    .search-box input {
        width: 100px;
    }
}

/* =========================================================
   FOOTER
   ========================================================= */
footer {
    text-align: center;
    margin-top: 40px;
    margin-bottom: 20px;
    font-size: 12px;
    color: #666;
}

/* =========================================================
   AJUSTES FINAIS / RESTAURAÇÃO DE COMPATIBILIDADE
   ========================================================= */

/* Prevenir imagens de quebrarem o layout */
td img, .tabela td img {
    max-width: 120px;
    max-height: 90px;
    object-fit: cover;
}

/* Garantir que cards e tabelas não estourem largura */
.tabela-card {
    overflow-x: auto;
}

.card.tabela-card {
    overflow-x: auto;
    overflow-y: visible;
}

/* Estilo para tags de quantidade (estoque) */
.tag {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 13px;
    color: white;
}

.tag.verde-escuro {
    background: var(--green-700);
}

/* Pequeno efeito suave */
.smooth {
    transition: all 0.22s ease;
}

/* Estado “empty” */
.empty {
    text-align: center;
    padding: 12px;
    font-size: 13px;
    color: #888;
    font-style: italic;
}
/* Grid de métricas (4 cards lado a lado em desktop) */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}

.metric-card { padding: 18px; border-radius: 12px; box-shadow: var(--shadow); background: var(--card); }
.metric-card h3 { margin-bottom: 8px; font-size: 16px; color: var(--green-900); }
.metric-value { font-size: 22px; font-weight:700; color:var(--green-900); }

/* responsivo: empilha em telas pequenas */
@media (max-width: 1000px) {
  .grid-cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .grid-cards { grid-template-columns: 1fr; }
}

/* ================================
   GRÁFICOS LADO A LADO
=================================== */

.charts-wrapper {
    display: flex;
    gap: 20px;
    width: 100%;
}

.chart-small {
    flex: 1;
    height: 380px;
}

.chart-small canvas {
    width: 100% !important;
    height: 300px !important;
}

/* Responsivo */
@media (max-width: 900px) {
    .charts-wrapper {
        flex-direction: column;
    }

    .chart-small {
        height: 360px;
    }
}
/* GRÁFICOS LADO A LADO */
.chart-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

/* Canvas nítido */
.chart-card canvas {
    width: 100% !important;
    height: auto !important;
    max-width: 520px;
    max-height: 320px;
    margin: 0 auto;
    display: block;
}
/* =============================
   CORREÇÃO TABELA EQUIPAMENTOS
   ============================= */

/* Reduz a altura geral da tabela */
.tabela td {
    padding: 6px 10px !important;
    font-size: 14px !important;
}

/* FOTO compacta */
.tabela .thumb,
td img {
    width: 70px !important;
    height: 55px !important;
    object-fit: cover !important;
    border-radius: 6px;
    border: 2px solid #0f5132;
}

/* Linha mais compacta */
.tabela tr {
    height: 68px !important;
}

/* Botões de ação em linha (horizontal) */
.actions {
    display: flex !important;
    flex-direction: row !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 8px !important;
}

/* Todos os botões ficam menores */
.action-btn {
    width: 45px !important;
    height: 40px !important;
    border-radius: 8px !important;
    font-size: 12px !important;
    padding: 0 !important;
}

.action-btn span {
    font-size: 11px !important;
}

/* Ajuste de coluna de ações */
td.acoes-col {
    width: 260px !important;
    text-align: center !important;
}

/* Nome, modelo, localização compactos */
.tabela td:nth-child(3),
.tabela td:nth-child(4),
.tabela td:nth-child(5) {
    font-size: 14px !important;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
