/* ========================================
   UNIFIED MODAL & ANIMATION SYSTEM
   Handles both Bulma (.modal) and MDC (.mdc-dialog)
   ======================================== */

.modal,
.mdc-dialog {
  display: flex !important;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 10000 !important;
}

.modal.is-active,
.mdc-dialog.mdc-dialog--open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

/* Overlay / Scrim */
.modal-background,
.mdc-dialog__scrim {
  background-color: rgba(15, 23, 42, 0.65) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  opacity: 0 !important;
  transition: opacity 0s !important;
}

.is-active .modal-background,
.mdc-dialog--open .mdc-dialog__scrim {
  opacity: 1 !important;
}

/* Modal Surface / Container */
.modal-content,
.modal-card,
.mdc-dialog__surface {
  transform: scale(0.98);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
  border-radius: 16px !important;
  overflow: hidden !important;
}

.is-active .modal-content,
.is-active .modal-card,
.mdc-dialog--open .mdc-dialog__surface {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* Standardized Header */
.modal-card-head {
  background: white !important;
  padding: 1.25rem 1.75rem !important;
  border-bottom: 2px solid #edf2f7 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
}

.modal-card-title,
.modal-title-modern,
.center_align {
  font-size: 1.4rem !important;
  font-weight: 700 !important;
  color: #1a365d !important;
  margin: 0 !important;
  text-align: left !important;
}

/* Standardized Footer */
.modal-card-foot,
#button-close-log-changes-modal {
  background: #f8fafc !important;
  padding: 1.25rem 1.75rem !important;
  border-top: 1px solid #edf2f7 !important;
  display: flex !important;
  justify-content: flex-end !important;
  gap: 1rem !important;
}

/* Fix for existing code */
.modal-header-modern {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 2rem;
  background: #ffffff;
  color: #333;
  border-bottom: 3px solid #244b95;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.modal-header-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
}

.modal-title-modern {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #333;
}

.modal-title-modern i {
  font-size: 1.75rem;
  color: #244b95;
}

.modal-close-btn {
  background: transparent;
  border: none;
  height: 42px;
  border-radius: 8px;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.modal-close-btn:hover {
  background: #f8f9fa;
  color: #244b95;
}

/* History Dropdown - Deprecated in favor of direct button */
.history-dropdown {
  display: none !important;
}

/* Modal Content */
.modern-modal-content {
  overflow-y: auto;
  max-height: calc(90vh - 140px);
  padding: 0 !important;
}

.modern-modal-content::-webkit-scrollbar {
  width: 8px;
}

.modern-modal-content::-webkit-scrollbar-track {
  background: #f8f9fa;
  border-radius: 4px;
}

.modern-modal-content::-webkit-scrollbar-thumb {
  background: #dee2e6;
  border-radius: 4px;
}

.modern-modal-content::-webkit-scrollbar-thumb:hover {
  background: #244b95;
}

.modal-sections {
  padding: 2rem;
  background: #f8f9fa;
}

/* Modal Sections */
.modal-section {
  background: white;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  transition: all 0.3s ease;
  border: 1px solid #dee2e6;
}

.modal-section:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  border-color: rgba(36, 75, 149, 0.3);
}

.section-highlight {
  border: 2px solid #244b95;
  position: relative;
}

.section-highlight::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: #244b95;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  background: #fafbfc;
  border-bottom: 2px solid #f0f1f3;
}

.section-icon {
  font-size: 1.5rem;
  color: #244b95;
}

.section-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.section-content {
  padding: 1.5rem;
}

/* Form Rows and Fields */
.form-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.form-field {
  flex: 1;
  min-width: 0;
}

.form-field-2 {
  flex: 0 0 calc(16.666% - 0.833rem);
}

.form-field-3 {
  flex: 0 0 calc(25% - 0.75rem);
}

.form-field-4 {
  flex: 0 0 calc(33.333% - 0.667rem);
}

.form-field-5 {
  flex: 0 0 calc(41.666% - 0.584rem);
}

.form-field-6 {
  flex: 0 0 calc(50% - 0.5rem);
}

.form-field-8 {
  flex: 0 0 calc(66.666% - 0.334rem);
}

.form-field-12 {
  flex: 0 0 100%;
}

@media (max-width: 768px) {
  .form-field-2,
  .form-field-3,
  .form-field-4,
  .form-field-5,
  .form-field-6,
  .form-field-8 {
    flex: 0 0 100%;
  }
}

/* Info Box - Usando colores de la app */
.info-box {
  display: flex;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: rgba(36, 75, 149, 0.05);
  border-left: 4px solid #244b95;
  border-radius: 8px;
  margin-top: 1rem;
}

.info-box-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  color: #244b95;
  font-size: 1.25rem;
}

.info-box-content {
  flex: 1;
  color: #555;
  font-size: 0.9rem;
  line-height: 1.6;
}

.info-box-content > strong {
  display: block;
  margin-bottom: 0.25rem;
  color: #333;
}

.info-box-content p {
  margin: 0;
  color: #555;
}

/* Organism Table */
.organism-table-wrapper {
  overflow-x: auto;
  margin-bottom: 1rem;
  border-radius: 8px;
  border: 1px solid #dee2e6;
}

.modern-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.modern-table thead {
  background: #fafbfc;
}

.modern-table th {
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  color: #333;
  border-bottom: 2px solid #dee2e6;
}

.modern-table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid #f0f1f3;
  color: #555;
}

.modern-table tbody tr {
  transition: background 0.2s ease;
}

.modern-table tbody tr:hover {
  background: rgba(36, 75, 149, 0.05);
}

.modern-table .actions-col {
  width: 80px;
  text-align: center;
}

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

/* Add Organism Row */
.add-organism-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  padding: 1.25rem;
  background: #fafbfc;
  border-radius: 8px;
  border: 2px dashed #dee2e6;
}

.btn-add-organism {
  background: #244b95;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 48px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(36, 75, 149, 0.3);
}

.btn-add-organism:hover {
  background: #1b3a75;
  box-shadow: 0 4px 12px rgba(36, 75, 149, 0.4);
}

/* Comment Section */
.comment-section {
  margin-top: 1rem;
}

.comment-label {
  display: block;
  font-weight: 600;
  color: #333;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.modern-textarea {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
  transition: all 0.3s ease;
  color: #333;
}

.modern-textarea:focus {
  outline: none;
  border-color: #244b95;
  box-shadow: 0 0 0 3px rgba(36, 75, 149, 0.1);
}

.modern-textarea::placeholder {
  color: #999;
}

/* File Upload Modern */
.file-upload-modern {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.file-upload-label {
  cursor: pointer;
}

.file-input-hidden {
  display: none;
}

.file-upload-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  border: 2px dashed #dee2e6;
  border-radius: 8px;
  background: #fafbfc;
  transition: all 0.3s ease;
  text-align: center;
  gap: 0.5rem;
}

.file-upload-box:hover {
  border-color: #244b95;
  background: rgba(36, 75, 149, 0.05);
}

.file-upload-box i {
  font-size: 2rem;
  color: #244b95;
}

.file-upload-box span {
  font-weight: 600;
  color: #333;
  font-size: 0.95rem;
}

.file-upload-box small {
  color: #666;
  font-size: 0.85rem;
}

.file-download-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  color: #244b95;
  text-decoration: none;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

.file-download-link:hover {
  background: rgba(36, 75, 149, 0.05);
  border-color: #244b95;
}

.file-download-link i {
  font-size: 1.25rem;
  color: #ef4444;
}

.file-download-link span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Modal Footer */
.modal-footer-modern {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding: 1.5rem 2rem;
  background: white;
  border-top: 2px solid #dee2e6;
  position: sticky;
  bottom: 0;
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

.btn-cancel {
  background: white;
  color: #666;
  border: 2px solid #dee2e6;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-cancel:hover {
  background: #f8f9fa;
  border-color: #999;
  color: #333;
}

.btn-cancel:focus {
  outline: none;
  border-color: #244b95;
  box-shadow: 0 0 0 3px rgba(36, 75, 149, 0.2);
}

.btn-submit {
  background: #244b95;
  color: white;
  border: none;
  padding: 0.75rem 2rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 2px 8px rgba(36, 75, 149, 0.3);
}

.btn-submit:hover {
  background: #1b3a75;
  box-shadow: 0 4px 12px rgba(36, 75, 149, 0.4);
}

.btn-submit:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(36, 75, 149, 0.3), 0 2px 8px rgba(36, 75, 149, 0.3);
}

/* Hidden Comment Section */
.is-OiaCommentHidden {
  display: none;
}

/* ========================================
   MODERN HISTORY LOG MODAL
   ======================================== */

#modalLog {
  z-index: 20000 !important;
}

#modalLog .modal-content {
  max-width: 900px;
  width: 90%;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

#modalLog .modal-card-body {
  padding: 0;
  background: white;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  overflow: hidden;
}

#modalLog .modal-card-head {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #ffffff !important;
  padding: 1.5rem 2rem !important;
  margin: 0;
  border-bottom: 3px solid #244b95 !important;
  font-size: 1.25rem;
  color: #333;
  display: flex !important;
  align-items: center !important;
  gap: 0.75rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
  justify-content: center !important;
}

#table-container-scroll-style {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  min-height: 0;
}

#table-container-scroll-style::-webkit-scrollbar {
  width: 8px;
}

#table-container-scroll-style::-webkit-scrollbar-track {
  background: #f8f9fa;
}

#table-container-scroll-style::-webkit-scrollbar-thumb {
  background: #dee2e6;
  border-radius: 4px;
}

#table-container-scroll-style::-webkit-scrollbar-thumb:hover {
  background: #244b95;
}

#modalLog .table {
  margin: 0;
  background: white;
}

#modalLog .table thead {
  background: #fafbfc;
  position: sticky;
  top: 0;
  z-index: 10;
}

#modalLog .table thead th {
  color: #333;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 1rem;
  border-bottom: 2px solid #dee2e6;
}

#modalLog .table tbody tr {
  transition: background 0.2s ease;
}

#modalLog .table tbody tr:hover {
  background: rgba(36, 75, 149, 0.05);
}

#modalLog .table tbody td {
  padding: 0.875rem 1rem;
  color: #555;
  font-size: 0.9rem;
  border-bottom: 1px solid #f0f1f3;
}

#modalLog .table tbody td a {
  color: #244b95;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
}

#modalLog .table tbody td a:hover {
  color: #1b3a75;
  text-decoration: underline;
}

.file-link-log {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  background: rgba(36, 75, 149, 0.1);
  border-radius: 6px;
  color: #244b95;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.file-link-log:hover {
  background: #244b95;
  color: white;
  box-shadow: 0 2px 8px rgba(36, 75, 149, 0.3);
}

.file-link-log i {
  font-size: 0.9rem;
}

#button-close-log-changes-modal {
  position: sticky;
  bottom: 0;
  z-index: 100;
  padding: 1.5rem;
  background: #fafbfc;
  border-top: 2px solid #f0f1f3;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
  flex-shrink: 0;
}

#button-close-log-changes-modal .button {
  background: #244b95;
  color: white;
  border: none;
  padding: 0.75rem 2rem;
  font-weight: 600;
  border-radius: 8px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(36, 75, 149, 0.3);
}

#button-close-log-changes-modal .button:hover {
  background: #1b3a75;
  box-shadow: 0 4px 12px rgba(36, 75, 149, 0.4);
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .modal-header-modern {
    padding: 1rem 1.25rem;
  }

  .modal-title-modern {
    font-size: 1.25rem;
  }

  .modal-sections {
    padding: 1rem;
  }

  .section-header {
    padding: 1rem;
  }

  .section-content {
    padding: 1rem;
  }

  .modal-footer-modern {
    flex-direction: column;
    gap: 0.75rem;
  }

  .btn-cancel,
  .btn-submit {
    width: 100%;
    justify-content: center;
  }

  .add-organism-row {
    flex-direction: column;
  }

  .btn-add-organism {
    width: 100%;
  }

  #modalLog .modal-content {
    width: 95%;
  }

  #log-changes-modal {
    font-size: 1.1rem;
    padding: 1.25rem 1.5rem;
  }

  #table-container-scroll-style {
    max-height: 400px;
  }

  #modalLog .table {
    font-size: 0.85rem;
  }

  #modalLog .table thead th,
  #modalLog .table tbody td {
    padding: 0.75rem 0.5rem;
  }
}

/* Animation for modal sections */
.modal-section {
  animation: sectionFadeIn 0.2s ease backwards;
}

.modal-section:nth-child(1) {
  animation-delay: 0s;
}

.modal-section:nth-child(2) {
  animation-delay: 0.02s;
}

.modal-section:nth-child(3) {
  animation-delay: 0.04s;
}

.modal-section:nth-child(4) {
  animation-delay: 0.06s;
}

.modal-section:nth-child(5) {
  animation-delay: 0.08s;
}

.modal-section:nth-child(6) {
  animation-delay: 0.1s;
}

@keyframes sectionFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}
