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

/* ── Variáveis EDR ────────────────────────────────────────────────────────── */
:root {
  --bg:           #0f0f11;
  --sidebar:      #141416;
  --card:         #1a1a1e;
  --surface:      #202026;
  --card-hover:   #22222a;
  --border:       #2a2a32;
  --border-light: #383844;
  --gold:         #e8a84c;
  --gold-dark:    #c8882c;
  --gold-light:   #f2c46a;
  --gold-glow:    rgba(232,168,76,0.10);
  --gold-dim:     rgba(232,168,76,0.06);
  --text:         #eeeef0;
  --text-muted:   #72728a;
  --text-soft:    #aaaabb;
  --success:      #4dbb6e;
  --danger:       #e05252;
  --warning:      #e8a84c;
  --info:         #4a9eda;
  --sidebar-w:    252px;
  --radius:       10px;
  --radius-sm:    6px;
  --radius-lg:    14px;
  --shadow:       0 2px 12px rgba(0,0,0,0.5);
  --shadow-md:    0 6px 30px rgba(0,0,0,0.6);
  --transition:   0.15s ease;
}

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

html, body {
  height: 100%;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--gold); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--gold-light); }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Layout ────────────────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  overflow: hidden;
}

.sidebar-logo {
  padding: 20px 18px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-logo img { max-width: 124px; height: auto; display: block; opacity: 0.95; }

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

.nav-section {
  padding: 18px 14px 5px;
  font-size: 10.5px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 800;
  opacity: 0.9;
  border-top: 1px solid rgba(232,168,76,0.15);
  margin-top: 4px;
}
.nav-section:first-child {
  border-top: none;
  margin-top: 0;
  padding-top: 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  transition: background var(--transition), color var(--transition);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.nav-item:hover { background: var(--gold-glow); color: var(--text); }
.nav-item.active {
  background: rgba(232,168,76,0.13);
  color: var(--gold);
  font-weight: 600;
}
.nav-item .icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }

.sidebar-user {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: rgba(0,0,0,0.15);
}
.sidebar-user .user-name { font-weight: 600; font-size: 13px; color: var(--text); }
.sidebar-user .user-perfil {
  font-size: 10px;
  color: var(--gold);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 8px;
  font-weight: 600;
  opacity: 0.85;
}
.btn-logout { font-size: 12px; color: var(--text-muted); transition: color var(--transition); }
.btn-logout:hover { color: var(--danger); }

/* ── Main ──────────────────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
}

/* ── Page Header ───────────────────────────────────────────────────────────── */
.page-header {
  padding: 26px 30px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header-left { flex: 1; min-width: 0; }
.page-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.4px;
  line-height: 1.2;
}
.page-subtitle { color: var(--text-muted); font-size: 12.5px; margin-top: 3px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; flex-shrink: 0; }

.page-content { padding: 18px 30px 32px; flex: 1; }

/* ── Alertas flash ─────────────────────────────────────────────────────────── */
.alerts { padding: 14px 30px 0; }
.alert {
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 13px;
  border-left: 3px solid;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-success { background: rgba(77,187,110,0.09); border-color: var(--success); color: #80d49a; }
.alert-error   { background: rgba(224,82,82,0.09);  border-color: var(--danger);  color: #e89090; }
.alert-warning { background: rgba(232,168,76,0.09); border-color: var(--warning); color: var(--gold-light); }

/* ── Alert Banners (fabricação, prazos) ────────────────────────────────────── */
.alert-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid;
  margin-bottom: 14px;
  font-size: 13px;
}
.alert-banner-danger  { background: rgba(224,82,82,0.08);  border-color: rgba(224,82,82,0.3);  }
.alert-banner-warning { background: rgba(232,168,76,0.08); border-color: rgba(232,168,76,0.3); }
.alert-banner-icon { font-size: 18px; flex-shrink: 0; }

/* ── Cards de métricas ─────────────────────────────────────────────────────── */
.cards-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  margin-bottom: 20px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: border-color var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.015) 0%, transparent 60%);
  pointer-events: none;
}
.card:hover { border-color: var(--border-light); transform: translateY(-1px); }
.card-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-weight: 700;
}
.card-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; }
.card-sub   { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.card.gold  {
  border-color: rgba(232,168,76,0.3);
  background: linear-gradient(135deg, rgba(232,168,76,0.07) 0%, rgba(232,168,76,0.02) 100%);
}
.card.gold .card-value { color: var(--gold); }

/* ── Progress bar (metas) ──────────────────────────────────────────────────── */
.progress-wrap {
  background: var(--border);
  border-radius: 20px;
  height: 6px;
  overflow: hidden;
  margin-top: 10px;
}
.progress-bar {
  height: 100%;
  border-radius: 20px;
  transition: width 0.4s ease;
}
.progress-bar.green  { background: var(--success); }
.progress-bar.gold   { background: var(--gold); }
.progress-bar.red    { background: var(--danger); }
.progress-pct {
  text-align: right;
  font-size: 11px;
  font-weight: 600;
  margin-top: 4px;
}

/* ── Tabelas ───────────────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}
.table-header {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}
.table-header h3 { font-size: 13.5px; font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 9px 14px;
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--text-muted);
  background: rgba(0,0,0,0.18);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  white-space: nowrap;
}
tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  font-size: 13px;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(232,168,76,0.025); }

/* Colunas ordenáveis */
thead th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
}
thead th.sortable:hover { color: var(--gold); }
thead th.sortable.asc  .sort-icon::after { content: ' ↑'; color: var(--gold); font-size: 11px; }
thead th.sortable.desc .sort-icon::after { content: ' ↓'; color: var(--gold); font-size: 11px; }
thead th.sortable .sort-icon { color: var(--border); font-size: 11px; }
thead th.sortable.asc  .sort-icon,
thead th.sortable.desc .sort-icon { color: transparent; }

/* ── Empty state ───────────────────────────────────────────────────────────── */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 36px; margin-bottom: 12px; opacity: 0.5; }
.empty-state-text { font-size: 14px; margin-bottom: 16px; }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.badge-gerado       { background: rgba(74,158,218,0.14); color: #6bbde8; }
.badge-em_definicao { background: rgba(232,168,76,0.14); color: var(--gold); }
.badge-aprovado     { background: rgba(77,187,110,0.14); color: #6dd49a; }
.badge-perdido      { background: rgba(224,82,82,0.14);  color: #e88888; }
.badge-urgencia     { background: rgba(255,140,0,0.16);  color: #ffaa44; }

/* ── Botões ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
  font-family: inherit;
  white-space: nowrap;
  line-height: 1.4;
  letter-spacing: -0.1px;
}
.btn-gold        { background: var(--gold); color: #141414; font-weight: 600; }
.btn-gold:hover  { background: var(--gold-light); color: #141414; }
.btn-outline     { background: transparent; border: 1px solid var(--border-light); color: var(--text-soft); }
.btn-outline:hover { border-color: var(--gold); color: var(--gold); background: var(--gold-dim); }
.btn-success     { background: rgba(77,187,110,0.12); color: var(--success); border: 1px solid rgba(77,187,110,0.22); }
.btn-success:hover { background: var(--success); color: #fff; }
.btn-danger      { background: rgba(224,82,82,0.10); color: var(--danger); border: 1px solid rgba(224,82,82,0.22); }
.btn-danger:hover{ background: var(--danger); color: #fff; }
.btn-sm          { padding: 5px 10px; font-size: 12px; }
.btn-xs          { padding: 3px 7px; font-size: 11px; }
.btn:disabled    { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* ── Filtros (botões de status) ────────────────────────────────────────────── */
.filter-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }

/* ── Formulários ───────────────────────────────────────────────────────────── */
.form-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 6px;
  font-weight: 700;
}
.form-control {
  width: 100%;
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
  -webkit-appearance: none;
}
.form-control:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(232,168,76,0.09);
}
.form-control::placeholder { color: var(--text-muted); opacity: 0.5; }
select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2372728a' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}
select.form-control option { background: #1a1a1e; color: var(--text); }
textarea.form-control { resize: vertical; min-height: 76px; line-height: 1.55; }
input[type="number"].form-control::-webkit-inner-spin-button,
input[type="number"].form-control::-webkit-outer-spin-button { -webkit-appearance: none; }

.form-row    { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; gap: 9px; margin-top: 18px; align-items: center; flex-wrap: wrap; }

/* Título de seção dentro de form ou página */
.secao-titulo {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--gold);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ── Divisor ───────────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

/* ── Login ─────────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 60% 50% at 20% 50%, rgba(232,168,76,0.04) 0%, transparent 100%);
}
.login-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 42px 38px;
  width: 100%;
  max-width: 370px;
  box-shadow: var(--shadow-md);
}
.login-logo { text-align: center; margin-bottom: 26px; }
.login-logo img { max-width: 140px; }
.login-title { font-size: 17px; font-weight: 700; text-align: center; margin-bottom: 4px; letter-spacing: -0.3px; }
.login-sub { font-size: 12.5px; color: var(--text-muted); text-align: center; margin-bottom: 26px; }
.login-box .form-group { margin-bottom: 13px; }
.btn-login { width: 100%; padding: 10px; font-size: 14px; margin-top: 10px; justify-content: center; font-weight: 600; }

/* ── Chat ──────────────────────────────────────────────────────────────────── */
.chat-layout { display: flex; flex-direction: column; height: calc(100vh - 150px); }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg { display: flex; gap: 9px; max-width: 82%; }
.msg.agent { align-self: flex-start; }
.msg.user  { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.msg.agent .msg-avatar { background: rgba(232,168,76,0.16); color: var(--gold); }
.msg.user  .msg-avatar { background: rgba(77,187,110,0.16);  color: var(--success); }
.msg-bubble {
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.msg.agent .msg-bubble { background: rgba(255,255,255,0.05); border-radius: 4px 12px 12px 12px; }
.msg.user  .msg-bubble { background: rgba(232,168,76,0.11);  border-radius: 12px 4px 12px 12px; }

.typing { display: flex; gap: 4px; align-items: center; padding: 8px 13px; }
.typing span { width: 6px; height: 6px; background: var(--gold); border-radius: 50%; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,80%,100%{ opacity:0.2 } 40%{ opacity:1 } }

.pdf-card {
  background: rgba(77,187,110,0.07);
  border: 1px solid rgba(77,187,110,0.22);
  border-radius: var(--radius-sm);
  padding: 11px 15px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.pdf-card .pdf-info  { font-size: 13px; }
.pdf-card .pdf-total { font-weight: 700; color: var(--success); }

.chat-input-area {
  display: flex; gap: 9px; padding: 11px 13px;
  background: var(--card);
  border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
}
.chat-input {
  flex: 1;
  background: rgba(0,0,0,0.22);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none; resize: none;
  font-family: inherit;
  transition: border-color var(--transition);
}
.chat-input:focus { border-color: var(--gold); }

/* ── Parcelas / listas de itens ─────────────────────────────────────────────── */
.parcela-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border-left: 3px solid var(--border-light);
  font-size: 13px;
}
.parcela-item.atrasada { border-left-color: var(--danger); }
.parcela-item.vencendo { border-left-color: var(--warning); }

/* ── Detalhes (obras) ──────────────────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.detail-item label {
  font-size: 10px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.7px;
  display: block; margin-bottom: 2px; font-weight: 700;
}
.detail-item span  { font-size: 13.5px; color: var(--text); }
.detail-item.highlight span { color: var(--gold); font-weight: 600; }

/* ── Kanban ────────────────────────────────────────────────────────────────── */
.kanban-board { display: flex; gap: 12px; align-items: flex-start; overflow-x: auto; padding-bottom: 16px; }
.kanban-col {
  min-width: 255px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.kanban-col-header {
  padding: 11px 15px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.8px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.kanban-cards { padding: 8px; display: flex; flex-direction: column; gap: 7px; min-height: 60px; }
.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px;
  cursor: grab;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-size: 13px;
}
.kanban-card:hover { border-color: var(--gold); box-shadow: 0 2px 10px rgba(0,0,0,0.3); }

/* ── Hamburguer mobile ─────────────────────────────────────────────────────── */
.hamburger {
  display: none;
  position: fixed; top: 12px; left: 12px;
  z-index: 200;
  background: var(--gold);
  border: none;
  border-radius: var(--radius-sm);
  width: 38px; height: 38px;
  cursor: pointer;
  flex-direction: column;
  align-items: center; justify-content: center;
  gap: 5px;
  box-shadow: var(--shadow);
}
.hamburger span { display: block; width: 16px; height: 2px; background: #111; border-radius: 2px; transition: all .22s; }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 149;
  backdrop-filter: blur(3px);
}

/* ── Helpers ───────────────────────────────────────────────────────────────── */
.text-gold    { color: var(--gold); }
.text-muted   { color: var(--text-muted); }
.text-soft    { color: var(--text-soft); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-11  { font-size: 11px; }
.fs-12  { font-size: 12px; }
.fs-13  { font-size: 13px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-0  { margin-top: 0; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }

/* ── Responsivo ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .hamburger { display: flex; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 150; width: 260px;
  }
  .sidebar.aberto { transform: translateX(0); }
  .sidebar-overlay.aberto { display: block; }
  .main { margin-left: 0; padding-top: 56px; }
  .page-header { padding: 14px 16px 0; }
  .page-content { padding: 14px 16px 24px; }
  .alerts { padding: 10px 16px 0; }
  .form-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .cards-grid { grid-template-columns: 1fr 1fr; }
  thead th, tbody td { padding: 8px 10px; }
}
@media (max-width: 480px) {
  .cards-grid { grid-template-columns: 1fr; }
}
