/**
 * Centralized styles for system modals
 */

/* ===== MODAL DIALOG BASE ===== */
.uk-modal-dialog,
.uk-modal-container .uk-modal-dialog,
[id*="Modal"] .uk-modal-dialog,
[id*="modal"] .uk-modal-dialog {
  background: #fff;
  border-radius: 12px !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* ===== MODAL HEADER ===== */
.modal-form-header {
  background: #fff;
  color: #1e293b;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid #e2e8f0;
}

.modal-form-header__content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.modal-form-header__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: #f8fafc;
  border-radius: 8px;
  font-size: 1.25rem;
  color: #667eea;
}

.modal-form-header__icon i {
  color: #667eea;
  font-size: 1.125rem;
}

.modal-form-header__texts {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.modal-form-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #1e293b;
}

.modal-form-subtitle {
  margin: 0;
  font-size: 0.875rem;
  color: #64748b;
  font-weight: 400;
}

/* ===== MODAL BODY ===== */
.modal-form-body {
  background: #f8fafc;
  padding: 2rem;
}

/* ===== MODAL FIELDSETS ===== */
.modal-form-body fieldset {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.2s ease;
}

.modal-form-body fieldset:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.modal-form-body fieldset:last-of-type {
  margin-bottom: 1rem;
}

.modal-form-body fieldset+hr.uk-divider-icon {
  display: none;
}

/* ===== MODAL SECTION TITLES ===== */
.modal-section-title {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1rem;
  font-size: 1.125rem;
  font-weight: 600;
  color: #1e293b;
  text-transform: none;
}

.modal-section-title::before {
  content: '';
  display: inline-block;
  width: 32px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.modal-section-title i {
  color: #667eea;
  font-size: 1rem;
}

/* ===== MODAL ACTIONS (FOOTER) ===== */
.modal-form-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem 2rem;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  margin-top: 1rem;
}

.modal-form-actions .uk-button {
  min-width: 120px;
  border-radius: 8px;
}

.modal-form-actions .uk-button-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  color: white;
  font-weight: 600;
  transition: background 0.3s ease, transform 0.2s ease;
}

.modal-form-actions .uk-button-primary:hover {
  background: linear-gradient(135deg, #5a6fd6 0%, #6e42a0 100%);
  transform: translateY(-1px);
}

/* ===== MODAL TABS ===== */
.modal-tabs {
  border-bottom: 2px solid #e2e8f0;
  margin-bottom: 1.25rem;
}

.modal-tabs>li>a {
  color: #64748b;
  font-weight: 500;
  padding: 0.75rem 1.25rem;
  border-bottom: 3px solid transparent;
  transition: all 0.3s ease;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-tabs>li>a:hover {
  color: #667eea;
  background-color: #f8fafc;
  border-bottom-color: #e2e8f0;
}

.modal-tabs>li.uk-active>a {
  color: #667eea;
  border-bottom-color: #667eea;
  background-color: transparent;
  font-weight: 600;
}

.modal-tabs>li>a i {
  font-size: 1rem;
  width: 1rem;
  text-align: center;
}

.uk-modal-title {
  color: #1e293b !important;
  font-weight: 600 !important;
}

/* Ensure modal title is visible in folder picker modal */
#folder-picker-modal .uk-modal-title,
#create-folder-modal .uk-modal-title {
  color: #1e293b !important;
  background: transparent !important;
}

/* Fix for white-on-white text in modal titles */
.uk-modal-dialog .uk-modal-title,
.uk-modal-body .uk-modal-title {
  color: #1e293b !important;
  font-weight: 600 !important;
}

/* Modals with gradient headers should have white titles */
.modal-header-gradient .uk-modal-title,
.modal-header-gradient .uk-modal-header .uk-modal-title,
.modal-header-gradient .modal-title-content .uk-modal-title {
  color: white !important;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
  .uk-modal-dialog {
    border-radius: 12px;
    margin: 20px;
  }

  .modal-form-header {
    padding: 1.5rem;
  }

  .modal-form-header__content {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.75rem;
  }

  .modal-form-header__icon {
    width: 36px;
    height: 36px;
    font-size: 1.125rem;
  }

  .modal-form-title {
    font-size: 1.125rem;
  }

  .modal-form-subtitle {
    font-size: 0.85rem;
  }

  .modal-form-body {
    padding: 1.25rem;
  }

  .modal-form-body fieldset {
    padding: 1rem 1.125rem 1.25rem;
    margin-bottom: 1.25rem;
  }

  .modal-form-actions {
    padding: 1.25rem;
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 0.625rem;
  }

  .modal-form-actions .uk-button {
    width: 100%;
  }
}

/* ===== SPECIFIC MODAL OVERRIDES ===== */

/* Modal con overflow hidden (solo per dettagli) */
.uk-modal-dialog[data-overflow-hidden="true"] {
  overflow: hidden;
}

/* Stili per campi readonly/disabled */
.modal-form-body input[readonly],
.modal-form-body textarea[readonly],
.modal-form-body select[disabled] {
  background-color: #f8fafc;
  color: #64748b;
  border-color: #e2e8f0;
  cursor: not-allowed;
}

/* ===== CHECKBOX STYLING ===== */
.modal-form-body .uk-form-label .uk-checkbox {
  width: 18px !important;
  height: 18px !important;
  border: 2px solid #cbd5e1 !important;
  border-radius: 4px !important;
  background: #fff !important;
  position: relative !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  accent-color: unset !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  margin-right: 0.5rem !important;
}

.modal-form-body .uk-form-label .uk-checkbox:checked {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  border-color: #667eea !important;
}

.modal-form-body .uk-form-label .uk-checkbox:checked::after {
  content: '✓' !important;
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
}

/* ===== TOGGLE SWITCH STYLING ===== */
.toggle-switch-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border: 1px solid #e5e5e5;
  border-radius: 10px;
  background: #fff;
  margin-bottom: 1rem;
}

.toggle-switch-field__text {
  flex: 1;
}

.toggle-switch-field__label {
  font-weight: 600;
  color: #1e293b;
  margin: 0;
  display: inline-block;
}

.toggle-switch-field__description {
  margin: 4px 0 0;
  font-size: 13px;
  color: #64748b;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 56px;
  height: 30px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #d6d6d6;
  transition: 0.3s ease;
  border-radius: 999px;
}

.toggle-slider::before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 4px;
  bottom: 4px;
  background-color: #fff;
  transition: 0.3s ease;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.toggle-switch input:checked+.toggle-slider {
  background-color: #667eea;
}

.toggle-switch input:checked+.toggle-slider::before {
  transform: translateX(26px);
}

.modal-form-body .uk-form-label .uk-checkbox:focus {
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1) !important;
}

.modal-form-body .uk-form-label {
  color: #1e293b !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
}

/* Animazioni per elementi che appaiono */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-form-body .uk-card {
  animation: fadeInUp 0.4s ease-out;
}

/* ===== STICKY FOOTER (se necessario) ===== */
.modal-form-actions[data-sticky="true"] {
  position: sticky;
  bottom: 0;
  z-index: 1;
}

/* ===== TINYMCE DIALOGS INSIDE UIKIT MODALS ===== */
/* Ensure TinyMCE dialogs (link editor, source code, etc.) appear above UIkit modals */
/* The .tox-tinymce-aux is the container for all TinyMCE floating UI elements */
.tox-tinymce-aux {
  z-index: 10100 !important;
}

.tox .tox-dialog-wrap {
  z-index: 10100 !important;
}

.tox .tox-dialog-wrap__backdrop {
  z-index: 10099 !important;
}

.tox .tox-dialog {
  z-index: 10100 !important;
}

/* Ensure TinyMCE notifications/toasts are visible */
.tox-notifications-container {
  z-index: 10101 !important;
}

/* TinyMCE color picker and other floating panels */
.tox-color-input__container,
.tox-swatches-wrap,
.tox-menu {
  z-index: 10100 !important;
}