/* ========================================
   COMMON GLOBAL STYLES (shared across pages)
   ======================================== */

/* Full-width content area that grows to push footer down */
main.content {
  flex: 1 1 auto;
  width: 100%;
  padding: 20px; /* safe spacing */
  box-sizing: border-box;
}

/* ========================================
   VERIFICATION SECTION (shared by all modules)
   ======================================== */
.verification-section {
  background: var(--gradient-hero);
  background-attachment: fixed;
  padding: 60px 0;
  display: flex;
  align-items: center;
}

/* Use full-width container for internal modules to maximize space (keeps index unaffected) */
.verification-section .container {
  width: 100% !important;
  max-width: 100% !important;
  padding-left: 12px;
  padding-right: 12px;
}

.verification-section h1,
.verification-section h2,
.verification-section h3,
.verification-section h4,
.verification-section h5,
.verification-section h6 {
  color: #ffffff !important;
}

.verification-section .text-center {
  color: #ffffff !important;
}

/* ========================================
   VERIFICATION CARD (transparent shell)
   ======================================== */
.verification-card {
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
}

.verification-card .card-header {
  background: transparent !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important;
  padding: 22px;
}

.verification-card .card-body {
  padding: 22px;
}

.verification-card .card-footer {
  background: transparent !important;
  border-top: 1px solid rgba(255, 255, 255, 0.15) !important;
  box-shadow: none !important;
  padding: 16px 22px;
}

/* ========================================
   FIELDSETS (white inner containers)
   ======================================== */
.residencias-fieldset,
.contactos-fieldset {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  background: #ffffff;
}

.residencias-fieldset .form-label,
.contactos-fieldset .form-label {
  color: var(--text-primary) !important;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.residencias-fieldset .form-control,
.residencias-fieldset .form-select,
.contactos-fieldset .form-control,
.contactos-fieldset .form-select {
  background-color: #ffffff;
  border: 1px solid var(--border);
  color: #212529;
}

.residencias-fieldset .form-control:focus,
.residencias-fieldset .form-select:focus,
.contactos-fieldset .form-control:focus,
.contactos-fieldset .form-select:focus {
  background: #ffffff;
  border-color: var(--secondary-color);
  box-shadow: 0 0 0 0.2rem rgba(53, 94, 59, 0.25);
}

/* ========================================
   COMMON BUTTONS
   ======================================== */
/* Requirement emphasis */
.text-required {
  color: #ffc107 !important;
}

/* Add button: warm amber-brown accent */
.btn-add {
  background: linear-gradient(180deg, #B9893B, #8A5C1B) !important;
  border: none !important;
  color: #ffffff !important;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(185, 137, 59, 0.35) !important;
  transition: all 0.2s ease-in-out;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
}

.btn-add:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.btn-add:active {
  transform: translateY(0);
}

/* Next button disabled style */
.btn-next.disabled,
.btn-next[aria-disabled="true"] {
  background: linear-gradient(135deg, #adb5bd, #6c757d) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(108, 117, 125, 0.25) !important;
  opacity: 1;
  pointer-events: auto;
  cursor: not-allowed;
}

/* ========================================
   MODERN TABLES (shared by all modules)
   ======================================== */
.table-modern {
  background: #ffffff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.table-modern table {
  margin-bottom: 0;
  border-collapse: separate;
  border-spacing: 0;
}

.table-modern thead {
  border-bottom: 1px solid #e9ecef;
  background: #f1f3f5;
}

.table-modern thead th {
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: .02em;
  color: #495057;
}

.table-modern thead th:first-child {
  border-top-left-radius: 12px;
}

.table-modern thead th:last-child {
  border-top-right-radius: 12px;
}

.table-modern tbody td {
  border-top: none;
  border-bottom: 1px solid #e9ecef;
}

.table-modern tbody tr {
  transition: background 0.15s ease;
}

.table-modern tbody tr:hover {
  background: #f8f9fa;
}

/* ========================================
   ACTION BUTTONS (edit/delete in tables)
   ======================================== */
.btn-edit,
.btn-delete {
  padding: .35rem .55rem !important;
  line-height: 1 !important;
  border-radius: 10px !important;
}

.btn-edit i,
.btn-delete i {
  font-size: 1rem;
}

.btn-edit {
  background: linear-gradient(180deg, #0d6efd, #0b5ed7) !important;
  color: #ffffff !important;
  border: none !important;
  box-shadow: 0 4px 10px rgba(13, 110, 253, 0.25) !important;
}

.btn-edit:hover {
  filter: brightness(1.05);
}

.btn-delete {
  background: linear-gradient(180deg, #dc3545, #bb2d3b) !important;
  color: #ffffff !important;
  border: 1px solid #b02a37 !important;
  box-shadow: 0 4px 10px rgba(220, 53, 69, 0.25) !important;
}

.btn-delete:hover {
  filter: brightness(1.05);
}

/* ========================================
   MODAL STYLES (shared across modules)
   ======================================== */
.modal-header {
  background: #ffffff;
}

.modal-header .modal-title {
  color: #000000 !important;
  font-weight: 700;
}

.modal-footer .btn-modal {
  padding: .6rem 1rem;
  min-width: 140px;
  min-height: 44px;
  font-weight: 600;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.btn-cancel-soft {
  background: #e9ecef !important;
  color: #000000 !important;
  border: 1px solid #ced4da !important;
}

.btn-cancel-soft:hover {
  filter: brightness(1.02);
}

/* Modal form alignment */
.modal .form-label {
  color: #000000 !important;
}

.modal .row.g-3 {
  align-items: end;
}

.modal .form-select,
.modal .form-control {
  height: 44px;
}

/* Celeste Next button (consistent across app) */
.btn-siguiente {
  background: linear-gradient(135deg, #17a2b8, #138496) !important;
  border: none !important;
  color: #ffffff !important;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(23, 162, 184, 0.3) !important;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center; /* center label/icon when button stretches */
  gap: 8px;
  border-radius: 12px;
  padding: 10px 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
  box-sizing: border-box;
}
.btn-siguiente:hover,
.btn-siguiente:focus {
  background: linear-gradient(135deg, #138496, #117a8b) !important;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(23, 162, 184, 0.4) !important;
  color: #ffffff !important;
}

/* Match celeste style for anchor-based Next buttons */
.btn-next {
  background: linear-gradient(135deg, #17a2b8, #138496) !important;
  border: none !important;
  color: #ffffff !important;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(23, 162, 184, 0.3) !important;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  padding: 10px 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
  box-sizing: border-box;
}
.btn-next:hover,
.btn-next:focus {
  background: linear-gradient(135deg, #138496, #117a8b) !important;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(23, 162, 184, 0.4) !important;
  color: #ffffff !important;
}

/* Disabled state: keep fully gray and avoid hover effects */
.btn-next.disabled,
.btn-next:disabled,
.btn-siguiente.disabled,
.btn-siguiente:disabled {
  background: #9ca3af !important;
  border: 1px solid #9ca3af !important;
  color: #ffffff !important;
  box-shadow: none !important;
  cursor: not-allowed !important;
  transform: none !important;
}
.btn-next.disabled:hover,
.btn-next:disabled:hover,
.btn-next.disabled:focus,
.btn-next:disabled:focus,
.btn-siguiente.disabled:hover,
.btn-siguiente:disabled:hover,
.btn-siguiente.disabled:focus,
.btn-siguiente:disabled:focus {
  background: #9ca3af !important;
  border: 1px solid #9ca3af !important;
  color: #ffffff !important;
  box-shadow: none !important;
  transform: none !important;
}

/* Readonly inputs (visual cue) */
.readonly-input {
  background-color: #f8f9fa !important;
  color: #6c757d !important;
  cursor: not-allowed;
}

/* Avoid interfering with Bootstrap's valid background-image on selects */
.form-select,
.form-control {
  background-color: #ffffff; /* DON'T use background shorthand */
}

/* Fallback arrow for selects (if Bootstrap var not present) */
:root {
  --cascade-select-arrow: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
}

/* Ensure select shows arrow (and optional status icon), matching Bootstrap */
.form-select {
  padding-right: 2.25rem !important; /* room for arrow */
  background-image: var(--bs-form-select-bg-img, var(--cascade-select-arrow)) !important;
  background-repeat: no-repeat !important;
  background-position: right 0.75rem center !important;
  background-size: 16px 12px !important;
}

/* Keep arrow on valid/invalid; prevent tiling */
.form-select.is-valid,
.was-validated .form-select:valid {
  padding-right: 2.25rem !important;
  background-image: var(--bs-form-select-bg-img, var(--cascade-select-arrow)) !important;
  background-repeat: no-repeat !important;
  background-position: right 0.75rem center !important;
  background-size: 16px 12px !important;
}
.form-select.is-invalid,
.was-validated .form-select:invalid {
  padding-right: 2.25rem !important;
  background-image: var(--bs-form-select-bg-img, var(--cascade-select-arrow)) !important;
  background-repeat: no-repeat !important;
  background-position: right 0.75rem center !important;
  background-size: 16px 12px !important;
}

/* Sticky footer look & feel across modules */
footer {
  background: #272727;
  color: #ffffff;
  padding: 30px 0 30px;
  text-align: center;
  position: relative;
  border-top: 1px solid rgba(255, 255, 255, 0.25) !important; /* white divider like navbar */
}
footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
}

/* ========================================
   RESPONSIVE STYLES (shared by all modules)
   ======================================== */
@media (max-width: 767.98px) {
  /* Widen modals a bit so they match the wider cards */
  .modal-dialog {
    margin: 0.5rem 8px; /* reduce side margins */
    max-width: calc(100% - 16px);
  }
  /* Use tighter gutters inside internal flows to gain width */
  .verification-section .row {
    --bs-gutter-x: 0.5rem; /* default ~1.5rem -> 0.5rem */
  }
  
  /* Stack modal footer actions vertically and full-width for internal pages */
  .verification-section .modal-footer {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 10px;
  }
  .verification-section .modal-footer > * { /* handle buttons and wrapping forms */
    width: 100% !important;
  }
  .verification-section .modal-footer .btn {
    width: 100% !important;
    display: inline-flex;
    justify-content: center;
  }
  
  .verification-card .card-footer .d-flex {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  
  .verification-card .card-footer .d-flex > .d-flex {
    width: 100%;
  }
  
  .verification-card .card-footer .btn-siguiente,
  .verification-card .card-footer .btn-next {
    width: 100% !important;
    display: inline-flex;
    justify-content: center;
  }
  
  /* Center Add button and make it full width */
  .residencias-fieldset .d-flex.justify-content-end,
  .contactos-fieldset .d-flex.justify-content-end {
    justify-content: center !important;
  }
  
  .residencias-fieldset .btn-add,
  .contactos-fieldset .btn-add {
    width: 100% !important;
  }
  
  .verification-card {
    margin: 0.75rem 0rem !important; /* reduce side gaps to widen card */
  }
  
  /* Slightly reduce side padding of main content on small screens */
  main.content { 
    padding-left: 10px; 
    padding-right: 10px; 
  }
  
  /* Even tighter container padding on small screens for more usable width */
  .verification-section .container {
    padding-left: 8px;
    padding-right: 8px;
  }
  
  .verification-card .card-body {
    padding: 1.5rem !important;
  }
  
  .verification-card .card-footer {
    padding: 1.25rem !important;
  }
  
  /* Align action buttons when table is stacked */
  .table-stack .cell-actions {
    text-align: left !important;
  }
  
  .table-stack .cell-actions .d-inline-flex {
    justify-content: flex-start;
  }
  
  .table-stack .cell-actions .btn {
    margin-right: 8px;
  }
}

/* Stack table vertically on small screens */
@media (max-width: 768px) {
  .table-stack thead {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }
  
  .table-stack tr,
  .table-stack td {
    display: block;
    width: 100% !important;
  }
  
  .table-stack tr {
    border-bottom: 1px solid #e9ecef;
  }
  
  .table-stack td {
    padding-left: 48% !important;
    padding-top: 12px;
    padding-bottom: 12px;
    position: relative;
    border: none !important;
    border-bottom: 1px solid #e9ecef !important;
    word-break: break-word;
    overflow-wrap: anywhere;
  }
  
  .table-stack td::before {
    content: attr(data-title);
    position: absolute;
    left: 12px;
    top: 12px;
    transform: none;
    font-weight: 600;
    color: #495057;
    line-height: 1.1;
    white-space: normal;
    max-width: 44%;
  }
}

/* Very small screens */
@media (max-width: 480px) {
  .verification-section {
    min-height: 100vh;
    padding: 40px 0;
  }
}

/* Keep footer action buttons tidy */
.card-footer .btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;            /* allow shrinking inside flex */
  white-space: nowrap;     /* keep label on one line */
  overflow: hidden;        /* prevent spill */
  text-overflow: ellipsis; /* show ellipsis if needed */
}

/* ========================================
   UTILITY CLASSES (shared across modules)
   ======================================== */
/* Center the card when there are no registros (used by multiple modules) */
.center-stage {
  min-height: calc(100vh - 220px);
  display: flex;
  align-items: center;
  justify-content: center;
}
