/* ========== VARIÁVEIS ========== */
:root {
  --primary: #ad4200;
  --primary-dark: #181818;
  --primary-light: #42A5F5;
  --accent: #FF6F00;
  --success: #4CAF50;
  --error: #E53935;
  --bg: #F5F5F5;
  --text: #212121;
  --text-secondary: #757575;
  --sidebar-width: 240px;
}

body { background: var(--bg) url('../img/menu/BACKGROUND.jpg') repeat-x center top / 100% auto; font-family: 'Segoe UI', system-ui, sans-serif; margin: 0; }
.page { min-height: 100vh; }

/* ========== LOGIN ========== */
.login-bg {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary), var(--primary-light));
}
.login-card { width: 100%; max-width: 400px; padding: 20px; text-align: center; }
.login-logo {
  width: 90px; height: 90px; border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0,0,0,.2);
  margin-bottom: 12px;
}

/* ========== NAVBAR ========== */
.bg-primary { background-color: var(--primary) !important; }
.navbar-brand img { box-shadow: 0 2px 6px rgba(0,0,0,.2); }

/* ========== SIDEBAR ========== */
.sidebar {
  width: var(--sidebar-width); height: calc(100vh - 56px);
  flex-shrink: 0;
  background: #fff; border-right: 1px solid #e0e0e0;
  overflow-y: auto; transition: transform .25s;
  position: sticky; top: 56px;
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; color: var(--text); font-size: 14px;
  text-decoration: none; border-radius: 0; transition: all .15s;
  cursor: pointer;
}
.sidebar-link:hover { background: #fff0e4; color: var(--primary); }
.sidebar-link.active { background: #fff0e4; color: var(--primary); font-weight: 600; border-left: 3px solid var(--primary); }
.sidebar-link i { font-size: 18px; width: 22px; text-align: center; }

/* Mobile sidebar */
@media (max-width: 767px) {
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 1050;
    height: 100vh; transform: translateX(-100%);
    box-shadow: 4px 0 20px rgba(0,0,0,.15);
  }
  .sidebar.show { transform: translateX(0); }
  .sidebar-overlay {
    display: none; position: fixed; inset: 0; z-index: 1040;
    background: rgba(0,0,0,.4);
  }
  .sidebar-overlay.show { display: block; }
}
@media (min-width: 768px) {
  .sidebar-overlay { display: none !important; }
}

/* ========== MAIN CONTENT ========== */
.main-content { min-height: calc(100vh - 56px); overflow-x: hidden; max-width: 100vw; min-width: 0; }

/* Background global em todas as páginas — aplicado no body para cobrir toda a rolagem */
#content-area {
  min-height: calc(100vh - 56px);
  padding: 16px;
  /* Espaço extra no final para a barra de navegação do celular não cobrir o conteúdo */
  padding-bottom: calc(max(16px, env(safe-area-inset-bottom, 0px)) + 80px);
  background: transparent;
}
/* Cards e containers sobre o background — fundo semi-transparente */
#content-area .card { background: rgba(255,255,255,0.93) !important; }
#content-area .table-container { background: rgba(255,255,255,0.93) !important; }

/* ========== RESPONSIVIDADE GLOBAL ========== */
html, body { overflow-x: hidden; max-width: 100vw; }
#page-app { overflow-x: hidden; }
.main-content .p-3, .main-content .p-md-4 { max-width: 100%; overflow-x: auto; }
@media (max-width: 767px) {
  .main-content { padding: 0; }
  #content-area { padding: 24px 16px !important; max-width: 100vw; box-sizing: border-box; overflow-x: hidden; }
  #content-area * { max-width: 100%; box-sizing: border-box; }
  .card { max-width: 100% !important; overflow: hidden !important; word-break: break-word; }
  .card-body { padding: 10px !important; overflow: hidden; }
  table { font-size: 11px; }
  .table-container { padding: 10px; overflow-x: auto; }
  .home-header { border-radius: 6px; margin: 0; width: 100%; }
  /* Forçar flex-wrap em todos os flex containers dentro de cards */
  .card .d-flex { flex-wrap: wrap !important; }
  /* EXCEÇÃO: cabeçalho dos cards de perfil/acessório/vidro não quebra —
     a lixeira/seta ficam fixas à direita e só o texto interno é responsivo. */
  .card .srv-card-head { flex-wrap: nowrap !important; }
  .card .srv-card-head .srv-card-acoes { flex-wrap: nowrap !important; flex-shrink: 0 !important; }
  /* Grid de valores: 2 colunas no mobile */
  div[style*="grid-template-columns:1fr 1fr 1fr 1fr"] { grid-template-columns: 1fr 1fr !important; gap: 4px !important; }
  div[style*="grid-template-columns:1fr 1fr 1fr 1fr 1fr"] { grid-template-columns: 1fr 1fr 1fr !important; gap: 4px !important; }
  /* DataTables responsivo */
  .dataTables_wrapper { overflow-x: auto; max-width: 100vw; }
  .dataTables_wrapper .row { margin: 0; }
  .dataTables_wrapper .dataTables_filter, .dataTables_wrapper .dataTables_length { float: none !important; text-align: left !important; margin-bottom: 8px; }
  /* Navbar compacta */
  .navbar-brand span { font-size: 14px; }
  .navbar .btn-sm { font-size: 11px; padding: 4px 8px; }
  /* Imagem tipologia menor no mobile */
  div[style*="width:80px;height:70px"] { width: 50px !important; height: 44px !important; }
  div[style*="width:80px;height:70px"] img { max-width: 48px !important; max-height: 42px !important; }
  /* Total e Qtd: não ultrapassar */
  div[style*="flex-shrink:0;text-align:right"] { flex-shrink: 1 !important; min-width: 0 !important; }
  /* Fontes menores nos cards */
  .card strong[style*="font-size:14px"] { font-size: 13px !important; }
  .card .fw-bold[style*="font-size:14px"] { font-size: 12px !important; }
}

/* ========== HOME CARDS ========== */
.home-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 6px; padding: 24px; color: #fff; margin-bottom: 24px;
}
.menu-card {
  border: none; border-radius: 6px; transition: transform .15s, box-shadow .15s;
  cursor: pointer; text-align: center; padding: 20px 12px;
}
.menu-card:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.menu-card .icon-wrap {
  width: 56px; height: 56px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px; font-size: 28px;
}
.menu-card h6 { font-size: 13px; font-weight: 600; margin: 0; color: var(--text); }

/* ========== TABELAS ========== */
.table-container { background: #fff; border-radius: 6px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.dataTables_wrapper .dataTables_filter input { border-radius: 4px; }
.dataTables_wrapper .dataTables_length select { border-radius: 4px; }
table.dataTable tbody tr:hover { background: #fff0e4 !important; }
.thumb-img { width: 36px; height: 36px; object-fit: contain; border-radius: 0; background: #f5f5f5; }

/* ========== FORMULÁRIOS ========== */
.form-card { background: rgba(255,255,255,0.93); border-radius: 6px; padding: 24px; box-shadow: 0 2px 8px rgba(0,0,0,.08); }

/* ========== BOTÕES ========== */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: #E65100; border-color: #E65100; color: #fff; }

/* ========== LOADING ========== */
.loading-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(255,255,255,.8); display: flex;
  align-items: center; justify-content: center;
}

/* ========== UTILITIES ========== */
.text-primary { color: var(--primary) !important; }
.bg-primary-light { background: #fff0e4; }
.rounded-12 { border-radius: 6px; }
.gap-12 { gap: 12px; }


/* ========== SCROLL AO TOPO NA PAGINAÇÃO ========== */
.dataTables_wrapper .dataTables_paginate .paginate_button {
  cursor: pointer;
}

/* ========== AUTOCOMPLETE (Serviços - Perfis/Acessórios) ========== */
.ac-item:hover {
  background: #fff0e4 !important;
}
.ac-item:active {
  background: #ffdfc5 !important;
}
#ac-list-ac-perfil-0, #ac-list-ac-acess-cod-0,
[id^="ac-list-"] {
  scrollbar-width: thin;
}
[id^="ac-list-"]::-webkit-scrollbar {
  width: 6px;
}
[id^="ac-list-"]::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

/* ========== LABEL DOS CARDS DO MENU — DESKTOP MAIOR ========== */
@media (min-width: 768px) {
  .menu-card-label { font-size: 13px !important; line-height: 1.3 !important; }
}
