/* ============================================================
   ADAPTECH FREIGHT HUB — Design System
   Paleta: Teal (#1D9E75) como cor primária da Adaptech
   ============================================================ */

:root {
  --brand:        #1D9E75;
  --brand-dark:   #0F6E56;
  --brand-light:  #E1F5EE;
  --brand-mid:    #5DCAA5;

  --bg:           #F8F8F6;
  --surface:      #FFFFFF;
  --surface-2:    #F1F0EC;
  --border:       rgba(0,0,0,0.10);
  --border-med:   rgba(0,0,0,0.18);

  --text-1:       #1A1A18;
  --text-2:       #5A5A56;
  --text-3:       #8A8A86;

  --blue:         #185FA5;  --blue-bg:    #E6F1FB;
  --amber:        #854F0B;  --amber-bg:   #FAEEDA;
  --purple:       #534AB7;  --purple-bg:  #EEEDFE;
  --green:        #3B6D11;  --green-bg:   #EAF3DE;
  --red:          #A32D2D;  --red-bg:     #FCEBEB;
  --gray:         #5F5E5A;  --gray-bg:    #F1EFE8;

  --radius-sm:    6px;
  --radius-md:    10px;
  --radius-lg:    14px;
  --radius-xl:    20px;

  --shadow-sm:    0 1px 3px rgba(0,0,0,0.07);
  --shadow-md:    0 4px 12px rgba(0,0,0,0.08);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --sidebar-w: 220px;
  --header-h:  56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:       #141412;
    --surface:  #1E1E1C;
    --surface-2:#2A2A28;
    --border:   rgba(255,255,255,0.10);
    --border-med:rgba(255,255,255,0.18);
    --text-1:   #EFEFEB;
    --text-2:   #A0A09C;
    --text-3:   #686864;
  }
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  background: var(--bg);
  color: var(--text-1);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---- Layout principal ---- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ---- Header ---- */
.app-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 0.5px solid var(--border);
  gap: 12px;
}
.app-logo {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--brand);
}
.app-logo span { color: var(--text-2); font-weight: 400; letter-spacing: 0; margin-left: 6px; font-size: 12px; }
.header-spacer { flex: 1; }
.header-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-2);
}
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--brand-light);
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}

/* ---- Sidebar ---- */
.app-sidebar {
  background: var(--surface);
  border-right: 0.5px solid var(--border);
  padding: 12px 0;
  overflow-y: auto;
}
.nav-section { padding: 0 10px; margin-bottom: 4px; }
.nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-3);
  text-transform: uppercase;
  padding: 8px 10px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--surface-2); color: var(--text-1); }
.nav-item.active { background: var(--brand-light); color: var(--brand-dark); font-weight: 500; }
.nav-item .nav-icon { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--red-bg);
  color: var(--red);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
}

/* ---- Main content ---- */
.app-main {
  overflow-y: auto;
  padding: 24px;
  background: var(--bg);
}
.page { display: none; }
.page.active { display: block; }

/* ---- Page header ---- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title { font-size: 18px; font-weight: 600; color: var(--text-1); }
.page-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ---- Botões ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.12s;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: var(--surface); color: var(--text-1); border: 0.5px solid var(--border-med); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: none; color: var(--text-2); border: 0.5px solid var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text-1); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ---- Cards de métricas ---- */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.metric-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}
.metric-label { font-size: 11px; color: var(--text-3); margin-bottom: 6px; }
.metric-value { font-size: 24px; font-weight: 600; color: var(--text-1); line-height: 1; }
.metric-sub { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* ---- Filtros ---- */
.filter-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: center;
}
.filter-chip {
  padding: 4px 12px;
  border-radius: 20px;
  border: 0.5px solid var(--border-med);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.12s;
}
.filter-chip:hover { background: var(--surface-2); }
.filter-chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.filter-spacer { flex: 1; }
.search-input {
  padding: 5px 12px;
  border-radius: var(--radius-md);
  border: 0.5px solid var(--border-med);
  background: var(--surface);
  color: var(--text-1);
  font-size: 13px;
  width: 200px;
  outline: none;
}
.search-input:focus { border-color: var(--brand); }

/* ---- Badge de status ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-transito, .badge-embarque { background: var(--blue-bg); color: var(--blue); }
.badge-producao  { background: var(--amber-bg); color: var(--amber); }
.badge-desembaco { background: var(--purple-bg); color: var(--purple); }
.badge-entregue  { background: var(--green-bg); color: var(--green); }
.badge-alerta    { background: var(--red-bg); color: var(--red); }
.badge-rascunho, .badge-cancelado { background: var(--gray-bg); color: var(--gray); }

.badge-pag-pendente  { background: var(--gray-bg); color: var(--gray); }
.badge-pag-faturado  { background: var(--blue-bg); color: var(--blue); }
.badge-pag-parcial   { background: var(--amber-bg); color: var(--amber); }
.badge-pag-quitado   { background: var(--green-bg); color: var(--green); }

/* ---- Cards de embarque ---- */
.cards-list { display: flex; flex-direction: column; gap: 10px; }
.ship-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.15s;
}
.ship-card:hover { border-color: var(--border-med); }
.ship-card.expanded { border-color: var(--brand); }
.ship-card.alerta { border-left: 3px solid var(--red); }

.ship-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
}
.ship-modal-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  background: var(--brand-light);
  color: var(--brand-dark);
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ship-info { flex: 1; min-width: 0; }
.ship-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ship-meta { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.ship-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex-shrink: 0; }
.ship-eta { font-size: 11px; color: var(--text-3); }

/* Progress bar */
.progress-wrap { padding: 0 16px 4px; }
.progress-bar { height: 3px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 2px; background: var(--brand); transition: width 0.4s; }
.progress-fill.alerta { background: var(--red); }
.progress-fill.entregue { background: var(--green); }

/* Etapas visuais */
.stages-wrap { padding: 10px 16px; overflow-x: auto; }
.stages-row { display: flex; align-items: flex-start; min-width: max-content; gap: 0; }
.stage { display: flex; flex-direction: column; align-items: center; width: 80px; }
.stage-dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-med);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px;
  font-weight: 600;
  color: var(--text-3);
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}
.stage-dot.done { background: var(--brand); border-color: var(--brand); color: #fff; }
.stage-dot.current { border-color: var(--blue); color: var(--blue); box-shadow: 0 0 0 3px var(--blue-bg); }
.stage-dot.current-alert { border-color: var(--red); color: var(--red); box-shadow: 0 0 0 3px var(--red-bg); }
.stage-label { font-size: 10px; color: var(--text-3); margin-top: 5px; text-align: center; line-height: 1.3; max-width: 72px; }
.stage-label.done { color: var(--brand-dark); }
.stage-label.current { color: var(--blue); font-weight: 500; }
.stage-connector { flex: 1; height: 2px; background: var(--border); margin-top: 10px; min-width: 12px; }
.stage-connector.done { background: var(--brand); }

/* Detalhes expandidos */
.ship-details {
  display: none;
  padding: 0 16px 16px;
  border-top: 0.5px solid var(--border);
}
.ship-details.open { display: block; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 14px 0;
}
@media (max-width: 700px) {
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
}
.detail-item .dl { font-size: 11px; color: var(--text-3); margin-bottom: 3px; }
.detail-item .dv { font-size: 13px; font-weight: 500; }

/* Custo consolidado */
.cost-grid {
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.cost-item .cl { font-size: 11px; color: var(--text-3); }
.cost-item .cv { font-size: 13px; font-weight: 600; }
.cost-total { border-top: 0.5px solid var(--border-med); padding-top: 8px; margin-top: 4px; }
.cost-total .cl { color: var(--text-2); font-weight: 500; }
.cost-total .cv { color: var(--brand-dark); font-size: 15px; }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.tl-item { display: flex; gap: 10px; align-items: flex-start; }
.tl-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; }
.tl-dot.done { background: var(--brand); }
.tl-dot.pending { background: var(--border-med); }
.tl-dot.alert { background: var(--red); }
.tl-content .tl-text { font-size: 12px; color: var(--text-2); line-height: 1.4; }
.tl-content .tl-text strong { color: var(--text-1); }
.tl-content .tl-date { font-size: 11px; color: var(--text-3); margin-top: 1px; }

/* Log de ocorrências */
.ocorrencias { margin-bottom: 12px; }
.ocorrencia-item {
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 6px;
  font-size: 12px;
}
.ocorrencia-meta { font-size: 11px; color: var(--text-3); margin-top: 3px; }

/* Documentos */
.docs-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.doc-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--blue-bg);
  color: var(--blue);
  border-radius: var(--radius-md);
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
}
.doc-chip:hover { opacity: 0.8; }
.doc-empty { font-size: 12px; color: var(--text-3); font-style: italic; }

/* Ações */
.action-bar { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 10px; border-top: 0.5px solid var(--border); }

/* ---- Formulários ---- */
.form-section { margin-bottom: 20px; }
.form-title { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 12px; padding-bottom: 6px; border-bottom: 0.5px solid var(--border); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: 12px; font-weight: 500; color: var(--text-2); }
.form-input, .form-select, .form-textarea {
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 0.5px solid var(--border-med);
  background: var(--surface);
  color: var(--text-1);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.12s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--brand); }
.form-textarea { resize: vertical; min-height: 72px; }
.form-hint { font-size: 11px; color: var(--text-3); }

/* ---- Modal ---- */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 0.5px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-3); font-size: 18px; }
.modal-body { padding: 20px 22px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 0.5px solid var(--border); }

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

/* ---- Empty state ---- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty-state .empty-icon { font-size: 32px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ---- Toast ---- */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--text-1);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.2s ease;
}
.toast.success { background: var(--brand); }
.toast.error { background: var(--red); }
@keyframes slideIn { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---- Responsivo ---- */
@media (max-width: 600px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-sidebar { display: none; }
  .app-main { padding: 16px; }
}
