/* ============================================================
   safe-theme.css — Design System SAFE Escola de Aviação
   Dashboard Comercial
   ============================================================ */

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

/* ── Variáveis ─────────────────────────────────────────────── */
:root {
  /* Cores SAFE */
  --navy:        #1D2951;
  --navy-deep:   #141d3a;
  --navy-light:  #253463;
  --blue:        #5BAEE2;
  --blue-light:  #7ec3ea;
  --blue-dark:   #3d8cc4;
  --teal:        #60C0BF;
  --teal-light:  #80d4d3;
  --teal-dark:   #44a8a7;
  --mid-blue:    #80B8B8;

  /* Neutros */
  --white:       #FFFFFF;
  --off-white:   #F4F7FC;
  --gray-100:    #EEF2F8;
  --gray-200:    #DDE4EF;
  --gray-300:    #BCC8DC;
  --gray-400:    #8EA4C0;
  --gray-500:    #5E7A9A;
  --gray-600:    #3E5475;
  --black:       #000000;

  /* Semânticas */
  --success:     #2ECC71;
  --warning:     #F39C12;
  --danger:      #E74C3C;
  --info:        var(--blue);

  /* Sidebar */
  --sidebar-w:        240px;
  --sidebar-w-collapsed: 68px;

  /* Layout */
  --topbar-h:    64px;
  --radius-sm:   6px;
  --radius-md:   12px;
  --radius-lg:   20px;
  --radius-xl:   28px;

  /* Sombras */
  --shadow-sm:   0 1px 4px rgba(29,41,81,.08);
  --shadow-md:   0 4px 16px rgba(29,41,81,.12);
  --shadow-lg:   0 8px 32px rgba(29,41,81,.18);
  --shadow-card: 0 2px 12px rgba(29,41,81,.10);

  /* Tipografia */
  --font-title:  'Raleway', sans-serif;
  --font-body:   'Montserrat', sans-serif;

  /* Transições */
  --transition:  all .2s cubic-bezier(.4,0,.2,1);
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--off-white);
  color: var(--navy);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }

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

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1rem; }

.text-sm    { font-size: .85rem; }
.text-xs    { font-size: .75rem; }
.text-muted { color: var(--gray-400); }
.text-white { color: var(--white); }
.text-blue  { color: var(--blue); }
.text-teal  { color: var(--teal); }
.fw-600     { font-weight: 600; }
.fw-700     { font-weight: 700; }

/* ── Botões ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: .875rem;
  font-weight: 600;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--blue);
  color: var(--white);
}
.btn-primary:hover {
  background: var(--blue-dark);
  box-shadow: 0 4px 12px rgba(91,174,226,.35);
  transform: translateY(-1px);
}

.btn-navy {
  background: var(--navy);
  color: var(--white);
}
.btn-navy:hover {
  background: var(--navy-deep);
  transform: translateY(-1px);
}

.btn-teal {
  background: var(--teal);
  color: var(--white);
}
.btn-teal:hover {
  background: var(--teal-dark);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--navy);
  border: 1.5px solid var(--gray-200);
}
.btn-ghost:hover {
  background: var(--gray-100);
  border-color: var(--gray-300);
}

.btn-danger {
  background: var(--danger);
  color: var(--white);
}
.btn-danger:hover { background: #c0392b; }

.btn-sm { padding: 7px 14px; font-size: .8rem; }
.btn-lg { padding: 13px 28px; font-size: 1rem; }
.btn-icon { padding: 9px; border-radius: var(--radius-sm); }

.btn:disabled {
  opacity: .5;
  pointer-events: none;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title {
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
}

/* KPI Card */
.kpi-card {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--blue), var(--teal));
}
.kpi-label {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-400);
}
.kpi-value {
  font-family: var(--font-title);
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1;
}
.kpi-sub {
  font-size: .78rem;
  color: var(--gray-400);
}
.kpi-icon {
  position: absolute;
  top: 20px; right: 20px;
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}
.kpi-icon.blue  { background: rgba(91,174,226,.12); color: var(--blue); }
.kpi-icon.teal  { background: rgba(96,192,191,.12); color: var(--teal); }
.kpi-icon.navy  { background: rgba(29,41,81,.08);   color: var(--navy); }
.kpi-icon.green { background: rgba(46,204,113,.12); color: var(--success); }

/* ── Formulários ───────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.form-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  color: var(--navy);
  background: var(--white);
  transition: var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(91,174,226,.15);
}
.form-control::placeholder { color: var(--gray-300); }
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0 16px;
}

/* ── Tabelas ───────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.table thead th {
  background: var(--navy);
  color: var(--white);
  font-family: var(--font-title);
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 12px 16px;
  text-align: left;
  white-space: nowrap;
}
.table thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
.table thead th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }
.table tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: var(--transition);
}
.table tbody tr:hover { background: var(--off-white); }
.table tbody td {
  padding: 12px 16px;
  color: var(--navy);
  vertical-align: middle;
}
.table tbody tr:last-child { border-bottom: none; }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.badge-blue   { background: rgba(91,174,226,.12);  color: var(--blue-dark); }
.badge-teal   { background: rgba(96,192,191,.12);  color: var(--teal-dark); }
.badge-navy   { background: rgba(29,41,81,.08);    color: var(--navy); }
.badge-green  { background: rgba(46,204,113,.12);  color: #27ae60; }
.badge-orange { background: rgba(243,156,18,.12);  color: #d68910; }
.badge-red    { background: rgba(231,76,60,.12);   color: #c0392b; }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14,20,40,.55);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px) scale(.97);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-header {
  padding: 24px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-body    { padding: 20px 24px; }
.modal-footer  { padding: 0 24px 24px; display: flex; gap: 10px; justify-content: flex-end; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-400);
  transition: var(--transition);
}
.modal-close:hover { background: var(--gray-100); color: var(--navy); }

/* ── Toast / Alertas ───────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 380px;
  font-size: .875rem;
  font-weight: 500;
  animation: toastIn .3s cubic-bezier(.4,0,.2,1);
  border-left: 4px solid var(--blue);
}
.toast.success { border-color: var(--success); }
.toast.error   { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Loading ───────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.spinner.dark {
  border-color: rgba(29,41,81,.15);
  border-top-color: var(--navy);
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  z-index: 10;
}

/* ── Utilitários ───────────────────────────────────────────── */
.d-flex  { display: flex; }
.d-none  { display: none !important; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8   { gap: 8px; }
.gap-12  { gap: 12px; }
.gap-16  { gap: 16px; }
.mt-4    { margin-top: 4px; }
.mt-8    { margin-top: 8px; }
.mt-16   { margin-top: 16px; }
.mt-24   { margin-top: 24px; }
.mb-16   { margin-bottom: 16px; }
.mb-24   { margin-bottom: 24px; }
.w-100   { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.cursor-pointer { cursor: pointer; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-400);
}
.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: .4;
}
.empty-state p { font-size: .9rem; }

/* Divider */
.divider {
  border: none;
  border-top: 1px solid var(--gray-100);
  margin: 16px 0;
}

/* Scrollbar customizada */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* Garante que nada vaze */
*, *::before, *::after { box-sizing: border-box; }

.table-wrapper {
  overflow-x: hidden !important;
  width: 100%;
}

.table {
  width: 100%;
  min-width: 0 !important;
  table-layout: fixed;
}

/* Colunas com largura fixa */
.table thead th:nth-child(1) { width: 100px; } /* Data */
.table thead th:nth-child(2) { width: 90px;  } /* PAC */
.table thead th:nth-child(3) { width: auto;  } /* Cliente — flex */
.table thead th:nth-child(4) { width: 140px; } /* Curso */
.table thead th:nth-child(5) { width: 110px; } /* Origem */
.table thead th:nth-child(6) { width: 90px;  } /* Lead Novo */
.table thead th:nth-child(7) { width: 110px; } /* Valor */
.table thead th:nth-child(8) { width: 44px;  } /* Ação */

/* Células truncam com reticências */
.table tbody td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── 1200px: some Origem ──────────────────────────────────── */
@media (max-width: 1200px) {
  .table .col-origem,
  .table th.col-origem { display: none; }
}

/* ── 960px: some Lead Novo ───────────────────────────────── */
@media (max-width: 960px) {
  .table .col-lead,
  .table th.col-lead { display: none; }
}

/* ── 720px: some PAC ─────────────────────────────────────── */
@media (max-width: 720px) {
  .table .col-pac,
  .table th.col-pac { display: none; }
}

/* ── 520px: some Curso ───────────────────────────────────── */
@media (max-width: 520px) {
  .table .col-curso,
  .table th.col-curso { display: none; }
}

/* ============================================================
   Tabela responsiva — sem scroll, sem truncamento
   Colunas somem progressivamente conforme a tela diminui
   ============================================================ */

/* Reset: tabela ocupa espaço disponível, sem forçar largura */
.table-wrapper {
  overflow: hidden !important;
  width: 100%;
}

.table {
  width: 100%;
  table-layout: auto;
}

/* Sem truncamento em nenhuma célula */
.table tbody td,
.table thead th {
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  word-break: break-word;
}

/* Apenas data e valor não quebram */
.table td:first-child,
.table th:first-child,
.table td.col-valor,
.table th.col-valor {
  white-space: nowrap;
}

/* ── Breakpoints: colunas somem, nunca truncam ─────────────── */

/* < 1100px: some Origem */
@media (max-width: 1100px) {
  .col-origem { display: none !important; }
}

/* < 860px: some Lead Novo */
@media (max-width: 860px) {
  .col-lead { display: none !important; }
}

/* < 680px: some PAC */
@media (max-width: 680px) {
  .col-pac { display: none !important; }
}

/* < 500px: some Curso */
@media (max-width: 500px) {
  .col-curso { display: none !important; }
}
