/* ============================================================
   SOLO FINANCES - COMPONENTES UI
============================================================ */

/* ============================================================
   BOTÕES
============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 8px 18px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: 600;
  border: none;
  outline: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), #818CF8);
  color: #fff;
  box-shadow: 0 4px 14px rgba(99,102,241,0.4);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-hover), #6366F1);
  box-shadow: 0 6px 20px rgba(99,102,241,0.5);
  transform: translateY(-1px);
}
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}
.btn-ghost:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--text-muted);
}
.btn-danger  { background: var(--color-danger);  color: #fff; }
.btn-danger:hover  { background: #BE123C; }
.btn-success { background: var(--color-success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-warning { background: #D97706; color: #fff; }
.btn-warning:hover { background: #B45309; }
.btn-sm  { padding: 5px 12px;  font-size: var(--font-size-sm); border-radius: var(--radius-sm); }
.btn-lg  { padding: 12px 28px; font-size: var(--font-size-md); border-radius: var(--radius-md); }
.btn-full { width: 100%; }

/* ============================================================
   CAMPOS DE FORMULÁRIO
============================================================ */
.field-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.field-label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.field-input {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: var(--font-size-base);
  width: 100%;
  transition: all var(--transition-fast);
  outline: none;
  appearance: none;
}
.field-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--bg-surface);
}
.field-input::placeholder { color: var(--text-disabled); }

select.field-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394A3B8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}
select.field-input option { background: var(--bg-elevated); }
textarea.field-input { resize: vertical; min-height: 80px; }
input[type="color"].field-input { height: 44px; padding: 4px 8px; cursor: pointer; }

.input-wrapper { position: relative; display: flex; align-items: center; }
.input-wrapper .input-icon {
  position: absolute;
  left: 12px;
  font-size: 16px;
  pointer-events: none;
}
.input-wrapper .field-input { padding-left: 40px; }

/* ============================================================
   MODAIS
============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: var(--space-8);
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}
.modal-header h3 { font-size: var(--font-size-lg); font-weight: 700; }
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ============================================================
   TOAST NOTIFICATIONS
============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: 500;
  min-width: 280px;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease forwards;
  pointer-events: all;
  border-left: 4px solid transparent;
  background: var(--bg-elevated);
}
.toast.success { border-left-color: var(--color-success); }
.toast.error   { border-left-color: var(--color-danger); }
.toast.warning { border-left-color: var(--color-warning); }
.toast.info    { border-left-color: var(--color-info); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(40px); }
}
.toast.removing { animation: toastOut 0.25s ease forwards; }

/* ============================================================
   TABELA DE DADOS
============================================================ */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
}
.data-table { 
  width: 100%; 
  border-collapse: separate;  /* collapse quebra position:sticky no thead */
  border-spacing: 0; 
  font-size: var(--font-size-sm); 
}
.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 12px 16px;
  text-align: left;
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
.data-table tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition-fast);
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-elevated); }
.data-table tbody td { padding: 11px 16px; color: var(--text-primary); vertical-align: middle; }

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.status-pendente   { background: rgba(245,158,11,0.15);  color: var(--color-warning); }
.status-pago       { background: rgba(16,185,129,0.15);  color: var(--color-success); }
.status-conciliado { background: rgba(59,130,246,0.15);  color: var(--color-info); }
.status-efetivado  { background: rgba(139,92,246,0.15);  color: var(--color-purple); }
.status-pendente-conciliada { background: rgba(59,130,246,0.15); color: var(--color-info); border: 1px dashed var(--color-info); }
.status-pago-conciliada { background: rgba(16,185,129,0.15); color: var(--color-success); border: 1px dashed var(--color-success); }

/* ============================================================
   FILTROS BAR
============================================================ */
.filters-bar {
  display: flex;
  align-items: flex-end;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
  padding: var(--space-4) var(--space-5);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}
.filter-group { display: flex; flex-direction: column; gap: var(--space-1); }
.filter-group label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.filter-select, .filter-input {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  outline: none;
  transition: all var(--transition-fast);
  min-width: 100px;
}
.filter-select:focus, .filter-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-glow);
}
.filter-select option { background: var(--bg-elevated); }
.filter-input { min-width: 200px; }

/* ============================================================
   EMPTY STATE
============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12);
  text-align: center;
  gap: var(--space-4);
}
.empty-icon { font-size: 64px; opacity: 0.5; }
.empty-state h3 { font-size: var(--font-size-xl); color: var(--text-secondary); }
.empty-state p  { color: var(--text-muted); max-width: 360px; }

/* ============================================================
   FORM GRID
============================================================ */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}
.field-span2 { grid-column: span 2; }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border-color);
}

/* Action buttons na tabela */
.action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}
.action-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.action-btn.danger:hover  { color: var(--color-danger); }
.action-btn.success:hover { color: var(--color-success); }

/* ============================================================
   EXTRATO — LINHA INTERATIVA (DUPLO-CLIQUE PARA EDITAR)
============================================================ */
.extrato-row { cursor: default; }
.extrato-row:hover { background: var(--bg-elevated) !important; }
.extrato-row:hover td { position: relative; }
/* Dica de edição no hover */
.extrato-row:hover::after {
  content: '';
}
.acoes-col { white-space: nowrap; }

/* ============================================================
   TRANSFERÊNCIA PAR — CONECTOR VISUAL
============================================================ */
.transf-par-top td    { border-bottom: none !important; padding-bottom: 4px !important; }
.transf-par-bottom td { border-top: none !important; padding-top: 4px !important; }

.transf-par {
  background: rgba(99, 102, 241, 0.04) !important;
}
.transf-par:hover {
  background: rgba(99, 102, 241, 0.1) !important;
}
.transf-par-top { border-top: 1px solid rgba(99,102,241,0.25) !important; }
.transf-par-bottom { border-bottom: 1px solid rgba(99,102,241,0.25) !important; }

/* Conector gráfico vertical */
.transf-conector-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 16px;
  flex-shrink: 0;
  gap: 0;
}
.transf-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.transf-dot-saida  { background: var(--color-danger); box-shadow: 0 0 6px rgba(225,29,72,0.5); }
.transf-dot-entrada { background: var(--color-success); box-shadow: 0 0 6px rgba(16,185,129,0.5); }
.transf-linha {
  width: 2px;
  flex: 1;
  min-height: 10px;
  background: linear-gradient(to bottom, var(--color-danger), var(--color-success));
  opacity: 0.5;
}



/* -- Modal Fatura: Resumo financeiro -------------------------- */
.fat-resumo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  background: var(--bg-lighter);
  border-radius: 10px;
  padding: 14px 16px;
}

.fat-resumo-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.fat-resumo-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.fat-resumo-val {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.fat-resumo-total {
  color: var(--color-danger);
}

/* -- Calculadora Flutuante --------------------------------- */
#calc-popup {
  position: fixed;
  z-index: 99999;
  width: 240px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: inherit;
  animation: calcPop .12s ease;
}

@keyframes calcPop {
  from { opacity:0; transform:scale(.92) translateY(-6px); }
  to   { opacity:1; transform:scale(1)   translateY(0);    }
}

#calc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border-color);
}

#calc-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 6px;
  transition: background .1s;
}
#calc-close:hover { background: rgba(239,68,68,.15); color: var(--color-danger); }

#calc-display-wrap {
  padding: 8px 14px 6px;
  background: var(--bg-darker, #0f0f1a);
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
}

#calc-expr {
  font-size: 10px;
  color: var(--text-muted);
  min-height: 14px;
  letter-spacing: .3px;
}

#calc-display {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  word-break: break-all;
  text-align: right;
  line-height: 1.2;
}

#calc-btns {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border-color);
  border-top: 1px solid var(--border-color);
}

.c-btn {
  background: var(--bg-card);
  border: none;
  padding: 13px 0;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-primary);
  transition: background .1s;
  font-family: inherit;
}
.c-btn:hover  { background: var(--bg-lighter); }
.c-btn:active { background: rgba(99,102,241,.2); }

.c-fn  { color: #f59e0b; font-weight: 700; }
.c-op  { color: var(--color-primary); font-weight: 800; font-size: 17px; }
.c-eq  { background: var(--color-primary); color: #fff; font-size: 18px; }
.c-eq:hover  { background: #5558e0; }
.c-eq:focus  { outline: 2px solid rgba(99,102,241,.5); outline-offset: -2px; }
.c-zero { grid-column: span 2; }

#calc-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-darker, #0f0f1a);
  flex-wrap: wrap;
}

#calc-apply-btn {
  margin-left: auto;
  background: var(--color-success, #10b981);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
  white-space: nowrap;
}
#calc-apply-btn:disabled {
  opacity: .35;
  cursor: default;
}
#calc-apply-btn:not(:disabled):hover { opacity: .85; }

/* -- Janelas Arrastveis (drag-windows.js) ----------------- */

/* O overlay de janelas arrastveis serve apenas de backdrop 
   no centraliza mais o filho (o JS cuida do posicionamento). */
.drag-overlay {
  align-items: flex-start !important;
  justify-content: flex-start !important;
}

/* Cursor grab no header da calculadora ao virar janela */
#calc-header {
  cursor: grab;
  user-select: none;
}
#calc-header:active { cursor: grabbing; }

/* Header do modal de lanamento: cursor indica que  arrastvel */
.prem-modal-header {
  cursor: grab;
}
.prem-modal-header:active { cursor: grabbing; }

/* Indicador visual de janela arrastvel (hint no canto) */
.drag-hint {
  font-size: 14px;
  color: var(--text-muted);
  opacity: 0.35;
  margin-right: 6px;
  user-select: none;
  pointer-events: none;
  flex-shrink: 0;
}
