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

:root {
  --bg-color: #f8fafc; /* Fundo principal cinza muito claro */
  --panel-bg: #ffffff; /* Fundo dos cartões e painel lateral */
  --text-main: #0f172a; /* Texto escuro principal */
  --text-muted: #64748b; /* Texto secundário */
  --primary: #2563eb; /* Azul padrão corporativo/gov */
  --primary-hover: #1e40af; /* Azul mais escuro no hover */
  --secondary: #e2e8f0; /* Cor secundária leve (botão voltar) */
  --accent: #dc2626; /* Vermelho para deletar/erros */
  --success: #16a34a; /* Verde para sucesso/adicionar */
  --border: #cbd5e1; /* Cor de bordas */
  --glass: rgba(255, 255, 255, 0.95); /* Fundo do login translúcido claro */
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  text-decoration: none;
  color: var(--primary);
  transition: 0.2s;
}
a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* Auth Pages */
.auth-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: var(--bg-color);
}

.auth-box {
  background: var(--panel-bg);
  padding: 2.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: var(--shadow);
}

.auth-box h1 {
  margin-bottom: 2rem;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-main);
}

.form-group {
  margin-bottom: 1.2rem;
  text-align: left;
}
.form-group label {
  font-weight: 500;
  color: var(--text-main);
  font-size: 0.9rem;
  display: block;
  margin-bottom: 0.3rem;
}

.form-control, select, textarea {
  width: 100%;
  padding: 10px 14px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-control[readonly], input[readonly] {
  background-color: #f1f5f9 !important;
  color: var(--text-muted) !important;
}

.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: center;
  transition: background 0.2s;
}

.btn:hover {
  background: var(--primary-hover);
  text-decoration: none;
  color: #fff;
}

.btn[style*="var(--secondary)"] {
  background: var(--secondary) !important;
  color: var(--text-main) !important;
  border: 1px solid var(--border) !important;
}
.btn[style*="var(--secondary)"]:hover {
  background: #cbd5e1 !important;
  border-color: #cbd5e1 !important;
}

/* Dashboard Layout */
.dashboard {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 260px;
  background: var(--panel-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 1.5rem;
  font-size: 1.3rem;
  font-weight: 700;
  text-align: center;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
}
.sidebar-brand span { font-weight: 400; opacity: 0.9; }

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}

.sidebar-nav a {
  display: block;
  padding: 0.8rem 1.5rem;
  color: var(--text-main);
  font-weight: 500;
  border-left: 4px solid transparent;
  font-size: 0.95rem;
}

.sidebar-nav a:hover, .sidebar-nav a.active {
  background: #f1f5f9;
  border-left-color: var(--primary);
  text-decoration: none;
  color: var(--primary);
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-color);
  overflow-y: auto;
}

.topbar {
  height: 60px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  font-size: 0.95rem;
}

.content {
  padding: 2rem;
}

.content h2 { margin-bottom: 1.5rem; color: var(--text-main); font-weight: 600; font-size: 1.5rem; }
.content h3 { font-size: 1.1rem; font-weight: 600; color: var(--text-main); }

.card {
  background: #f0f7ff; /* Azul muito claro */
  border-radius: 8px;
  padding: 1.5rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* Grid & Utilities */
.grid { display: grid; gap: 1.5rem; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

.text-danger { color: var(--accent); }
.text-success { color: var(--success); }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }

/* Tabelas padrão */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--border); text-align: left; }
th { font-weight: 600; color: var(--text-muted); background: #f8fafc; font-size: 0.9rem; border-top: 1px solid var(--border); }
tbody tr:hover { background: #f8fafc; }

/* Modais e Tabelas Dinâmicas */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(15, 23, 42, 0.4); backdrop-filter: none; }
.modal-content { background-color: var(--panel-bg); margin: 8% auto; padding: 25px; border: 1px solid var(--border); border-radius: 8px; width: 90%; max-width: 450px; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); }
.close-modal { color: var(--text-muted); float: right; font-size: 24px; font-weight: normal; cursor: pointer; }
.close-modal:hover { color: var(--accent); }

.table-sm { margin-top: 10px; font-size: 0.9rem; }
.table-sm th, .table-sm td { padding: 8px 10px; }
.btn-sm { padding: 6px 10px; font-size: 0.85rem; border-radius: 4px; }

/* Status Button Group */
.status-btn-group { display: flex; gap: 8px; margin-top: 5px; flex-wrap: wrap; }
.status-btn-group input[type="radio"] { display: none; }
.status-btn-group .status-btn { flex: 1; text-align: center; padding: 10px; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text-muted); cursor: pointer; font-weight: 500; transition: all 0.2s; font-size: 0.9rem; min-width: 120px; }
.status-btn-group .status-btn:hover { background: #f8fafc; }
.status-btn-group input[value="pendente"]:checked + .status-btn { background: #fef9c3; color: #854d0e; border-color: #eab308; }
.status-btn-group input[value="atendida"]:checked + .status-btn { background: #dcfce7; color: #166534; border-color: #22c55e; }
.status-btn-group input[value="cancelada"]:checked + .status-btn { background: #fee2e2; color: #991b1b; border-color: #ef4444; }

/* ================= RESPONSIVIDADE E MOBILE ================= */
@media (max-width: 1024px) {
  .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  /* Transformar Menu Lateral em Menu Superior Scrollável */
  .dashboard { flex-direction: column; height: auto; min-height: 100vh; overflow: auto; }
  .sidebar { width: 100%; height: auto; border-right: none; border-bottom: 2px solid var(--border); }
  .sidebar-brand { padding: 1rem; font-size: 1.2rem; }
  .sidebar-nav { display: flex; flex-wrap: wrap; overflow-x: auto; padding: 0; margin-bottom: 5px; -webkit-overflow-scrolling: touch; }
  .sidebar-nav a { flex: 1 1 auto; justify-content: center; padding: 12px 15px; border-left: none; border-bottom: 3px solid transparent; font-size: 0.9rem; }
  .sidebar-nav a:hover, .sidebar-nav a.active { border-left-color: transparent; border-bottom-color: var(--primary); background: transparent; }
  
  /* Conteudo e Topbar */
  .main-content { overflow: visible; }
  .topbar { padding: 10px; height: auto; flex-direction: column; gap: 5px; text-align: center; font-size: 0.85rem; }
  .content { padding: 1rem; }
  
  /* Desempilhar Grids para 1 Coluna em Telas Pequenas */
  .grid-cols-4, .grid-cols-3, .grid-cols-2 { grid-template-columns: 1fr; }
  
  /* Ajuste de Box Model dos Cards */
  .card { padding: 1rem; overflow-x: auto; }
  
  /* Tabelas ficam arrastáveis pro lado (Swipe) exceto listagens curtas */
  table:not(.table-sm) { width: 100%; min-width: 650px; }
  
  /* Listagens pequenas (Serviços e Peças / table-sm) */
  .table-sm, .table-sm tbody { display: block; width: 100%; }
  .table-sm thead { display: none; }
  .table-sm tr { 
      display: flex; 
      flex-wrap: wrap; 
      background: #f8fafc; 
      border-radius: 6px; 
      padding: 10px; 
      margin-bottom: 8px; 
      border-left: 3px solid var(--border); 
      align-items: center; 
      border-bottom: none;
  }
  .table-sm td { display: block; border: none !important; padding: 2px 5px !important; }
  .table-sm td:nth-child(1) { width: 100%; font-weight: 600; color: var(--text-main); margin-bottom: 4px; }
  .table-sm td:nth-child(2) { flex: 1; font-size: 0.95rem; color: var(--text-muted); }
  .table-sm td:nth-child(3) { width: auto; font-size: 0.9rem; }
  
  /* Cabeçalhos de Página (Alinha os botões que ficam lado a lado) */
  div[style*="justify-content: space-between"] { flex-direction: column; gap: 15px; align-items: stretch !important; text-align: center; }
  div[style*="justify-content: space-between"] .btn { width: 100% !important; justify-content: center; }
  div[style*="justify-content: space-between"] form { flex-direction: column; width: 100%; }
  
  /* Formulários */
  input, select, textarea { font-size: 16px; /* Evita auto-zoom do iOS */ }
  .status-btn-group { flex-direction: column; }
  
  /* Modais ocupam mais espaço vertical */
  .modal-content { margin: 15% auto; width: 95%; max-width: 95%; }
}
