/* main.css — Reconstrução Total & Design System */

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

:root {
  --blue-deep: #0A1C3F;
  --blue-mid: #152E5F;
  --blue-light: #EBF2FF;
  --yellow: #FFB800;
  
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  
  --radius: 12px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* --- UTILITÁRIOS DE LAYOUT --- */
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.gap-8 { gap: 0.5rem; }
.gap-16 { gap: 1rem; }
.mb-8 { margin-bottom: 0.5rem; }
.mb-16 { margin-bottom: 1rem; }
.mb-24 { margin-bottom: 1.5rem; }
.mt-8 { margin-top: 0.5rem; }
.mt-24 { margin-top: 1.5rem; }
.text-center { text-align: center; }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 0.8125rem; }
.text-xs { font-size: 0.75rem; }

/* --- FORMULÁRIOS (APPLE UX) --- */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.form-control {
    width: 100%;
    padding: 0.85rem 1rem;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    color: var(--gray-800);
    transition: var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--blue-mid);
    box-shadow: 0 0 0 4px rgba(21, 46, 95, 0.08);
}
textarea.form-control { min-height: 80px; resize: vertical; }

/* --- BOTÕES --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  border: none;
}
.btn-sm { padding: 0.5rem 1rem; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 1rem 2rem; font-size: 16px; }
.btn-primary { background: var(--blue-deep); color: #fff; }
.btn-primary:hover { background: var(--blue-mid); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(10, 28, 63, 0.2); }
.btn-outline { background: #fff; border: 1.5px solid var(--gray-200); color: var(--gray-700); }
.btn-outline:hover { border-color: var(--blue-mid); color: var(--blue-mid); background: var(--gray-50); }
.btn-ghost { background: transparent; color: var(--gray-500); }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-800); }
.btn-yellow { background: #fef9c3; color: #854d0e; }
.btn-yellow:hover { background: #fef08a; }
.btn-danger { background: #fee2e2; color: #991b1b; }
.btn-danger:hover { background: #fecaca; }

/* --- CARDS --- */
.card { background: #fff; border-radius: 16px; border: 1px solid var(--gray-200); box-shadow: 0 1px 3px rgba(0,0,0,0.02); overflow: hidden; }
.card-header { padding: 1.5rem; border-bottom: 1px solid var(--gray-100); background: #fff; }
.card-body { padding: 1.5rem; }

/* --- TABELAS --- */
.table-wrapper { overflow-x: auto; border-radius: 12px; border: 1px solid var(--gray-200); }
table { width: 100%; border-collapse: collapse; background: #fff; }
th { padding: 1rem; background: var(--blue-deep); color: #fff; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; text-align: left; }
td { padding: 1.25rem 1rem; border-bottom: 1px solid var(--gray-100); font-size: 14px; color: var(--gray-700); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

/* --- BADGES --- */
.badge { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.badge-blue { background: var(--blue-light); color: var(--blue-mid); }
.badge-success { background: #dcfce7; color: #166534; }
.badge-gray { background: #f3f4f6; color: #4b5563; }

/* --- MODAIS (FIX) --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4); backdrop-filter: blur(8px);
    display: none; z-index: 1000; align-items: center; justify-content: center;
    padding: 5px; /* Margem de 5px dos limites da tela conforme solicitado */
}
.modal-overlay.active { display: flex; }
.modal {
    background: #fff; width: 100%; border-radius: 20px; 
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    overflow: hidden; animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: calc(100vh - 10px); /* Garante que o modal não ultrapasse o limite de 5px top/bottom */
    display: flex;
    flex-direction: column;
}

/* NOVO: Garante que formulários dentro de modais também sigam o layout flex */
.modal form {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header { padding: 1.25rem 2rem; border-bottom: 1px solid var(--gray-100); display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.modal-header h3 { font-size: 18px; color: var(--blue-deep); font-weight: 800; }
.modal-close { background: transparent; border: none; font-size: 20px; cursor: pointer; color: var(--gray-400); transition: .2s; }
.modal-close:hover { color: var(--gray-800); }
.modal-body { padding: 2rem; overflow-y: auto; flex: 1; }
.modal-footer { padding: 1.25rem 2rem; background: var(--gray-50); border-top: 1px solid var(--gray-100); display: flex; justify-content: flex-end; gap: 1rem; flex-shrink: 0; }
