/* ============ MGPANEL BASE STYLES ============ */
/* Estilos base para componentes MGPanel disponibles globalmente */
:root {
  --systemMg-primary: #0056b3;
  --systemMg-secondary: #6c757d;
  --systemMg-success: #28a745;
  --systemMg-danger: #dc3545;
  --systemMg-warning: #ffc107;
  --systemMg-info: #17a2b8;
  --systemMg-light: #fafafa;
  --systemMg-dark: #2d3436;
  --systemMg-white: #ffffff;
  --systemMg-background: #ffffff;
  --systemMg-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --systemMg-border-radius: 4px;
  --systemMg-input-padding: 8px 12px;
  --systemMg-input-height: 42px;
  --systemMg-box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

/* ============ PANEL DE PERSONALIZACIÓN ESTILO CANVA ============ */

.mgpanel-customizer {
  position: fixed;
  top: 50%;
  right: 20px;
  transform: translateY(-50%);
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  pointer-events: none;
}

.mgpanel-customizer * {
  pointer-events: all;
}

/* Botón flotante principal */
.mgpanel-customizer-trigger {
  width: 48px;
  height: 48px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.04);
  user-select: none;
  position: relative;
  overflow: hidden;
}

.mgpanel-customizer-trigger:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1), 0 8px 24px rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.12);
}

.mgpanel-customizer-trigger.active {
  background: #6366f1;
  border-color: #6366f1;
  color: white;
  transform: scale(1.05);
}

.mgpanel-customizer-icon {
  width: 20px;
  height: 20px;
  transition: all 0.2s ease;
  position: relative;
}

.mgpanel-customizer-trigger.active .mgpanel-customizer-icon {
  transform: rotate(45deg);
}

/* Panel lateral estilo Canva */
.mgpanel-customizer-panel {
  position: absolute;
  top: 50%;
  right: calc(100% + 12px);
  transform: translateY(-50%);
  width: 280px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.06);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-50%) translateX(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  backdrop-filter: blur(20px);
}

.mgpanel-customizer.open .mgpanel-customizer-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) translateX(0) scale(1);
}

/* Header del panel */
.mgpanel-customizer-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(249, 250, 251, 0.8);
}

.mgpanel-customizer-title {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mgpanel-customizer-subtitle {
  font-size: 12px;
  color: #6b7280;
  margin: 2px 0 0 0;
  font-weight: 400;
}

/* Contenido del panel */
.mgpanel-customizer-content {
  padding: 0;
  max-height: 400px;
  overflow-y: auto;
}

/* Sección del panel */
.mgpanel-customizer-section {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.mgpanel-customizer-section:last-child {
  border-bottom: none;
}

.mgpanel-customizer-section-title {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin: 0 0 12px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mgpanel-customizer-section-icon {
  width: 16px;
  height: 16px;
  opacity: 0.7;
}

/* Opciones de idioma */
.mgpanel-lang-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mgpanel-lang-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: #374151;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
}

.mgpanel-lang-option:hover {
  background: rgba(99, 102, 241, 0.04);
  border-color: rgba(99, 102, 241, 0.1);
  text-decoration: none;
  color: #6366f1;
}

.mgpanel-lang-option.active {
  background: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.2);
  color: #6366f1;
  font-weight: 600;
}

.mgpanel-lang-flag {
  width: 20px;
  height: 15px;
  border-radius: 3px;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

.mgpanel-lang-flag[data-lang="es"] {
  background-image: url('/public/base/base-12.0.1/media/flags/es.png');
}

.mgpanel-lang-flag[data-lang="us"] {
  background-image: url('/public/base/base-12.0.1/media/flags/us.png');
}

/* Posiciones del panel */
.mgpanel-customizer.position-left {
  left: 20px;
  right: auto;
}

.mgpanel-customizer.position-left .mgpanel-customizer-panel {
  left: calc(100% + 12px);
  right: auto;
  transform: translateY(-50%) translateX(-20px) scale(0.95);
}

.mgpanel-customizer.position-left.open .mgpanel-customizer-panel {
  transform: translateY(-50%) translateX(0) scale(1);
}

.mgpanel-customizer.position-top {
  top: 20px;
  transform: none;
}

.mgpanel-customizer.position-top .mgpanel-customizer-panel {
  top: calc(100% + 12px);
  transform: translateX(-50%) translateY(-20px) scale(0.95);
  left: 50%;
  right: auto;
}

.mgpanel-customizer.position-top.open .mgpanel-customizer-panel {
  transform: translateX(-50%) translateY(0) scale(1);
}

.mgpanel-customizer.position-bottom {
  bottom: 20px;
  top: auto;
  transform: none;
}

.mgpanel-customizer.position-bottom .mgpanel-customizer-panel {
  bottom: calc(100% + 12px);
  top: auto;
  transform: translateX(-50%) translateY(20px) scale(0.95);
  left: 50%;
  right: auto;
}

.mgpanel-customizer.position-bottom.open .mgpanel-customizer-panel {
  transform: translateX(-50%) translateY(0) scale(1);
}

/* Responsive */
@media (max-width: 768px) {
  .mgpanel-customizer {
    right: 16px;
  }
  
  .mgpanel-customizer.position-left {
    left: 16px;
  }
  
  .mgpanel-customizer.position-top {
    top: 16px;
  }
  
  .mgpanel-customizer.position-bottom {
    bottom: 16px;
  }
  
  .mgpanel-customizer-trigger {
    width: 44px;
    height: 44px;
  }
  
  .mgpanel-customizer-icon {
    width: 18px;
    height: 18px;
  }
  
  .mgpanel-customizer-panel {
    width: 260px;
    max-height: 70vh;
  }
  
  .mgpanel-customizer-content {
    max-height: 300px;
  }
}

/* Animaciones */
.mgpanel-customizer {
  animation: mgpanel-fade-in 0.4s ease-out;
}

@keyframes mgpanel-fade-in {
  from {
    opacity: 0;
    transform: translateY(-50%) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(-50%) scale(1);
  }
}

/* Estados de carga */
.mgpanel-customizer.loading .mgpanel-customizer-trigger {
  opacity: 0.7;
  pointer-events: none;
}

.mgpanel-customizer.loading .mgpanel-customizer-trigger::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: mgpanel-spin 1s linear infinite;
}

@keyframes mgpanel-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Scrollbar personalizado para el panel */
.mgpanel-customizer-content::-webkit-scrollbar {
  width: 4px;
}

.mgpanel-customizer-content::-webkit-scrollbar-track {
  background: transparent;
}

.mgpanel-customizer-content::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 2px;
}

.mgpanel-customizer-content::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.2);
}

/* ============ SHORTCODES MGPanel ============ */

/* Estilos base para shortcodes */
.mg-shortcode-form,
.mg-shortcode-blog {
  margin: 20px 0;
  padding: 20px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Formulario shortcode */
.mg-shortcode-form h3,
.mg-shortcode-form p {
  margin: 0 0 12px 0;
  color: #374151;
}

.mg-shortcode-form form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 16px;
}

.mg-shortcode-form input,
.mg-shortcode-form textarea {
  padding: 12px 16px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s ease;
  background: #ffffff;
}

.mg-shortcode-form input:focus,
.mg-shortcode-form textarea:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.08);
}

.mg-shortcode-form textarea {
  min-height: 100px;
  resize: vertical;
}

.mg-shortcode-form button {
  padding: 12px 24px;
  background: #6366f1;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  align-self: flex-start;
}

.mg-shortcode-form button:hover {
  background: #5856eb;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

/* Blog shortcode */
.mg-shortcode-blog h3 {
  margin: 0 0 16px 0;
  color: #111827;
  font-size: 20px;
  font-weight: 600;
}

.mg-shortcode-blog p {
  margin: 0 0 16px 0;
  color: #6b7280;
  font-size: 14px;
}

.blog-posts {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.blog-post {
  padding: 16px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  color: #374151;
  font-size: 14px;
  transition: all 0.15s ease;
}

.blog-post:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}

/* Variantes de estilo */
.mg-shortcode-form.style-modern {
  border: none;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 8px 32px rgba(102, 126, 234, 0.25);
}

.mg-shortcode-form.style-modern input,
.mg-shortcode-form.style-modern textarea {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #374151;
}

.mg-shortcode-form.style-modern input:focus,
.mg-shortcode-form.style-modern textarea:focus {
  background: rgba(255, 255, 255, 1);
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
}

.mg-shortcode-form.style-modern button {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(10px);
}

.mg-shortcode-form.style-modern button:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
}

/* Estilo minimalista */
.mg-shortcode-form.style-minimal {
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 0;
}

.mg-shortcode-form.style-minimal input,
.mg-shortcode-form.style-minimal textarea {
  border: none;
  border-bottom: 2px solid #e5e7eb;
  border-radius: 0;
  background: transparent;
  padding: 12px 0;
}

.mg-shortcode-form.style-minimal input:focus,
.mg-shortcode-form.style-minimal textarea:focus {
  border-bottom-color: #6366f1;
  box-shadow: none;
}

/* Estilos adicionales para campos de formulario */
.mg-shortcode-form .mg-form-field {
  margin-bottom: 20px;
}

.mg-shortcode-form .mg-field-label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: #374151;
  font-size: 14px;
}

.mg-shortcode-form .mg-field-description {
  margin: 4px 0 8px 0;
  color: #6b7280;
  font-size: 13px;
  line-height: 1.4;
}

.mg-shortcode-form .mg-required {
  color: #ef4444;
  margin-left: 2px;
}

.mg-shortcode-form .mg-select {
  padding: 12px 16px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s ease;
  background: #ffffff;
  width: 100%;
  cursor: pointer;
}

.mg-shortcode-form .mg-select:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.08);
}

.mg-shortcode-form .mg-radio-group,
.mg-shortcode-form .mg-checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.mg-shortcode-form .mg-radio-option,
.mg-shortcode-form .mg-checkbox-option {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mg-shortcode-form .mg-radio-option input,
.mg-shortcode-form .mg-checkbox-option input {
  margin: 0;
  width: auto;
}

.mg-shortcode-form .mg-radio-option label,
.mg-shortcode-form .mg-checkbox-option label {
  margin: 0;
  font-weight: 400;
  cursor: pointer;
  user-select: none;
}

.mg-shortcode-form fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

.mg-shortcode-form legend {
  font-weight: 600;
  margin-bottom: 8px;
  color: #374151;
  font-size: 14px;
  padding: 0;
}

.mg-shortcode-form .mg-field-title {
  margin: 0 0 16px 0;
  color: #111827;
  font-size: 24px;
  font-weight: 700;
}

.mg-shortcode-form .mg-field-subtitle {
  margin: 8px 0 16px 0;
  color: #6b7280;
  font-size: 16px;
  line-height: 1.5;
}

.mg-shortcode-form .mg-field-header {
  margin: 0 0 12px 0;
  color: #111827;
  font-size: 18px;
  font-weight: 600;
}

.mg-shortcode-form .mg-field-subheader {
  margin: 4px 0 12px 0;
  color: #6b7280;
  font-size: 14px;
  line-height: 1.5;
}

.mg-shortcode-form .mg-field-text {
  padding: 12px 0;
}

.mg-shortcode-form .mg-field-text strong {
  color: #111827;
  font-size: 16px;
}

.mg-shortcode-form .mg-field-text p {
  margin: 8px 0 0 0;
  color: #6b7280;
  line-height: 1.5;
}

/* Estados de error */
.mg-shortcode-form .mg-input.mg-error,
.mg-shortcode-form .mg-textarea.mg-error,
.mg-shortcode-form .mg-select.mg-error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.08);
}

.mg-alert {
  position: relative;
  padding: 16px 20px;
  margin-bottom: 20px;
  border-radius: 8px;
  display: flex;
  align-items: flex-start;
  border-left-width: 4px;
  border-left-style: solid;
  background-color: #f8f9fa;
  line-height: 1.5;
}

.mg-alert i {
  margin-right: 12px;
  font-size: 20px;
  margin-top: 2px;
}

.mg-alert p {
  margin: 0;
  flex: 1;
  font-size: 0.95em;
}

.mg-alert-warning {
  border-left-color: var(--system-warning);
  background-color: rgba(255, 193, 7, 0.1);
}

.mg-alert-warning i {
  color: var(--system-warning);
}

.mg-alert-danger {
  border-left-color: var(--system-danger);
  background-color: rgba(220, 53, 69, 0.1);
}

.mg-alert-danger i {
  color: var(--system-danger);
}

.mg-alert-success {
  border-left-color: var(--system-success);
  background-color: rgba(40, 167, 69, 0.1);
}

.mg-alert-success i {
  color: var(--system-success);
}

.mg-alert-info {
  border-left-color: var(--system-info);
  background-color: rgba(23, 162, 184, 0.1);
}

.mg-alert-info i {
  color: var(--system-info);
}

.mg-input.mg-invalid,
.mg-textarea.mg-invalid,
.mg-select.mg-invalid {
  border-color: var(--systemMg-danger);
}

.mg-input.mg-invalid:focus,
.mg-textarea.mg-invalid:focus,
.mg-select.mg-invalid:focus {
  border-color: var(--systemMg-danger);
  box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
}

.mg-shortcode-form .mg-form-actions .mg-btn-primary i {
  margin-right: 8px;
}

/* Responsive */
@media (max-width: 768px) {
  .mg-shortcode-form,
  .mg-shortcode-blog {
    padding: 16px;
    margin: 16px 0;
  }
  
  .mg-shortcode-form form {
    gap: 12px;
  }
  
  .mg-shortcode-form input,
  .mg-shortcode-form textarea {
    padding: 10px 12px;
    font-size: 16px; /* Prevenir zoom en iOS */
  }
  
  .mg-shortcode-form .mg-radio-group,
  .mg-shortcode-form .mg-checkbox-group {
    gap: 12px;
  }
}
