/* ═══════════════════════════════════════
   Prudens Finance — Transactions Page CSS
   Phase 2 (updated Phase 4)
═══════════════════════════════════════ */

/* ── Page Layout ──────────────────────── */
.page-transactions {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

/* ── Filter bar ───────────────────────── */
.filter-bar {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding: 1rem 1.25rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.filter-search {
  flex: 1;
  min-width: 180px;
}

.filter-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filter-select,
.filter-input {
  height: 2.25rem;
  padding: 0 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 0.45rem;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.15s;
}

.filter-input {
  width: 100%;
}

.filter-select:focus,
.filter-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-alpha);
}

/* ── Summary Strip ────────────────────── */
.tx-summary {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.summary-chip {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.6rem 1rem;
  border-radius: 0.6rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  flex: 1;
  min-width: 110px;
}

.chip-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.chip-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.summary-chip.income .chip-value { color: var(--color-income); }
.summary-chip.expense .chip-value { color: var(--color-expense); }
.summary-chip.net .chip-value { color: var(--color-text); }

/* ── Table ────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  background: var(--color-surface);
}

.tx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.tx-table thead {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.tx-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.tx-table td {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: middle;
}

.tx-table tbody tr:last-child td {
  border-bottom: none;
}

.tx-table tbody tr:hover {
  background: var(--color-hover);
}

/* Column widths */
.col-date     { width: 110px; white-space: nowrap; }
.col-category { width: 180px; }
.col-partner  { }
.col-payment  { width: 130px; }
.col-amount   { width: 120px; text-align: right; }
.col-actions  { width: 90px; text-align: right; }

/* Amount cell */
.tx-amount {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tx-amount.income { color: var(--color-income); }
.tx-amount.expense { color: var(--color-expense); }

/* Category badge */
.tx-category {
  display: inline-block;
  font-size: 0.78rem;
}
.tx-category-group {
  font-size: 0.68rem;
  color: var(--color-text-muted);
  margin-top: 0.1rem;
}

/* Payment badge */
.payment-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--color-badge-bg);
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* Notes tooltip */
.tx-partner {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.tx-notes {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}

/* Action buttons */
.action-btns {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-end;
}

.btn-icon-only {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--color-border);
  border-radius: 0.4rem;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  transition: all 0.15s;
}
.btn-icon-only:hover {
  background: var(--color-hover);
  color: var(--color-text);
}
.btn-icon-only.delete:hover {
  background: var(--color-danger-light);
  border-color: var(--color-danger);
  color: var(--color-danger);
}

/* Loading & empty states */
.tx-loading td {
  text-align: center;
  padding: 3rem;
}

.tx-empty td {
  text-align: center;
  padding: 3rem;
  color: var(--color-text-muted);
}

/* ── Pagination ───────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 1.25rem;
}

.page-btn {
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 0.4rem;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.15s;
}
.page-btn:hover { background: var(--color-hover); }
.page-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
  font-weight: 600;
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Modal ────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.15s ease;
}

.modal-overlay[hidden] { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal {
  background: var(--color-surface);
  border-radius: 1rem;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  animation: slideUp 0.2s ease;
}

.modal-sm { max-width: 400px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  color: var(--color-text);
}

.modal-close {
  width: 2rem;
  height: 2rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--color-text-muted);
  border-radius: 0.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.modal-close:hover {
  background: var(--color-hover);
  color: var(--color-text);
}

.modal-body { padding: 1.25rem 1.5rem; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem 1.25rem;
  border-top: 1px solid var(--color-border);
  margin-top: 1rem;
}

/* ── Form styles ──────────────────────── */
.form-row { display: flex; gap: 1rem; }
.form-row-2 > .form-group { flex: 1; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}
.form-group:last-child { margin-bottom: 0; }

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-hint {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--color-text-muted);
}

.form-control {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-alpha);
}

.form-control[readonly] {
  background: var(--color-bg-muted);
  color: var(--color-text-muted);
  cursor: default;
}

.form-control.is-invalid { border-color: var(--color-danger); }

.amount-input { font-variant-numeric: tabular-nums; font-weight: 600; }

textarea.form-control { resize: vertical; min-height: 3rem; }

.form-error {
  margin-top: 0.5rem;
  padding: 0.6rem 0.8rem;
  background: var(--color-danger-light);
  border: 1px solid var(--color-danger);
  border-radius: 0.5rem;
  color: var(--color-danger);
  font-size: 0.85rem;
}

/* Delete confirm */
.confirm-text { margin: 0 0 0.75rem; color: var(--color-text); }
.confirm-detail {
  padding: 0.6rem 0.8rem;
  background: var(--color-bg-muted);
  border-radius: 0.5rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* ── Toast ────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--color-text);
  color: var(--color-bg);
  border-radius: 0.6rem;
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 200;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  animation: slideUp 0.2s ease;
}
.toast[hidden] { display: none; }
.toast.success { background: var(--color-income); color: #fff; }
.toast.error   { background: var(--color-danger); color: #fff; }

/* ── Responsive ───────────────────────── */
@media (max-width: 768px) {
  .page-transactions { padding: 1rem 0.75rem 3rem; }

  .filter-bar {
    padding: 0.75rem;
    gap: 0.5rem;
  }

  .col-payment,
  .col-category .tx-category-group { display: none; }

  .tx-notes { max-width: 140px; }

  .form-row { flex-direction: column; gap: 0; }

  .modal { border-radius: 0.75rem; }

  .tx-summary { gap: 0.5rem; }
  .summary-chip { min-width: 80px; padding: 0.5rem 0.75rem; }
  .chip-value { font-size: 0.9rem; }
}

@media (max-width: 480px) {
  .col-payment { display: none; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .btn-primary { width: 100%; justify-content: center; }
}
