/* app/styles/components/modal.css */

/* Modal Overlay */
.app-modal-overlay {
  position: fixed; /* Stays in place even when scrolling */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6); /* Semi-transparent black background */
  display: flex; /* Use flexbox for centering */
  justify-content: center;
  align-items: center;
  z-index: 1003; /* Ensure it's on top of everything */
  opacity: 0; /* Start hidden for fade-in */
  visibility: hidden; /* Hide from screen readers when not visible */
  transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
  margin-block: 0;
}

.app-modal-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

/* Modal Content Wrapper */
.app-modal-content-wrapper {
  background-color: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  width: 90%;
  max-width: 60rem;
  transform: translateY(-20px);
  opacity: 0;
  transition: transform 0.3s ease-out, opacity 0.3s ease-out;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
}

.app-modal-content-wrapper.is-visible {
  transform: translateY(0);
  opacity: 1;
}

/* Modal Header */
.app-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid #eee;
  background-color: #097b48;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}

.app-modal-title {
  margin: 0;
  font-size: 1.25rem;
  color: white;
  font-weight: 600;
}

.app-modal-close-button {
  background: none;
  border: none;
  font-size: 1.8rem; /* Large 'x' */
  cursor: pointer;
  color: #fff;
  padding: 0;
  line-height: 1;
  /* transition: color 0.2s ease; */
  border-radius: 50%; /* Make it circular */
  width: 30px;
  height: 30px;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.3s;
}

.app-modal-close-button:hover {
  transform: scale(1.2);
}

/* Modal Body */
.app-modal-body {
  padding: 20px;
  flex-grow: 1; /* Allows body to take up available space */
  overflow-y: auto; /* Enable scrolling for long content */
  color: #555;
  line-height: 1.6;
  margin-block: 0;
}

.modal-view-tabs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.modal-view-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  & .tab-title {
    font-weight: 500;
    font-size: 1.1rem;
  }
  &.active {
    border-bottom: 2px solid #097b48;
    & .tab-title {
      font-weight: 700;
    }
  }
}

.status-icon {
  width: 1.5rem;
  height: 1.5rem;
  margin-bottom: 0.3rem;
  &.status-incomplete {
    fill: #bababa;
  }
}
.status-icon.status-complete {
  color: #097b48;
  fill: #097b48;
}

.modal-view-body-content h4 {
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.app-modal-body .form-group {
  margin-block: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: end;
  gap: 0.3rem;
}

.app-modal-body .form-group {
  & label {
    font-weight: 500;
    color: #333;
    font-size: 0.8rem;
  }
  & input,
  & select {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid #726d6d;
  }
}

.app-modal-body .grid,
.modal-form-grid,
.modal-form-top-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  align-items: end;
  & .form-group {
    margin-block: 0;
    vertical-align: middle;
  }
}

.app-modal-body .grid .image {
  /* span entire row */
  grid-column: 1 / -1;
}

.grid + h4 {
  margin-top: 2rem;
}

.user-image-preview-view-only {
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid #726d6d;
  overflow: hidden;
  margin-bottom: 2rem;
}

.details-group,
.details-section {
  margin-bottom: 2rem;
}

.details-group {
  display: flex;
  align-items: center;
  & .detail-item {
    flex: 1;
  }
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 1rem;
  margin-top: 0.5rem;
}

.detail-item {
  display: flex;
  flex-direction: column;
  /* gap: 0.2rem; */
}

.modal-form-items-section {
  margin-top: 2rem;
}

.items-table-container,
.table-responsive {
  margin-top: 1rem;
  overflow-x: auto; /* Allow horizontal scrolling for wide tables */
  border-radius: 8px;
  background-color: #fff;
  padding: 1rem;
  border: 1px solid #ddd;
  margin-bottom: 2rem;
  max-height: 400px; /* Limit height for better UX */
}
.items-table-container,
.table-responsive {
  & table {
    width: 100%;
    border-collapse: collapse;
  }
}
.items-table-container,
.table-responsive {
  & table th {
    border-bottom: 1px solid #ddd;
  }
}
.items-table-container,
.table-responsive {
  & table th,
  table td {
    padding: 0.5rem;
    text-align: left;
  }
}

.items-table-container,
.table-responsive {
  table tr td {
    input,
    select {
      width: 100%;
      padding: 0.5rem;
      border: 1px solid #ddd;
      border-radius: 0.3rem;
    }
    &:first-child input {
      width: 100%;
    }
    &:nth-child(2) input {
      width: 5rem;
    }
    &:nth-child(3) input {
      width: 3rem;
    }
    &:nth-child(4) input {
      width: 3rem;
    }
  }
}

.view-donor-item-modal-content .table-responsive table tr {
  th:last-child {
    display: none; /* Hide the last column header */
  }
  td {
    &:first-child input {
      width: 100%;
    }
    &:nth-child(2) input {
      width: 100%;
    }
    &:nth-child(3) input {
      width: 4rem;
    }
    &:nth-child(4) input {
      width: 7rem;
    }
    &:nth-child(5) input {
      width: 3rem;
    }
  }
}

.table-responsive table tr td:nth-child(3) input {
  width: 5rem;
}

.item-actions {
  display: flex;
  /* justify-content: center;  */
  gap: 0.5rem;
  & button:last-child {
    display: none;
  }
}

.modal-buttons-bottom {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 1rem;
}

.app-modal-body .details-grid .detail-item {
  & strong {
    font-size: 0.8rem;
    font-weight: 600;
  }
  & span {
    margin: 0;
    font-size: 0.9rem;
    color: #555;
  }
}
.app-modal-body .table_container {
  margin-top: 1rem;
  overflow-x: auto; /* Allow horizontal scrolling for wide tables */
  border-radius: 8px;
  background-color: #fff;
  padding: 1rem;
  border: 1px solid #ddd;
}

.app-modal-body .table_container,
.app-modal-body .table-container {
  & table {
    width: 100%;
    border-collapse: collapse;
  }
}
.app-modal-body .table_container,
.app-modal-body .table-container {
  & table th {
    border-bottom: 1px solid #ddd;
  }
}
.app-modal-body .table_container,
.app-modal-body .table-container {
  & table th,
  & table td {
    padding: 0.5rem;
    text-align: left;
  }
}

.app-modal-body .records-table {
  border-collapse: collapse;
}

.app-modal-body .records-table table {
  width: 100%;
  border: 1px solid black;
}

.app-modal-body .records-table table th,
.app-modal-body .records-table table td {
  padding: 0.5rem;
  text-align: left;
  border: 1px solid black;
}

.app-modal-body .card {
  border-color: #726d6d;
}

.modal-body-content {
  width: 100%;
}
.chart-container {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: auto;
}
.dropdown-filter {
  padding: 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid #726d6d;
}

.balance-sheet-table table {
  width: 100%;
}
.balance-sheet-table table th,
.balance-sheet-table table td {
  padding: 0.5rem;
  text-align: left;
  border-bottom: 5px solid #ddd;
}
.balance-sheet-table table th {
  font-weight: 600;
}
.balance-sheet-table table tfoot{
  font-weight: 600;
  background-color: #097b48;
  color: white;
  td {
    border: none;
  }
}

@media (max-width: 768px) {
  .app-modal-body .flex.justify-between {
    /* flex-direction: column; */
    gap: 1rem;
  }
  .dropdown-filter {
    width: 100%;
  }
}

/* Modal Footer (Optional) */
.app-modal-footer {
  /* display: flex; */
  justify-content: flex-end; /* Align buttons to the right */
  gap: 10px;
  padding: 15px 20px;
  border-top: 1px solid #eee;
  background-color: #f8f8f8;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  display: none; /* Hidden by default, controlled by JS */
  margin-block: 0;
}

.voucher-header {
  margin-bottom: 1rem;
}

.voucher-section {
  text-align: center;
  &:nth-child(odd) {
    width: 25%;
  }
  &:nth-child(even) {
    width: 50%;
  }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .app-modal-content-wrapper {
    width: 95%;
    max-width: none; /* Remove max-width on smaller screens */
    margin: 10px; /* Add some margin from edges */
  }
}

@media (max-width: 480px) {
  .app-modal-header,
  .app-modal-body,
  .app-modal-footer {
    padding: 10px 15px;
  }
  .app-modal-title {
    font-size: 1.1rem;
  }
  .app-modal-close-button {
    font-size: 1.5rem;
    width: 24px;
    height: 24px;
  }
}
