/* ============================================================
   OBDIP 2026 — Design System Compartilhado
   ============================================================ */

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

:root {
  /* Cores */
  --navy:        #1E3A5F;
  --navy-deep:   #152C4A;
  --navy-light:  #2D5480;
  --gold:        #C9A227;
  --gold-light:  #E2B93B;
  --gold-pale:   #FDF6DC;
  --white:       #FFFFFF;
  --bg:          #F4F7FA;
  --bg-alt:      #EEF2F7;
  --surface:     #FFFFFF;
  --text:        #1A202C;
  --text-muted:  #718096;
  --text-light:  #A0AEC0;
  --border:      #E2E8F0;
  --border-dark: #CBD5E0;
  --error:       #E53E3E;
  --error-bg:    #FFF5F5;
  --error-border:#FEB2B2;
  --success:     #38A169;
  --success-bg:  #F0FFF4;
  --success-border:#9AE6B4;
  --warning:     #D97706;
  --info-bg:     #EBF8FF;
  --info-border: #BEE3F8;
  --info-text:   #2B6CB0;

  /* Espaçamento */
  --radius:      8px;
  --radius-lg:   12px;
  --radius-sm:   6px;

  /* Sombras */
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:      0 4px 16px rgba(30,58,95,0.08), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg:   0 10px 40px rgba(30,58,95,0.12), 0 2px 8px rgba(0,0,0,0.06);

  /* Tipografia */
  --font-sans:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif:  'Playfair Display', Georgia, 'Times New Roman', serif;

  /* Transição */
  --transition:  all 0.18s ease;
}

/* ---- Base ---- */
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Tipografia ---- */
h1, h2, h3, h4, h5 { line-height: 1.25; font-weight: 700; }
.serif { font-family: var(--font-serif); }

/* ---- Botões ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.985); }
.btn[disabled], .btn.loading { opacity: 0.6; pointer-events: none; }

.btn-primary   { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-deep); }

.btn-secondary { background: var(--bg-alt); color: var(--text); border-color: var(--border-dark); }
.btn-secondary:hover { background: var(--border); }

.btn-outline   { background: transparent; color: var(--navy); border-color: var(--navy); }
.btn-outline:hover { background: var(--navy); color: #fff; }

.btn-ghost     { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--bg-alt); color: var(--text); }

.btn-danger    { background: var(--error); color: #fff; border-color: var(--error); }
.btn-danger:hover { background: #c53030; }

.btn-gold      { background: var(--gold); color: var(--navy-deep); border-color: var(--gold); }
.btn-gold:hover { background: var(--gold-light); }

.btn-sm  { padding: 6px 14px; font-size: 13px; }
.btn-lg  { padding: 13px 28px; font-size: 15px; }
.btn-full { width: 100%; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

/* ---- Formulários ---- */
.form-group { margin-bottom: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 5px;
}
.form-label .required { color: var(--error); margin-left: 2px; }

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.18s, box-shadow 0.18s;
  outline: none;
  appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(30,58,95,0.1);
}
.form-input.error, .form-select.error, .form-textarea.error {
  border-color: var(--error);
}
.form-input:disabled, .form-select:disabled {
  background: var(--bg-alt);
  color: var(--text-muted);
  cursor: not-allowed;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23718096' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-textarea { resize: vertical; min-height: 100px; }

.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--error); margin-top: 4px; display: none; }
.form-error.visible { display: block; }

.input-wrapper { position: relative; }
.input-wrapper .form-input { padding-right: 42px; }
.input-action {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  display: flex;
  align-items: center;
}
.input-action:hover { color: var(--navy); }

.checkbox-group {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}
.checkbox-group:hover { background: var(--bg-alt); }
.checkbox-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 1px;
  accent-color: var(--navy);
  cursor: pointer;
  flex-shrink: 0;
}
.checkbox-group span {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

/* ---- Alerts / Info boxes ---- */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.6;
  display: none;
}
.alert.visible { display: block; }
.alert-error   { background: var(--error-bg);   border: 1px solid var(--error-border);   color: var(--error); }
.alert-success { background: var(--success-bg); border: 1px solid var(--success-border); color: var(--success); }
.alert-info    { background: var(--info-bg);    border: 1px solid var(--info-border);    color: var(--info-text); }
.alert-warning { background: #FFFBEB; border: 1px solid #FCD34D; color: var(--warning); }

/* ---- Badge ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.badge-navy    { background: #DBEAFE; color: var(--navy); }
.badge-gold    { background: var(--gold-pale); color: #92400E; }
.badge-green   { background: #D1FAE5; color: #065F46; }
.badge-red     { background: #FEE2E2; color: #991B1B; }
.badge-gray    { background: var(--bg-alt); color: var(--text-muted); }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 20px;
  opacity: 0; visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(12px);
  transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 900px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 4px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center;
}
.modal-close:hover { background: var(--bg-alt); color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg); }

/* ---- Spinner ---- */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 16px; height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
  opacity: 0.6;
}
.btn.loading .spinner { display: inline-block; }
.spinner-page {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 60px auto;
}

/* ---- Divider ---- */
.divider {
  display: flex; align-items: center; gap: 12px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 12px;
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ---- Toast ---- */
#toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  background: var(--navy);
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: slide-in 0.2s ease;
  max-width: 320px;
}
.toast.toast-error   { background: var(--error); }
.toast.toast-success { background: var(--success); }
.toast.toast-warning { background: var(--warning); }
@keyframes slide-in {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ---- Tabs ---- */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  gap: 0;
  margin-bottom: 24px;
}
.tab-btn {
  padding: 10px 18px;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover  { color: var(--navy); }
.tab-btn.active { color: var(--navy); border-bottom-color: var(--navy); font-weight: 600; }

/* ---- Skeleton loader ---- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-alt) 25%, var(--border) 50%, var(--bg-alt) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state svg { margin: 0 auto 16px; opacity: 0.4; }
.empty-state h3  { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-state p   { font-size: 13px; }

/* ---- Utilities ---- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.text-small  { font-size: 12px; }
.flex        { display: flex; align-items: center; }
.flex-between{ display: flex; align-items: center; justify-content: space-between; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.gap-16      { gap: 16px; }
.mt-8        { margin-top: 8px; }
.mt-16       { margin-top: 16px; }
.mt-24       { margin-top: 24px; }
.mb-8        { margin-bottom: 8px; }
.mb-16       { margin-bottom: 16px; }
.mb-24       { margin-bottom: 24px; }
.hidden      { display: none !important; }

/* ════════════════════════
   RESPONSIVIDADE MOBILE
════════════════════════ */
@media (max-width: 600px) {
  /* Modal — footer wrap e padding reduzido */
  .modal-footer {
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 16px;
  }
  .modal-body  { padding: 18px 16px; }
  .modal-header { padding: 16px; }

  /* Toast — ocupa largura melhor no celular */
  #toast-container {
    bottom: 16px;
    right: 12px;
    left: 12px;
  }
  .toast {
    max-width: 100%;
    font-size: 13px;
  }

  /* Tabela — texto menor para caber mais no mobile */
  .table-wrap td { font-size: 12px; padding: 10px 10px; }
  .table-wrap th { font-size: 10px; padding: 8px 10px; }

  /* Tabs — overflow horizontal para não quebrar layout */
  .tabs { overflow-x: auto; flex-wrap: nowrap; gap: 0; }
  .tab-btn { white-space: nowrap; flex-shrink: 0; padding: 10px 14px; }

  /* form-row sempre 1 coluna no mobile */
  .form-row { grid-template-columns: 1fr; }

  /* topbar-title sem overflow */
  .topbar-title { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }
}
