/* ============================================================
   Engenharia e Serviços — Sistema de Orçamentos
   Design profissional, azul corporativo
   ============================================================ */

:root {
  --blue:        #1a5276;
  --blue-light:  #2e86c1;
  --blue-pale:   #eaf2ff;
  --blue-mid:    #d6eaf8;
  --green:       #1e8449;
  --green-pale:  #e9f7ef;
  --orange:      #e67e22;
  --orange-pale: #fef9e7;
  --red:         #c0392b;
  --red-pale:    #fdedec;
  --gray:        #5d6d7e;
  --gray-light:  #f4f6f8;
  --gray-border: #dce3ea;
  --white:       #ffffff;
  --text:        #2c3e50;
  --text-muted:  #7f8c8d;
  --radius:      8px;
  --shadow:      0 2px 12px rgba(0,0,0,.08);
  --shadow-md:   0 4px 20px rgba(0,0,0,.12);
  --nav-h:       60px;
  --font:        'Segoe UI', Arial, Helvetica, sans-serif;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body { font-family: var(--font); color: var(--text); background: #f0f3f7; min-height: 100vh; }
a { color: var(--blue-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   NAVBAR
   ============================================================ */
.topnav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: var(--blue);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.topnav-brand { display: flex; align-items: center; gap: 10px; }
.brand-link { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.brand-icon { font-size: 22px; }
.brand-name { color: #fff; font-size: 16px; font-weight: 700; letter-spacing: .3px; }
.brand-sub { color: rgba(255,255,255,.6); font-size: 11px; font-weight: 400; margin-left: 2px; }
.topnav-links { display: flex; align-items: center; gap: 4px; }
.nav-link {
  color: rgba(255,255,255,.8); font-size: 13.5px; padding: 8px 14px;
  border-radius: 6px; transition: all .2s;
}
.nav-link:hover, .nav-link.active { background: rgba(255,255,255,.15); color: #fff; text-decoration: none; }
.nav-link-cta { background: rgba(255,255,255,.2); color: #fff !important; font-weight: 600; }
.nav-link-cta:hover { background: rgba(255,255,255,.3); }

/* ============================================================
   LAYOUT
   ============================================================ */
.container { max-width: 1100px; margin: 0 auto; padding: calc(var(--nav-h) + 24px) 20px 40px; }
.container-wide { max-width: 1400px; }

.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; color: var(--blue); }
.page-header p { color: var(--gray); margin-top: 4px; }

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.section-header h1, .section-header h2 { font-size: 20px; color: var(--blue); }

/* ============================================================
   STATS GRID
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--blue);
  transition: transform .2s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-blue { border-color: var(--blue); }
.stat-orange { border-color: var(--orange); }
.stat-teal { border-color: #1abc9c; }
.stat-green { border-color: var(--green); }
.stat-purple { border-color: #8e44ad; }
.stat-gray { border-color: var(--gray); }
.stat-number { font-size: 26px; font-weight: 700; color: var(--blue); line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-weight: 500; }

/* ============================================================
   FILTROS
   ============================================================ */
.filtros-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.input-busca {
  flex: 1; min-width: 200px; padding: 9px 14px;
  border: 1.5px solid var(--gray-border); border-radius: var(--radius);
  font-size: 13.5px; font-family: var(--font);
  transition: border-color .2s;
}
.input-busca:focus { outline: none; border-color: var(--blue-light); }
.select-filtro {
  padding: 9px 12px; border: 1.5px solid var(--gray-border);
  border-radius: var(--radius); font-size: 13.5px; font-family: var(--font);
  background: var(--white); cursor: pointer;
}

/* ============================================================
   TABELAS
   ============================================================ */
.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); }
.data-table { width: 100%; border-collapse: collapse; background: var(--white); font-size: 13.5px; }
.data-table thead tr { background: var(--blue); }
.data-table thead th { color: #fff; padding: 11px 12px; text-align: left; font-weight: 600; white-space: nowrap; font-size: 12.5px; }
.data-table tbody tr { border-bottom: 1px solid #edf0f3; transition: background .15s; }
.data-table tbody tr:hover { background: var(--blue-pale); }
.data-table tbody td { padding: 11px 12px; vertical-align: middle; }

.titulo-cell { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.valor-cell { text-align: right; font-weight: 600; color: var(--blue); }
.acoes-cell { text-align: center; white-space: nowrap; }
.btn-icon { font-size: 16px; padding: 3px 6px; text-decoration: none; opacity: .7; transition: opacity .2s; }
.btn-icon:hover { opacity: 1; text-decoration: none; }
.btn-icon-sm { background: none; border: none; font-size: 14px; cursor: pointer; opacity: .6; padding: 2px 4px; }
.btn-icon-sm:hover { opacity: 1; }

/* Linha da tabela de linhas de orçamento */
.linhas-table .linha-titulo td { background: #d6eaf8 !important; color: var(--blue); font-size: 13px; }
.linhas-table .linha-subtitulo td { background: #eaecee !important; color: #555; font-style: italic; }
.linhas-table td { padding: 9px 10px !important; }

.input-inline {
  width: 80px; padding: 4px 6px; border: 1px solid var(--gray-border);
  border-radius: 4px; font-size: 13px; text-align: center;
  font-family: var(--font);
}
.input-inline:focus { outline: none; border-color: var(--blue-light); }
.input-right { text-align: right; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
}
.badge-rascunho { background: #fff3cd; color: #856404; }
.badge-enviado  { background: #cce5ff; color: #004085; }
.badge-aprovado { background: #d4edda; color: #155724; }
.badge-rejeitado{ background: #f8d7da; color: #721c24; }
.badge-cancelado{ background: #e2e3e5; color: #383d41; }

.select-estado {
  border: 2px solid currentColor; border-radius: 6px; padding: 6px 10px;
  font-weight: 600; font-size: 13px; cursor: pointer; font-family: var(--font);
}
.badge-select.badge-rascunho { background: #fff3cd; color: #856404; }
.badge-select.badge-enviado  { background: #cce5ff; color: #004085; }
.badge-select.badge-aprovado { background: #d4edda; color: #155724; }
.badge-select.badge-rejeitado{ background: #f8d7da; color: #721c24; }
.badge-select.badge-cancelado{ background: #e2e3e5; color: #383d41; }

/* ============================================================
   BOTÕES
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius); font-size: 13.5px;
  font-weight: 600; font-family: var(--font); cursor: pointer;
  border: 1.5px solid transparent; transition: all .2s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; opacity: .9; transform: translateY(-1px); }
.btn:active { transform: none; }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-light); border-color: var(--blue-light); color: #fff; }
.btn-secondary { background: var(--white); color: var(--blue); border-color: var(--blue); }
.btn-secondary:hover { background: var(--blue-pale); }
.btn-ghost { background: transparent; color: var(--gray); border-color: var(--gray-border); }
.btn-ghost:hover { background: var(--gray-light); }
.btn-large { padding: 12px 28px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-full { width: 100%; justify-content: center; margin-bottom: 6px; }

/* ============================================================
   FORMULÁRIOS
   ============================================================ */
.form-grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.form-grid-1col { display: flex; flex-direction: column; gap: 20px; margin-bottom: 20px; }

.form-card { background: var(--white); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.form-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.form-card-title { font-size: 16px; font-weight: 700; color: var(--blue); margin-bottom: 16px; }
.form-card-desc { color: var(--gray); font-size: 13px; margin: -8px 0 16px; line-height: 1.5; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.form-control {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--gray-border);
  border-radius: 6px; font-size: 13.5px; font-family: var(--font);
  transition: border-color .2s; color: var(--text);
  background: var(--white);
}
.form-control:focus { outline: none; border-color: var(--blue-light); box-shadow: 0 0 0 3px rgba(46,134,193,.12); }
textarea.form-control { resize: vertical; min-height: 70px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.required { color: var(--red); }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-hint-link { font-size: 12px; color: var(--blue-light); display: block; margin-top: 4px; }

.form-actions { display: flex; justify-content: flex-end; gap: 12px; padding: 20px 0; }

/* ============================================================
   UPLOAD
   ============================================================ */
.upload-area {
  border: 2px dashed var(--blue-light); border-radius: var(--radius);
  padding: 32px 20px; text-align: center; cursor: pointer;
  transition: all .2s; background: var(--blue-pale); position: relative;
}
.upload-area:hover, .upload-area.drag-over { border-color: var(--blue); background: #dbeeff; }
.upload-icon { font-size: 36px; margin-bottom: 10px; }
.upload-area p { color: var(--gray); font-size: 14px; margin-bottom: 4px; }
.upload-hint { font-size: 12px !important; color: var(--text-muted) !important; }
.file-input-hidden { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

.file-list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.file-item { display: flex; justify-content: space-between; align-items: center; padding: 7px 12px; background: var(--gray-light); border-radius: 6px; font-size: 13px; }
.file-size { color: var(--text-muted); font-size: 12px; }

.ia-info-box { display: flex; gap: 14px; background: #f0faf5; border: 1px solid #a9dfbf; border-radius: var(--radius); padding: 14px 16px; margin-top: 16px; }
.ia-info-icon { font-size: 24px; flex-shrink: 0; }
.ia-info-box strong { color: var(--green); font-size: 14px; }
.ia-info-box p { font-size: 12.5px; color: var(--gray); margin: 3px 0 6px; }
.ia-info-box ul { font-size: 12.5px; color: var(--gray); padding-left: 16px; }
.ia-info-box li { margin-bottom: 2px; }

/* ============================================================
   VER ORÇAMENTO LAYOUT
   ============================================================ */
.orc-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 20px; gap: 16px;
}
.orc-header-left .breadcrumb { font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px; }
.orc-header-left h1 { font-size: 21px; color: var(--blue); }
.orc-local { color: var(--gray); font-size: 13px; margin-top: 4px; }
.orc-header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.orc-layout { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
.orc-main { display: flex; flex-direction: column; gap: 20px; }
.orc-sidebar { display: flex; flex-direction: column; gap: 16px; position: sticky; top: calc(var(--nav-h) + 16px); }

/* IA Resumo */
.ia-resumo-box {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px;
  background: #f0faf5; border: 1px solid #a9dfbf; border-radius: var(--radius);
}
.ia-resumo-icon { font-size: 24px; flex-shrink: 0; }
.ia-resumo-box strong { color: var(--green); font-size: 13px; display: block; margin-bottom: 3px; }
.ia-resumo-box p { font-size: 12.5px; color: var(--gray); line-height: 1.5; }

/* Loading */
.loading-box { display: flex; align-items: center; gap: 14px; padding: 16px; background: #fff8e1; border-radius: 8px; }
.spinner { width: 24px; height: 24px; border: 3px solid #f3e5ab; border-top-color: var(--orange); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Totais */
.totais-section { display: flex; justify-content: flex-end; margin-top: 16px; padding-top: 12px; border-top: 2px solid var(--gray-border); }
.totais-table { border-collapse: collapse; min-width: 240px; }
.totais-table td { padding: 6px 12px; font-size: 13.5px; }
.totais-table tr:nth-child(odd) td { background: var(--gray-light); }
.totais-table .total-final td { background: var(--blue); color: #fff; font-size: 15px; border-radius: 4px; }

/* Info table (sidebar) */
.info-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.info-table td { padding: 5px 4px; border-bottom: 1px solid #eee; }
.info-table td:first-child { color: var(--text-muted); width: 55%; }

/* Documentos grid */
.docs-grid { display: flex; flex-direction: column; gap: 8px; }
.doc-card { display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; border-radius: 6px; border: 1px solid var(--gray-border); background: var(--white); }
.doc-card-ok { border-left: 3px solid var(--green); }
.doc-card-erro { border-left: 3px solid var(--red); background: var(--red-pale); }
.doc-icon { font-size: 22px; flex-shrink: 0; }
.doc-info { font-size: 12.5px; line-height: 1.5; }
.doc-info strong { font-size: 13px; }

/* ============================================================
   MODAIS
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal { background: var(--white); border-radius: 10px; box-shadow: var(--shadow-md); width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto; }
.modal-large { max-width: 680px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--gray-border); }
.modal-header h3 { font-size: 16px; color: var(--blue); }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 20px 22px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--gray-border); background: var(--gray-light); border-radius: 0 0 10px 10px; }

/* ============================================================
   ALERTAS
   ============================================================ */
.alert {
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px;
  font-size: 13.5px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.alert-sucesso { background: var(--green-pale); color: var(--green); border: 1px solid #a9dfbf; }
.alert-erro    { background: var(--red-pale); color: var(--red); border: 1px solid #f5c6cb; }
.alert-aviso   { background: var(--orange-pale); color: #8a5700; border: 1px solid #fad7a0; }
.alert-close { background: none; border: none; font-size: 20px; cursor: pointer; color: inherit; opacity: .6; flex-shrink: 0; }
.alert-close:hover { opacity: 1; }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  background: var(--blue); color: #fff; padding: 12px 20px;
  border-radius: var(--radius); font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-md); animation: fadeInUp .3s ease;
}
@keyframes fadeInUp { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:none; } }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); }
.empty-icon { font-size: 50px; margin-bottom: 14px; }
.empty-state h3 { font-size: 18px; color: var(--text); margin-bottom: 8px; }
.empty-state p { margin-bottom: 20px; }

/* ============================================================
   UTILITÁRIOS
   ============================================================ */
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
small { font-size: 11.5px; }

/* ============================================================
   RESPONSIVO
   ============================================================ */
@media (max-width: 900px) {
  .form-grid-2col { grid-template-columns: 1fr; }
  .orc-layout { grid-template-columns: 1fr; }
  .orc-sidebar { position: static; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  .topnav { padding: 0 14px; }
  .brand-name { font-size: 14px; }
  .nav-link { padding: 6px 8px; font-size: 12px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
  .orc-header { flex-direction: column; }
  .orc-header-right { flex-wrap: wrap; }
  .container { padding-top: calc(var(--nav-h) + 14px); padding-left: 12px; padding-right: 12px; }
}
