﻿:root {
  --amd-accent: #e77918;
  --amd-accent-hover: #d96d15;
  --amd-accent-light: #fff5ed;
  --amd-success: #10b981;
  --amd-success-light: #d1fae5;
}

/* ====== BOTÓN REDONDO EXPANDIBLE ====== */
.amd-round-btn {
  --_size: 37px;
  --_expand: 220px;
  --_pad: 14px;

  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: var(--_size);
  height: var(--_size);
  border-radius: 9999px;
  overflow: hidden;

  background: #fff;
  border: 1px solid color-mix(in hsl, var(--amd-accent) 50%, #fff 50%);
  color: var(--amd-accent);
  outline: none;
  gap: 0;
  cursor: pointer;

  transition: width 0.5s cubic-bezier(0.25, 0.8, 0.25, 1),
    padding 0.5s cubic-bezier(0.25, 0.8, 0.25, 1), background 0.4s ease,
    border-color 0.4s ease, color 0.3s ease,
    gap 0.5s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.3s ease;
}

.amd-round-btn svg {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.3s ease;
}

.amd-round-btn::after {
  content: attr(aria-label);
  flex: 0 1 auto;
  white-space: nowrap;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: #fff;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  flex-shrink: 0;
  transition: max-width 0.5s cubic-bezier(0.25, 0.8, 0.25, 1),
    opacity 0.28s ease 0.08s;
}

.amd-round-btn:hover,
.amd-round-btn:focus-visible {
  width: var(--_expand);
  padding-inline: var(--_pad);
  justify-content: flex-start;
  gap: 0.6rem;
  background: color-mix(in hsl, var(--amd-accent) 96%, #fff 4%);
  border-color: color-mix(in hsl, var(--amd-accent) 80%, #fff 20%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(231, 121, 24, 0.25);
}

.amd-round-btn:hover::after,
.amd-round-btn:focus-visible::after {
  max-width: 260px;
  opacity: 1;
}

.amd-round-btn:active {
  transform: scale(0.97);
}

.amd-round-btn:focus-visible {
  outline: 3px solid color-mix(in hsl, var(--amd-accent) 30%, #fff 70%);
  outline-offset: 2px;
}

.amd-btn-wrap .amd-round-btn {
  --_size: 64px;
  --_expand: 240px;
}

/* ====== MODAL BASE CON ANIMACIONES ====== */
.amd-modal {
  position: fixed;
  inset: 0;
  z-index: 99998;
  display: grid;
  place-items: center;
  padding: 1rem;
  animation: amd-fadeIn 0.2s ease-out;
}

.amd-modal.hidden {
  display: none;
}

@keyframes amd-fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.amd-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  animation: amd-backdropFade 0.25s ease-out;
}

@keyframes amd-backdropFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.amd-dialog {
  position: relative;
  z-index: 99999;
  width: 100%;
  background: #fff;
  border-radius: 1.25rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12), 0 8px 16px rgba(0, 0, 0, 0.08);
  padding: 2rem;
  animation: amd-slideUp 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  transform-origin: center center;
}

@keyframes amd-slideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Header del modal más elegante */
.amd-dialog header h3 {
  color: #1e293b;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  letter-spacing: -0.025em;
}

/* ====== INPUTS MEJORADOS ====== */
.amd-dialog label {
  position: relative;
}

.amd-dialog label span {
  font-weight: 600;
  color: #475569;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  display: block;
  transition: color 0.2s ease;
}

.amd-dialog input[type="text"],
.amd-dialog textarea {
  width: 100%;
  border-radius: 0.75rem;
  border: 2px solid #e2e8f0;
  padding: 0.875rem 1rem;
  font-size: 0.9375rem;
  outline: none;
  background: #fff;
  transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
  color: #1e293b;
}

.amd-dialog input[type="text"]::placeholder,
.amd-dialog textarea::placeholder {
  color: #94a3b8;
}

.amd-dialog input[type="text"]:focus,
.amd-dialog textarea:focus {
  border-color: var(--amd-accent);
  box-shadow: 0 0 0 3px rgba(231, 121, 24, 0.1),
    0 2px 8px rgba(231, 121, 24, 0.08);
  transform: translateY(-1px);
}

.amd-dialog input[type="text"]:focus + span,
.amd-dialog textarea:focus + span {
  color: var(--amd-accent);
}

.amd-dialog textarea {
  min-height: 100px;
  resize: vertical;
  font-family: inherit;
}

/* ====== BOTONES DEL MODAL ====== */
.amd-btn-ghost,
.amd-btn-solid {
  padding: 0.625rem 1.5rem;
  border-radius: 0.625rem;
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  outline: none;
  border: none;
  transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* Botón Ghost (Cancelar) */
.amd-btn-ghost {
  background: transparent;
  color: #64748b;
  border: 2px solid #e2e8f0;
}

.amd-btn-ghost:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #475569;
  transform: translateY(-1px);
}

.amd-btn-ghost:active {
  transform: translateY(0);
  background: #f1f5f9;
}

/* Botón Sólido (Crear/Confirmar) */
.amd-btn-solid {
  background: linear-gradient(
    135deg,
    var(--amd-accent) 0%,
    var(--amd-accent-hover) 100%
  );
  color: #fff;
  box-shadow: 0 2px 8px rgba(231, 121, 24, 0.25);
  text-decoration: none;
}

.amd-btn-solid:hover {
  box-shadow: 0 4px 12px rgba(231, 121, 24, 0.35);
  transform: translateY(-2px);
}

.amd-btn-solid:active {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(231, 121, 24, 0.3);
}

/* ====== MODAL DE ÉXITO ====== */
.amd-dialog .bg-emerald-100 {
  background: var(--amd-success-light);
  animation: amd-successPulse 0.6s ease-out;
}

@keyframes amd-successPulse {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.amd-dialog .text-emerald-700 {
  color: var(--amd-success);
}

/* Animación del checkmark */
.amd-modal:not(.hidden) .text-emerald-700 path {
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
  animation: amd-checkDraw 0.5s ease-out 0.2s forwards;
}

@keyframes amd-checkDraw {
  to {
    stroke-dashoffset: 0;
  }
}

/* ====== MEJORAS EN FOOTER ====== */
.amd-dialog footer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.75rem;
  flex-wrap: wrap;
}

.amd-dialog footer.justify-end {
  justify-content: flex-end;
}

.amd-dialog footer.justify-center {
  justify-content: center;
}

/* ====== BLOQUEAR SCROLL ====== */
.amdp-modal-open {
  overflow: hidden;
}

/* ====== RESPONSIVE ====== */
@media (max-width: 640px) {
  .amd-dialog {
    padding: 1.5rem;
    margin: 1rem;
  }

  .amd-dialog header h3 {
    font-size: 1.25rem;
  }

  .amd-dialog footer {
    flex-direction: column-reverse;
    gap: 0.5rem;
  }

  .amd-btn-ghost,
  .amd-btn-solid {
    width: 100%;
    justify-content: center;
  }
}

/* ====== REDUCED MOTION ====== */
@media (prefers-reduced-motion: reduce) {
  .amd-round-btn,
  .amd-round-btn svg,
  .amd-round-btn::after,
  .amd-dialog,
  .amd-backdrop,
  .amd-modal,
  .amd-dialog input,
  .amd-dialog textarea,
  .amd-btn-ghost,
  .amd-btn-solid {
    animation: none !important;
    transition: none !important;
  }
}

/* ====== DETALLES ADICIONALES ====== */

/* Mejora visual del contenedor de espacio */
.amd-dialog .space-y-3 > * + * {
  margin-top: 1rem;
}

.amd-dialog .mb-4 {
  margin-bottom: 1.25rem;
}

/* Texto descriptivo más suave */
.amd-dialog .text-slate-600 {
  color: #64748b;
  line-height: 1.6;
}

/* Estado de carga opcional (puedes agregarlo al JS) */
.amd-btn-solid.loading {
  pointer-events: none;
  opacity: 0.7;
  position: relative;
}

.amd-btn-solid.loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: amd-spin 0.6s linear infinite;
}

@keyframes amd-spin {
  to {
    transform: rotate(360deg);
  }
}
