/* Global styles additions for save icon pending state */
#saveIcon svg { fill: none; stroke: currentColor; }
#saveIcon.save-pending svg { fill: currentColor; stroke: none; }

/* Global styles for header and tab buttons */

:root {
  /* Adjust this value if header or tabs height changes */
  --sidebar-top: 154px;
  /* App container width for the main frame */
  --app-max-width: 1400px;
  /* Sidebar width (adjust this single variable to change sidebar width globally) */
  --sidebar-width: 290px;
}

/* Central app container to control frame width globally */
.app-container {
  max-width: var(--app-max-width);
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

/* Priority rules to ensure they override inline Tailwind classes when necessary */
.btn-header {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.75rem !important; /* gap-3 */
  padding: 0.5rem 1rem !important; /* py-2 px-4 */
  background-color: rgba(255, 255, 255, 0.05) !important; /* bg-white/5 */
  color: #ffffff !important;
  border-radius: 0.375rem !important; /* rounded-md */
  border: 1px solid transparent !important;
  text-decoration: none !important;
  transition:
    box-shadow 150ms ease,
    background-color 150ms ease !important;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important;
  cursor: pointer !important;
}
.btn-header:hover {
  background-color: rgba(255, 255, 255, 0.1) !important;
}
.btn-header:focus {
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.12) !important; /* approximate yellow ring */
}
.btn-header[disabled] {
  opacity: 0.6 !important;
  cursor: not-allowed !important;
}

.btn-header .btn-icon {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 2rem !important; /* h-8 */
  width: 2rem !important; /* w-8 */
  border-radius: 9999px !important;
  background-color: rgba(55, 65, 81, 0.4) !important; /* bg-gray-700/40 */
  color: #f59e0b !important; /* yellow-400 */
}

.btn-header .btn-text {
  display: flex !important;
  flex-direction: column !important;
  text-align: left !important;
}

.tab-button {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.3125rem !important; /* smaller gap */
  padding: 0.25rem 0.5rem !important; /* px-2 py-1 (smaller buttons) */
  background-color: rgba(255, 255, 255, 0.05) !important;
  color: #ffffff !important;
  border-radius: 0.375rem !important;
  border: 1px solid transparent !important;
  transition:
    background-color 150ms ease,
    box-shadow 150ms ease !important;
  flex-shrink: 0 !important; /* prevent wrapping by shrinking */
}
.tab-button:hover {
  background-color: rgba(255, 255, 255, 0.08) !important;
}

/* Utility: make first tab look active if needed */
.tab-button.active {
  background-color: rgba(59, 130, 246, 1) !important; /* blue-600 */
  border-color: rgba(37, 99, 235, 1) !important; /* border-blue-600 */
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.03) inset,
    0 2px 6px rgba(2, 6, 23, 0.4) !important;
}

/* Visual for aria-pressed state (accessibility) */
.tab-button[aria-pressed="true"] {
  background-color: rgba(59, 130, 246, 1) !important;
  color: #fff !important;
}

/* Summary tab: icon-only, yellow-400 icon to stand out from other tabs */
.tab-button-summary {

/*  border: 1px solid rgba(245, 158, 11, 0.6) !important; */
/*  background-color: rgba(245, 158, 11, 0.12) !important; */
  color: rgb(250, 204, 21) !important; /* yellow-400 */
}
.tab-button-summary:hover {
/*  background-color: rgba(245, 158, 11, 0.22) !important; */
/*  border-color: rgba(245, 158, 11, 0.8) !important; */
  color: rgb(250, 204, 21) !important; /* yellow-400 */
}
.tab-button-summary.active,
.tab-button-summary[aria-pressed="true"] {
  background-color: rgba(217, 119, 6, 0.9) !important;
  border-color: rgb(245, 158, 11) !important;
  color: #fff !important;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 2px 6px rgba(0, 0, 0, 0.3) !important;
}
/* Override .btn-header .btn-icon for Summary tab - yellow-400 */
.tab-button-summary .btn-icon,
.tab-button-summary .tab-button-summary__icon,
.tab-button-summary .btn-icon svg,
.tab-button-summary .tab-button-summary__icon svg {
  color: rgb(250, 204, 21) !important; /* yellow-400 */
  stroke: rgb(250, 204, 21) !important; /* SVG stroke for currentColor fallback */
}

.shared-header-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: stretch;
  justify-content: flex-end;
}

.shared-header-metric {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: linear-gradient(135deg, rgba(17, 24, 39, 0.85), rgba(31, 41, 55, 0.85));
  border-radius: 0.9rem;
  padding: 0.4rem 0.8rem;
  min-height: 38px;
  flex: 0 0 auto;
  border: 2px dashed rgba(252, 211, 77, 0.45);
  box-shadow:
    0 15px 30px rgba(2, 6, 23, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.shared-header-metric--loan,
.shared-header-metric--ltv,
.shared-header-metric--dti {
  flex: 0 1 auto;
  width: fit-content;
  max-width: none;
}

.shared-header-metric::before {
  content: "";
  position: absolute;
  inset: -60% auto auto -30%;
  width: 150%;
  height: 150%;
  background: radial-gradient(circle, rgba(251, 191, 36, 0.35), transparent 55%);
  transform: rotate(-25deg);
  opacity: 0.6;
  z-index: -1;
}

.shared-header-metric::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.04);
  mix-blend-mode: screen;
  z-index: -1;
}

.shared-header-metric:hover {
  border-color: rgba(252, 211, 77, 0.7);
  transform: translateY(-1px);
  box-shadow:
    0 20px 35px rgba(2, 6, 23, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    border-color 150ms ease;
}

.shared-header-metric-label,
.shared-header-metric-value {
  display: inline-flex;
  align-items: center;
  line-height: 1.2;
  color: #fcd34d;
}

.shared-header-metric-label {
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
}

.shared-header-metric-value {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

@media (max-width: 1024px) {
  .shared-header-metric {
    max-width: none;
  }
}

@media (max-width: 640px) {
  .shared-header-metrics {
    justify-content: flex-start;
    gap: 0.75rem;
  }
}

/* form_1003 specific layout and component styles (moved from template) */
.sidebar-container {
  position: sticky;
  top: var(--sidebar-top); /* controlled via CSS variable */
  z-index: 39; /* Por debajo de z-index:40 de la barra de navegación */
  width: var(--sidebar-width); /* Ancho controlado por variable */
  max-height: calc(
    100vh - var(--sidebar-top)
  ); /* Altura máxima restando el espacio del header */
  overflow-y: auto; /* Permitir scroll dentro del sidebar si hay muchas tarjetas */
  background-color: #1f2937; /* bg-gray-800 */
  border-radius: 0.5rem; /* rounded-lg */
  padding: 1rem; /* p-4 */
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); /* shadow-lg */
}

/* ===== SCROLLABLE TABLE SYSTEM ===== */
/* Global scrollable table styles */
.scrollable-table {
  position: relative;
}

.scrollable-table-header {
  background-color: #374151; /* bg-gray-700 */
  padding: 0.5rem; /* p-2 */
  border-top-left-radius: 0.375rem; /* rounded-t */
  border-top-right-radius: 0.375rem; /* rounded-t */
  border: 1px solid #4B5563; /* border-gray-600 */
  border-bottom: none;
  position: sticky;
  top: 0;
  z-index: 10;
}

.scrollable-table-content {
  max-height: 24rem; /* max-h-96 - 384px */
  overflow-y: auto;
  border: 1px solid #4B5563; /* border-gray-600 */
  border-bottom-left-radius: 0.375rem; /* rounded-b */
  border-bottom-right-radius: 0.375rem; /* rounded-b */
  background-color: #1F2937; /* bg-gray-800 */
}

.scrollable-table-content::-webkit-scrollbar {
  width: 8px;
}

.scrollable-table-content::-webkit-scrollbar-track {
  background: #374151; /* bg-gray-700 */
  border-radius: 4px;
}

.scrollable-table-content::-webkit-scrollbar-thumb {
  background: #6B7280; /* bg-gray-500 */
  border-radius: 4px;
}

.scrollable-table-content::-webkit-scrollbar-thumb:hover {
  background: #9CA3AF; /* bg-gray-400 */
}

/* Responsive height variants */
.scrollable-table-content.max-h-64 { max-height: 16rem; } /* 256px */
.scrollable-table-content.max-h-80 { max-height: 20rem; } /* 320px */
.scrollable-table-content.max-h-96 { max-height: 24rem; } /* 384px */
.scrollable-table-content.max-h-\[500px\] { max-height: 500px; }
.scrollable-table-content.max-h-\[600px\] { max-height: 600px; }
.scrollable-table-content.max-h-\[calc\(5\*3\.5rem\)\] { max-height: calc(5 * 3.5rem); } /* ~175px - approximately 5 rows */
.scrollable-table-content.max-h-\[calc\(7\*3\.5rem\)\] { max-height: calc(7 * 3.5rem); } /* ~245px - approximately 7 rows */

/* Animation for smooth transitions */
.scrollable-table-content {
  transition: max-height 0.3s ease;
}

/* Focus styles for accessibility */
.scrollable-table-content:focus {
  outline: 2px solid #3B82F6; /* focus:ring-2 focus:ring-blue-500 */
  outline-offset: 2px;
}

input:disabled,
select:disabled,
textarea:disabled {
  background-color: #374151 !important; /* Gris más oscuro */
  color: #9ca3af !important; /* Texto gris claro */
  cursor: not-allowed !important;
  opacity: 0.6 !important;
  border-color: #4b5563 !important; /* Borde más oscuro */
}

label[for]:has(+ input:disabled),
label[for]:has(+ select:disabled),
label[for]:has(+ textarea:disabled) {
  color: #9ca3af !important; /* Texto del label más claro */
}

input,
select,
textarea {
  transition: all 0.2s ease-in-out !important;
}

.field-disabled {
  background-color: #374151 !important;
  color: #9ca3af !important;
  cursor: not-allowed !important;
  opacity: 0.6 !important;
  border-color: #4b5563 !important;
}

.field-enabled {
  background-color: #374151 !important; /* Mantener el color original */
  color: #ffffff !important;
  cursor: text !important;
  opacity: 1 !important;
  border-color: #4b5563 !important;
}

.disabled-option {
  pointer-events: none !important;
}

.disabled-option:hover {
  background-color: transparent !important;
}

.borrower-groups-container {
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
}

.borrower-group {
  background-color: rgba(55, 65, 81, 0.3) !important;
  border-radius: 8px !important;
  padding: 8px !important;
  border: 1px solid rgba(75, 85, 99, 0.3) !important;
}

.borrower-group .borrower-card {
  margin-bottom: 4px !important;
}

.borrower-group .borrower-card:last-child {
  margin-bottom: 0 !important;
}

/* Borrower Sidebar: visual separator between borrower groups */
.borrower-group {
  position: relative !important;
}

.borrower-group:not(:first-child)::before {
  content: "" !important;
  position: absolute !important;
  left: 0 !important;
  right: 0 !important;
  top: -12px !important;                  /* place the line in the gap above */
  height: 6px !important;                 /* thickness of the separator */
  background-color: #00000080  !important;    /* white line */
  border-radius: 6px !important;
  z-index: 1 !important;
}
