/* componentes.css — botões, cards, formulários, tabelas, badges, modais... */

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: 500; font-size: var(--fs-sm);
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-2); border-color: #B8BDC3; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--samid-laranja); border-color: var(--samid-laranja); color: var(--on-primary); font-weight: 600; }
.btn-primary:hover { background: #F09A38; border-color: #F09A38; }
.btn-dark { background: var(--samid-grafite-escuro); border-color: var(--samid-grafite-escuro); color: #fff; }
.btn-dark:hover { background: #45484B; }
.btn-danger { color: var(--danger); border-color: #F1B9B3; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: var(--fs-xs); }
.btn-icon { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); cursor: pointer; padding: 0; border-color: transparent; background: transparent; color: var(--text-2); }
.btn-icon svg { width: 16px; height: 16px; }
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-block { width: 100%; }
.btn .spinner { width: 14px; height: 14px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 0; }
.card__head h3 { font-size: 15px; }
.card__head p { margin: 0; font-size: var(--fs-xs); color: var(--text-muted); }
.card__body { padding: 16px 20px 20px; }
.card__body--flush { padding: 0; }

/* KPI */
.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden; }
.kpi__label { font-size: var(--fs-xs); color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; display: flex; align-items: center; gap: 6px; }
.kpi__value { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi__hint { font-size: var(--fs-xs); color: var(--text-muted); }
.kpi--accent { border-top: 3px solid var(--samid-laranja); }
.kpi--clickable { cursor: pointer; } .kpi--clickable:hover { border-color: var(--border-strong); }
.kpi .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---------- Formulários ---------- */
.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px 16px; }
.col-2 { grid-column: span 2; } .col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; } .col-6 { grid-column: span 6; } .col-7 { grid-column: span 7; } .col-8 { grid-column: span 8; }
.col-9 { grid-column: span 9; } .col-10 { grid-column: span 10; } .col-12 { grid-column: span 12; }
@media (max-width: 900px) { .col-2, .col-3, .col-4, .col-5 { grid-column: span 6; } .col-6, .col-7, .col-8, .col-9, .col-10 { grid-column: span 12; } }
@media (max-width: 560px) { .form-grid > * { grid-column: span 12; } }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: var(--fs-xs); font-weight: 500; color: var(--text-2); }
.field label .req { color: var(--danger); }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); font-size: var(--fs-sm); transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--samid-laranja); box-shadow: var(--focus); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-2); color: var(--text-2); }
.input.is-invalid, .select.is-invalid { border-color: var(--danger); }
.field__hint { font-size: 11px; color: var(--text-muted); }
.form-section { padding: 18px 20px; border-top: 1px solid var(--border); }
.form-section:first-child { border-top: 0; }
.form-section h3 { font-size: 14px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.form-section h3::before { content: ''; width: 4px; height: 16px; background: var(--samid-laranja); border-radius: 2px; }
.input-group { display: flex; } .input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: 0; }

/* ---------- Filtros ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 14px 16px; margin-bottom: 18px; }
.filters .field { width: 170px; }
.filters .field--wide { width: 240px; }
.filters__actions { display: flex; gap: 8px; margin-left: auto; }
@media (max-width: 640px) { .filters .field, .filters .field--wide { width: calc(50% - 5px); } }

/* ---------- Tabela ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); }
.table th {
  text-align: left; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); background: var(--surface-2); padding: 10px 10px; border-bottom: 1px solid var(--border);
  white-space: nowrap; position: sticky; top: 0;
}
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text); }
.table th .sort-ind { margin-left: 4px; opacity: .7; }
.table td { padding: 10px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover td { background: #FCFAF7; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .t-right { text-align: right; } .table .t-center { text-align: center; }
.table .t-code { font-weight: 600; color: var(--text); white-space: nowrap; }
.table .t-actions { white-space: nowrap; text-align: right; width: 1%; }
.table .t-actions .btn-icon { width: 28px; height: 28px; }
.table td.t-nowrap { white-space: nowrap; }
.table th:first-child, .table td:first-child { padding-left: 16px; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); font-size: var(--fs-xs); color: var(--text-muted); flex-wrap: wrap; }
.pager { display: flex; gap: 4px; align-items: center; }
.pager .btn { min-width: 32px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap; border: 1px solid transparent;
  background: var(--surface-2); color: var(--text-2);
}
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--badge-cor, currentColor); }
.badge--status { background: color-mix(in srgb, var(--badge-cor) 10%, white); border-color: color-mix(in srgb, var(--badge-cor) 30%, white); color: var(--text); }
.badge--plain::before { display: none; }
.prazo { font-size: 12px; font-weight: 500; display: inline-flex; align-items: center; gap: 5px; }
.prazo--vencida { color: var(--danger); } .prazo--vencendo { color: var(--warn); } .prazo--no_prazo { color: var(--ok); }
.prazo--sem_prazo, .prazo--encerrada { color: var(--text-muted); }
.pill-role { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--samid-laranja-claro); color: var(--samid-laranja-escuro); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Abas ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 12px; overflow-x: auto; }
.tab { background: none; border: 0; padding: 12px 14px; font-weight: 500; font-size: var(--fs-sm); color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); border-bottom-color: var(--samid-laranja); }
.tab .count { font-size: 11px; background: var(--bg); padding: 0 7px; border-radius: 999px; color: var(--text-2); }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,18,22,.45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: 90vh; display: flex; flex-direction: column; }
.modal--lg { max-width: 820px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal__body { padding: 20px; overflow-y: auto; }
.modal__foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }

/* ---------- Toast ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { min-width: 260px; max-width: 420px; padding: 12px 16px; border-radius: var(--radius); background: var(--samid-grafite-escuro); color: #fff; box-shadow: var(--shadow-lg); font-size: var(--fs-sm); display: flex; gap: 10px; align-items: flex-start; animation: toast-in .2s ease; }
.toast--ok { border-left: 4px solid var(--samid-verde-claro); }
.toast--erro { border-left: 4px solid #F97066; }
.toast--info { border-left: 4px solid var(--samid-laranja); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Estados ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty svg { width: 40px; height: 40px; margin: 0 auto 10px; opacity: .5; }
.spinner { width: 22px; height: 22px; border: 2px solid var(--border); border-top-color: var(--samid-laranja); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px; color: var(--text-muted); }
.skeleton { background: linear-gradient(90deg, #EEF0F2 25%, #F6F7F8 50%, #EEF0F2 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--radius-sm); }
@keyframes sk { to { background-position: -200% 0; } }
.alert { padding: 12px 14px; border-radius: var(--radius); font-size: var(--fs-sm); display: flex; gap: 10px; align-items: flex-start; }
.alert--erro { background: var(--danger-bg); color: var(--danger); }
.alert--info { background: var(--info-bg); color: var(--info); }
.alert--warn { background: var(--warn-bg); color: var(--warn); }

/* ---------- Anexos ---------- */
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--text-muted); cursor: pointer; transition: border-color .15s, background .15s; font-size: var(--fs-sm); }
.dropzone:hover, .dropzone.is-over { border-color: var(--samid-laranja); background: var(--samid-laranja-claro); color: var(--text); }
.dropzone strong { color: var(--samid-laranja-escuro); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.thumb { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); aspect-ratio: 4/3; cursor: zoom-in; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb__label { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 10px 6px; background: linear-gradient(transparent, rgba(0,0,0,.65)); color: #fff; font-size: 11px; font-weight: 500; }
.thumb__del { position: absolute; top: 6px; right: 6px; background: rgba(255,255,255,.92); border-radius: 50%; }
.doc-list { display: flex; flex-direction: column; }
.doc-item { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.doc-item:last-child { border-bottom: 0; }
.doc-icon { width: 38px; height: 38px; border-radius: var(--radius-sm); display: grid; place-items: center; font-size: 10px; font-weight: 700; color: #fff; background: var(--samid-grafite); flex: none; }
.doc-icon--pdf { background: #B42318; } .doc-icon--xls { background: #2F7A3A; } .doc-icon--doc { background: #2F6FA8; }
.doc-meta { flex: 1; min-width: 0; } .doc-meta strong { display: block; font-size: var(--fs-sm); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta span { font-size: 11px; color: var(--text-muted); }
.lightbox { position: fixed; inset: 0; background: rgba(10,12,14,.92); z-index: 150; display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: 92vw; max-height: 84vh; border-radius: 6px; }
.lightbox__bar { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; color: #fff; font-size: var(--fs-sm); }
.lightbox__nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.12); border: 0; color: #fff; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; font-size: 22px; }
.lightbox__nav:hover { background: rgba(255,255,255,.22); }
.lightbox__nav--prev { left: 20px; } .lightbox__nav--next { right: 20px; }
.lightbox .btn { background: rgba(255,255,255,.12); color: #fff; border-color: transparent; }

/* ---------- Linha do tempo ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ''; position: absolute; left: 15px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 0 0 18px 44px; }
.tl-dot { position: absolute; left: 6px; top: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); display: grid; place-items: center; }
.tl-dot svg { width: 10px; height: 10px; }
.tl-item--trat .tl-dot { border-color: var(--samid-laranja); background: var(--samid-laranja-claro); }
.tl-item--status .tl-dot { border-color: var(--samid-verde); background: #EEF6EB; }
.tl-head { font-size: var(--fs-sm); } .tl-head strong { font-weight: 600; }
.tl-when { font-size: 11px; color: var(--text-muted); }
.tl-body { margin-top: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; font-size: var(--fs-sm); white-space: pre-wrap; }
.tl-change { font-size: 12px; color: var(--text-2); }
.tl-change del { color: var(--text-muted); }

/* ---------- Resumo financeiro ---------- */
.fin-summary { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.fin-summary > div { padding: 12px 14px; border-right: 1px solid var(--border); background: var(--surface); }
.fin-summary > div:last-child { border-right: 0; }
.fin-summary span { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; display: block; }
.fin-summary strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.fin-summary .is-total { background: var(--surface-2); }
.fin-summary .is-pend strong { color: var(--danger); }
.fin-summary .is-pend.is-zero strong { color: var(--ok); }
@media (max-width: 900px) { .fin-summary { grid-template-columns: repeat(3, 1fr); } .fin-summary > div { border-bottom: 1px solid var(--border); } }
.bar-split { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--bg); gap: 2px; margin-top: 12px; }
.bar-split > i { display: block; height: 100%; }

/* ---------- Atenção / alertas ---------- */
.alert-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.alert-tile { border-radius: var(--radius); padding: 12px 14px; border: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; cursor: pointer; background: var(--surface); text-align: left; }
.alert-tile:hover { border-color: var(--border-strong); }
.alert-tile strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.alert-tile span { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.alert-tile--danger { background: var(--danger-bg); border-color: #F6CBC6; }
.alert-tile--warn { background: var(--warn-bg); border-color: #F5DFA8; }
.alert-tile--ok { background: var(--ok-bg); border-color: #CDE6C5; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.mini-list li:last-child { border-bottom: 0; }
.mini-list .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Gráficos ---------- */
.chart-box { position: relative; height: 260px; }
.chart-box--tall { height: 320px; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { background: var(--surface); border: 0; padding: 4px 10px; font-size: 12px; cursor: pointer; color: var(--text-2); }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.is-active { background: var(--samid-grafite-escuro); color: #fff; }
.chart-table { font-size: 12px; max-height: 260px; overflow: auto; }
.field { position: relative; }
.field > [data-quick] { position: absolute; right: 0; top: -6px; height: 24px; padding: 0 6px; color: var(--samid-laranja-escuro); }
@media (max-width: 1600px) { .table .col-opt { display: none; } }
