/* Cuotas Matrix Stylesheet (Excel-like Interactive Grid) */

.matrix-wrapper {
  position: relative;
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  box-shadow: var(--shadow-md);
  max-height: 75vh;
  overflow-y: auto;
}

.matrix-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}

/* Headers */
.matrix-table thead th {
  position: sticky;
  top: 0;
  background-color: #0f172a;
  color: var(--text-secondary);
  font-weight: 600;
  padding: 12px 14px;
  border-bottom: 2px solid var(--border-color);
  border-right: 1px solid var(--border-light);
  white-space: nowrap;
  z-index: 10;
  text-align: center;
}

.matrix-table thead th.col-sticky-1 {
  left: 0;
  z-index: 20;
  text-align: left;
  min-width: 85px;
  width: 85px;
}

.matrix-table thead th.col-sticky-2 {
  left: 85px;
  z-index: 20;
  text-align: left;
  min-width: 350px;
  width: 350px;
}

.matrix-table thead th.col-sticky-3 {
  left: 435px;
  z-index: 20;
  text-align: center;
  min-width: 65px;
  width: 65px;
}

.matrix-table thead th.month-header {
  min-width: 145px;
  width: 145px;
}

.matrix-table thead th.month-header.is-current {
  background-color: #1e3a8a;
  color: #60a5fa;
  border-top: 3px solid #3b82f6;
}

/* Sticky Data Columns */
.matrix-table td.col-sticky-1 {
  position: sticky;
  left: 0;
  background-color: var(--bg-card);
  z-index: 5;
  border-right: 1px solid var(--border-color);
  font-size: 0.825rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 85px;
  width: 85px;
}

.matrix-table td.col-sticky-2 {
  position: sticky;
  left: 85px;
  background-color: var(--bg-card);
  z-index: 5;
  border-right: 1px solid var(--border-color);
  font-weight: 500;
  color: var(--text-primary);
  min-width: 350px;
  max-width: 350px;
  width: 350px;
}

.matrix-concept-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.matrix-concept-title {
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.35;
  word-break: break-word;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  text-align: left;
}

.matrix-actions-stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
  align-items: center;
}

.matrix-btn-mini {
  width: 22px;
  height: 20px;
  min-width: 22px;
  min-height: 20px;
  padding: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.matrix-table td.col-sticky-3 {
  position: sticky;
  left: 435px;
  background-color: var(--bg-card);
  z-index: 5;
  border-right: 2px solid var(--border-color);
  text-align: center;
  font-weight: 600;
  color: var(--accent-blue);
  box-shadow: 4px 0 6px -2px rgba(0, 0, 0, 0.3);
  min-width: 65px;
  width: 65px;
}

.matrix-table tr:hover td.col-sticky-1,
.matrix-table tr:hover td.col-sticky-2,
.matrix-table tr:hover td.col-sticky-3 {
  background-color: var(--bg-card-hover);
}

/* Standard Cells */
.matrix-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
  vertical-align: middle;
  text-align: right;
  font-family: var(--font-mono);
  white-space: nowrap;
}

.matrix-table tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
}

/* Cuota installment styling */
.cuota-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: transform 0.15s ease;
}

.cuota-cell.is-paid {
  background-color: rgba(16, 185, 129, 0.22);
  border: 1px solid rgba(16, 185, 129, 0.5);
  color: #34d399;
}

.cuota-cell.is-pending {
  background-color: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

.cuota-tag {
  font-size: 0.7rem;
  opacity: 0.8;
  letter-spacing: 0.02em;
  font-family: var(--font-family);
  white-space: nowrap;
}

.cuota-amount {
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Footer Section */
.matrix-table tfoot {
  position: sticky;
  bottom: 0;
  z-index: 15;
  background-color: #0b1120;
}

.matrix-table tfoot tr td {
  border-top: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 0.925rem;
  white-space: nowrap;
}

.matrix-table tfoot td.col-sticky-1,
.matrix-table tfoot td.col-sticky-2,
.matrix-table tfoot td.col-sticky-3 {
  background-color: #0b1120;
  z-index: 25;
}

.matrix-table tfoot tr.footer-subtotal td {
  background-color: rgba(15, 23, 42, 0.95);
  color: var(--text-secondary);
}

.matrix-table tfoot tr.footer-adjustment td {
  background-color: rgba(15, 23, 42, 0.95);
  font-size: 0.85rem;
}

.matrix-table tfoot tr.footer-adjustment.positive td {
  color: #fb7185;
}

.matrix-table tfoot tr.footer-adjustment.negative td {
  color: #34d399;
}

.matrix-table tfoot tr.footer-total td {
  background: linear-gradient(90deg, #1e293b, #0f172a);
  color: #f8fafc;
  font-size: 1rem;
  font-weight: 700;
  border-top: 2px solid var(--accent-blue);
  border-bottom: 2px solid var(--accent-blue);
}

.adj-btn {
  background: none;
  border: 1px dashed var(--border-color);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  font-size: 0.75rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.adj-btn:hover {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}
