/* ══════════════════════════════════════════════════════════════
   🎨 MODALES FRAPPE - RECREADO DESDE CERO
   ══════════════════════════════════════════════════════════════ */

/* 🎯 RESET Y BASE DEL MODAL */
.modal {
  --bs-modal-zindex: 1055;
  --bs-modal-width: 520px;
  --bs-modal-padding: 0;
  --bs-modal-margin: 0.5rem;
  --bs-modal-bg: white;
  --bs-modal-border-color: transparent;
  --bs-modal-border-width: 0;
  --bs-modal-border-radius: 8px;
  --bs-modal-box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

/* 🎯 BACKDROP MÁS OSCURO */
.modal-backdrop {
  background-color: rgba(0, 0, 0, 0.5);
}

/* 🎯 DIALOG CONTAINER */
.modal-dialog {
  max-width: 520px;
  margin: 1.75rem auto;
}

.modal-dialog-centered {
  min-height: calc(100% - 3.5rem);
}

/* 🎯 MODAL CONTENT */
.modal-content {
  border: none;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  background: white;
}

/* 🎯 HEADER ESTILO FRAPPE */
.modal-header {
  background: white;
  border-bottom: none; /* Sin borde */
  padding: 1.5rem 1.5rem 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: #212529;
  margin: 0;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

/* 🎯 CLOSE BUTTON FRAPPE STYLE */
.btn-close {
  background: transparent;
  border: none;
  opacity: 1;
  padding: 0;
  margin: -0.25rem -0.5rem -0.25rem 0;
  width: 1.5rem;
  height: 1.5rem;
  color: #6c757d;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.btn-close::before {
  content: '×';
  display: block;
}

.btn-close:hover {
  color: #000;
  opacity: 1;
}

/* 🎯 BODY */
.modal-body {
  padding: 1.5rem;
  background: white;
}

/* 🎯 FOOTER */
.modal-footer {
  background: white;
  border-top: none;
  padding: 0 1.5rem 1.5rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ══════════════════════════════════════════════════════════════
   🎨 FORM ELEMENTS FRAPPE STYLE
   ══════════════════════════════════════════════════════════════ */

/* 🎯 FORM LAYOUT */
.modal-body .row {
  margin: 0 -0.5rem;
}

.modal-body .col,
.modal-body .col-6,
.modal-body .col-md-6,
.modal-body .col-4,
.modal-body .col-md-4 {
  padding: 0 0.5rem;
}

/* 🎯 FORM GROUPS */
.modal-body .mb-3,
.modal-body .form-group {
  margin-bottom: 1rem;
}

/* 🎯 LABELS */
.modal-body label,
.modal-body .form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #6c757d;
  margin-bottom: 0.375rem;
  text-transform: none;
  letter-spacing: 0;
}

/* 🎯 REQUIRED ASTERISK */
.modal-body label .required,
.modal-body label:has(+ input:required)::after {
  content: ' *';
  color: #dc3545;
}

/* 🎯 INPUT FIELDS */
.modal-body input[type="text"],
.modal-body input[type="email"],
.modal-body input[type="number"],
.modal-body input[type="tel"],
.modal-body input[type="password"],
.modal-body textarea,
.modal-body select,
.modal-body .form-control,
.modal-body .form-select {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.5;
  color: #212529;
  background-color: #f8f9fa;
  background-clip: padding-box;
  border: 1px solid #f8f9fa;
  border-radius: 4px;
  transition: border-color 0.15s ease-in-out, background-color 0.15s ease-in-out;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* 🎯 PLACEHOLDER */
.modal-body input::placeholder,
.modal-body textarea::placeholder,
.modal-body .form-control::placeholder {
  color: #adb5bd;
  opacity: 1;
}

/* 🎯 FOCUS STATE */
.modal-body input:focus,
.modal-body textarea:focus,
.modal-body select:focus,
.modal-body .form-control:focus,
.modal-body .form-select:focus {
  background-color: white;
  border-color: #86b7fe;
  outline: 0;
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* 🎯 SELECT DROPDOWN */
.modal-body select,
.modal-body .form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px 12px;
  padding-right: 2.5rem;
}

/* ══════════════════════════════════════════════════════════════
   🎨 BUTTONS FRAPPE STYLE
   ══════════════════════════════════════════════════════════════ */

/* 🎯 PRIMARY BUTTON (Create) */
.modal-footer .btn-primary,
.modal-footer button[type="submit"],
.modal-footer .btn-create {
  background-color: #212529;
  border: 1px solid #212529;
  color: white;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  min-width: 70px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  line-height: 1;
}

.modal-footer .btn-primary:hover,
.modal-footer button[type="submit"]:hover,
.modal-footer .btn-create:hover {
  background-color: #000;
  border-color: #000;
  transform: none;
  box-shadow: none;
}

/* 🎯 SECONDARY BUTTON */
.modal-footer .btn-secondary,
.modal-footer .btn-cancel {
  background-color: white;
  border: 1px solid #dee2e6;
  color: #495057;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  min-width: 70px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  line-height: 1;
}

.modal-footer .btn-secondary:hover,
.modal-footer .btn-cancel:hover {
  background-color: #f8f9fa;
  border-color: #adb5bd;
  color: #495057;
}

/* ══════════════════════════════════════════════════════════════
   🎨 ICONS IN MODAL
   ══════════════════════════════════════════════════════════════ */

/* 🎯 ICON BUTTONS */
.modal-header .icon-btn {
  background: transparent;
  border: none;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: #6c757d;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  margin-left: 0.5rem;
}

.modal-header .icon-btn:hover {
  background-color: #f8f9fa;
  color: #495057;
}

/* 🎯 FIELD ICONS */
.input-group-text {
  background-color: #f8f9fa;
  border: 1px solid #f8f9fa;
  color: #6c757d;
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
}

/* ══════════════════════════════════════════════════════════════
   🎨 RADIO BUTTONS FRAPPE STYLE
   ══════════════════════════════════════════════════════════════ */

.modal-body .form-check {
  display: flex;
  align-items: center;
  margin-bottom: 0.5rem;
  padding-left: 0;
}

.modal-body .form-check-input {
  width: 1rem;
  height: 1rem;
  margin-top: 0;
  margin-right: 0.5rem;
  background-color: white;
  border: 2px solid #dee2e6;
  cursor: pointer;
}

.modal-body .form-check-input:checked {
  background-color: #212529;
  border-color: #212529;
}

.modal-body .form-check-label {
  font-size: 0.875rem;
  color: #212529;
  cursor: pointer;
  margin-bottom: 0;
}

/* ══════════════════════════════════════════════════════════════
   🎨 RESPONSIVE
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 576px) {
  .modal-dialog {
    max-width: calc(100% - 1rem);
    margin: 0.5rem;
  }
  
  .modal-content {
    border-radius: 0.5rem;
  }
  
  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 1rem;
  }
}

/* ══════════════════════════════════════════════════════════════
   🎨 UTILITIES
   ══════════════════════════════════════════════════════════════ */

/* Para centrar verticalmente el modal */
.modal.show {
  display: flex !important;
  align-items: center;
  min-height: 100%;
}

/* Animación suave */
.modal.fade .modal-dialog {
  transition: transform 0.2s ease-out;
  transform: scale(0.95) translateY(-10px);
}

.modal.show .modal-dialog {
  transform: scale(1) translateY(0);
}

/* ══════════════════════════════════════════════════════════════
   🎨 MODAL CAMBIAR ORGANIZACIÓN - ESTILO FRAPPE
   ══════════════════════════════════════════════════════════════ */

/* 🎯 AJUSTES AL MODAL - MÁS ANCHO */
#switchOrgModal .modal-dialog {
  max-width: 560px; /* 🔥 AUMENTADO de 420px a 560px */
}

#switchOrgModal .modal-content {
  min-width: 500px; /* 🔥 AÑADIR: ancho mínimo */
}

/* 🎯 LISTA DE ORGANIZACIONES */
.organization-list {
  margin: 0 -1.5rem;
  padding: 0 1rem;
}

.organization-item {
  display: flex;
  align-items: center;
  padding: 0.875rem 1rem; /* 🔥 AUMENTAR padding horizontal */
  margin-bottom: 0.5rem; /* 🔥 AUMENTAR espacio entre items */
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

/* 🎯 ICONO DE ORGANIZACIÓN */
.org-icon {
  width: 44px; /* 🔥 LIGERAMENTE MÁS GRANDE */
  height: 44px; /* 🔥 LIGERAMENTE MÁS GRANDE */
  background-color: #e3f2fd;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #2196f3;
  font-size: 1.25rem; /* 🔥 ICONO MÁS GRANDE */
  margin-right: 1rem; /* 🔥 MÁS ESPACIO */
  flex-shrink: 0;
}

/* 🎯 INFORMACIÓN DE LA ORGANIZACIÓN */
.org-info {
  flex: 1;
  min-width: 0;
  padding-right: 1rem; /* 🔥 AÑADIR: espacio a la derecha */
}

.org-name {
  font-size: 0.9375rem; /* 🔥 LIGERAMENTE MÁS GRANDE */
  font-weight: 600;
  color: #2196f3;
  text-decoration: underline;
  margin-bottom: 0.125rem;
}

/* 🎯 AJUSTAR PADDING DEL MODAL */
#switchOrgModal .modal-header {
  padding: 1.25rem 1.75rem; /* 🔥 MÁS PADDING HORIZONTAL */
  border-bottom: 1px solid #e5e7eb;
}

#switchOrgModal .modal-body {
  padding: 1.25rem 1.75rem; /* 🔥 MÁS PADDING HORIZONTAL */
}

#switchOrgModal .modal-footer {
  padding: 1rem 1.75rem; /* 🔥 MÁS PADDING HORIZONTAL */
  border-top: 1px solid #e5e7eb;
}

/* ══════════════════════════════════════════════════════════════
   🎨 MODAL CAMBIAR ORGANIZACIÓN - DROPDOWN ESTILO FRAPPE
   ══════════════════════════════════════════════════════════════ */

/* 🎯 IMPORTANTE: Permitir que el modal muestre overflow */
#switchOrgModal .modal-body {
  overflow: visible !important;
}

#switchOrgModal .modal-content {
  overflow: visible !important;
}

#switchOrgModal .modal-dialog {
  overflow: visible !important;
}

/* 🎯 FRAPPE DROPDOWN EN MODAL */
#switchOrgModal .frappe-dropdown {
  position: relative;
  width: 100%;
}

/* 🎯 TOGGLE BUTTON */
#switchOrgModal .frappe-dropdown-toggle {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.875rem;
  color: #212529;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  min-height: 38px;
}

#switchOrgModal .frappe-dropdown-toggle:hover,
#switchOrgModal .frappe-dropdown-toggle:focus,
#switchOrgModal .frappe-dropdown-toggle.active {
  background: white;
  border-color: #0d6efd;
  outline: none;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

#switchOrgModal .dropdown-icon {
  font-size: 0.75rem;
  color: #6c757d;
  transition: transform 0.15s ease;
}

#switchOrgModal .frappe-dropdown-toggle.active .dropdown-icon {
  transform: rotate(180deg);
}

/* 🎯 DROPDOWN PANEL */
#switchOrgModal .dropdown-panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  min-width: 100%;
  overflow: hidden;
}

/* 🎯 SEARCH BOX */
#switchOrgModal .dropdown-search {
  padding: 8px;
  border-bottom: 1px solid #dee2e6;
  position: relative;
}

#switchOrgModal .dropdown-search-input {
  width: 100%;
  padding: 0.375rem 2rem 0.375rem 0.75rem;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  font-size: 0.8125rem;
  outline: none;
}

#switchOrgModal .dropdown-search-input:focus {
  border-color: #0d6efd;
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

#switchOrgModal .clear-search {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #6c757d;
  cursor: pointer;
  font-size: 0.875rem;
}

#switchOrgModal .clear-search:hover {
  color: #212529;
}

/* 🎯 DROPDOWN LIST */
#switchOrgModal .dropdown-list {
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.25rem 0;
}

/* 🎯 DROPDOWN ITEMS */
#switchOrgModal .dropdown-item {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  cursor: pointer;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  transition: background 0.15s ease;
}

#switchOrgModal .dropdown-item:hover {
  background: #f8f9fa;
}

#switchOrgModal .dropdown-item.selected {
  background: #e7f3ff;
}

#switchOrgModal .item-icon {
  font-size: 1rem;
  color: #0d6efd;
  margin-right: 0.5rem;
  width: 1.25rem;
  text-align: center;
}

#switchOrgModal .item-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#switchOrgModal .item-check {
  color: #198754;
  font-size: 0.875rem;
  margin-left: auto;
  flex-shrink: 0;
}

/* 🎯 DROPDOWN ACTIONS */
#switchOrgModal .dropdown-actions {
  border-top: 1px solid #dee2e6;
  padding: 0.5rem;
}

#switchOrgModal .dropdown-action-btn {
  width: 100%;
  padding: 0.375rem 0.75rem;
  background: transparent;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  font-size: 0.75rem;
  color: #6c757d;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  transition: all 0.15s ease;
}

#switchOrgModal .dropdown-action-btn:hover {
  background: #f8f9fa;
  color: #212529;
  border-color: #adb5bd;
}

/* 🎯 SCROLLBAR STYLE */
#switchOrgModal .dropdown-list::-webkit-scrollbar {
  width: 6px;
}

#switchOrgModal .dropdown-list::-webkit-scrollbar-track {
  background: #f8f9fa;
}

#switchOrgModal .dropdown-list::-webkit-scrollbar-thumb {
  background: #dee2e6;
  border-radius: 3px;
}

#switchOrgModal .dropdown-list::-webkit-scrollbar-thumb:hover {
  background: #adb5bd;
}

/* 🎯 RESPONSIVE */
@media (max-width: 576px) {
  #switchOrgModal .dropdown-panel {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 12px 12px 0 0;
    max-height: 70vh;
    margin-top: 0;
  }
  
  #switchOrgModal .dropdown-list {
    max-height: 50vh;
  }
}