:root {
  --background: 0 0% 100%;
  --foreground: 222.2 84% 4.9%;
  --card: 0 0% 100%;
  --card-foreground: 222.2 84% 4.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 222.2 84% 4.9%;
  --primary: 222.2 47.4% 11.2%;
  --primary-foreground: 210 40% 98%;
  --secondary: 210 40% 96%;
  --secondary-foreground: 222.2 84% 4.9%;
  --muted: 210 40% 96%;
  --muted-foreground: 215.4 16.3% 46.9%;
  --accent: 210 40% 96%;
  --accent-foreground: 222.2 84% 4.9%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 210 40% 98%;
  --border: 214.3 31.8% 91.4%;
  --input: 214.3 31.8% 91.4%;
  --ring: 222.2 84% 4.9%;
  --radius: 0.5rem;

  /* Toast Colors */
  --info: 221.2 83.2% 53.3%;
  --info-foreground: 210 40% 98%;
}

[data-theme="dark"] {
  --background: 222.2 84% 4.9%;
  --foreground: 210 40% 98%;
  --card: 222.2 84% 4.9%;
  --card-foreground: 210 40% 98%;
  --popover: 222.2 84% 4.9%;
  --popover-foreground: 210 40% 98%;
  --primary: 210 40% 98%;
  --primary-foreground: 222.2 47.4% 11.2%;
  --secondary: 217.2 32.6% 17.5%;
  --secondary-foreground: 210 40% 98%;
  --muted: 217.2 32.6% 17.5%;
  --muted-foreground: 215 20.2% 65.1%;
  --accent: 217.2 32.6% 17.5%;
  --accent-foreground: 210 40% 98%;
  --destructive: 0 62.8% 30.6%;
  --destructive-foreground: 210 40% 98%;
  --border: 217.2 32.6% 17.5%;
  --input: 217.2 32.6% 17.5%;
  --ring: 212.7 26.8% 83.9%;

  /* Dark Toast Colors */
  --info: 221.2 83.2% 53.3%;
  --info-foreground: 210 40% 98%;
}

.toast-container {
  position: fixed;
  top: 4.5em;
  right: 0;
  display: flex;
  max-height: 100vh;
  width: 34em;
  flex-direction: column-reverse;
  padding: 1rem;
  z-index: 9999;
  gap: 0.5rem;
  pointer-events: none;
}

.map-toast-container {
  position: fixed;
  top: 5rem;
  right: 3rem;
  display: flex;
  max-height: calc(100vh - 5rem);
  max-width: 26em;
  width: 100%;
  flex-direction: column-reverse;
  padding: 1rem;
  z-index: 9999;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  position: relative;
  pointer-events: auto;
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  padding: 0.75rem 0.875rem;
  color: hsl(var(--foreground));
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.2s ease-out;
}

.toast[data-state="open"] {
  opacity: 1;
  transform: translateX(0);
}

.toast[data-state="closed"] {
  opacity: 0;
  transform: translateX(100%);
}

.toast-viewport {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 9999;
  margin: 0;
  display: flex;
  max-height: 100vh;
  width: 420px;
  flex-direction: column-reverse;
  padding: 1rem;
  gap: 0.5rem;
  list-style: none;
  outline: none;
}

/* VARIANTES DE TOAST */
.toast[data-variant="default"] {
  background: #505050;
  border: 1px solid #505050;
  color: hsl(210 40% 98%);
}

.toast[data-variant="default"] .toast-close {
  color: hsl(210 40% 98% / 0.7);
}

.toast[data-variant="default"] .toast-close:hover {
  background: hsl(210 40% 98% / 0.1);
  color: hsl(210 40% 98%);
}

.toast[data-variant="info"] {
  background: hsl(var(--info));
  border: 1px solid hsl(var(--info));
  color: hsl(var(--info-foreground));
}

.toast[data-variant="info"] .toast-close {
  color: hsl(var(--info-foreground) / 0.7);
}

.toast[data-variant="info"] .toast-close:hover {
  background: hsl(var(--info-foreground) / 0.1);
  color: hsl(var(--info-foreground));
}

.toast[data-variant="error"] {
  background: hsl(var(--destructive));
  border: 1px solid hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

.toast[data-variant="success"] {
  background: hsl(142.1 76.2% 36.3%);
  border: 1px solid hsl(142.1 76.2% 36.3%);
  color: hsl(355.7 100% 97.3%);
}

.toast[data-variant="warning"] {
  background: hsl(43.3 96.4% 56.3%);
  border: 1px solid hsl(43.3 96.4% 56.3%);
  color: hsl(222.2 84% 4.9%);
}

/* ESTRUCTURA DE CONTENIDO DE TOAST */
.toast-content {
  display: grid;
  gap: 0.5rem;
  flex: 1;
}

/* Extra helpers for integrated upload inline toast */
.toast-file-item {
  margin: 8px 0;
  padding: 8px 8px 6px 8px;
  background: #f8f9fa;
  border-radius: 4px;
  border-left: 3px solid #ddd;
}

.toast-file-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 4px;
  min-width: 0;
  width: 100%;
}

.toast-file-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
  gap: 12px;
}

.toast-file-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: white;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
  line-height: 1.25rem;
}

.toast-file-size {
  font-size: 0.75rem;
  color: white;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  opacity: 0.8;
  padding: 0 1.5rem;
}

.toast-title {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25rem;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast-description {
  font-size: 0.875rem;
  line-height: 1.25rem;
  opacity: 0.9;
  margin: 0;
}

/* Utility for hiding elements */
.is-hidden { display: none !important; }

/* Upload status pills and states */
.upload-status { font-size: 0.9em; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.status-pill { background: rgba(255,255,255,0.8); padding: 2px 6px; border-radius: 12px; font-size: 0.85em; min-width: 45px; text-align: center; }
.status-pill--success { background: hsl(142.1 76.2% 36.3%); color: white; }
.status-pill--error { background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }
.upload-status--uploading { color: #ff9800; }
.upload-status--success { color: hsl(142.1 76.2% 36.3%); }
.upload-status--error { color: hsl(var(--destructive)); }

/* Compact progress bar inside toast */
.toast .progress-bar {
  height: 8px;
  width: 100%;
  background: hsl(var(--muted));
  border-radius: 4px;
  overflow: hidden;
  margin-top: 4px;
}
.toast .progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, hsl(142.1 76.2% 36.3%), hsl(142.1 70% 45%));
  border-radius: 4px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Global progress toast styling - Consolidated Design */
.global-progress-toast {
  min-width: 380px;
  max-width: 480px;
}

.global-progress-toast .toast-title {
  margin-bottom: 0.25rem;
}

.global-progress-toast .upload-status-text {
  margin-bottom: 0.75rem;
}

.global-progress-toast .progress-bar {
  height: 8px;
  margin-bottom: 0.75rem;
  background: hsl(214 32% 91%);
  border-radius: 4px;
  overflow: hidden;
}

.global-progress-toast .global-progress-fill {
  background: linear-gradient(90deg, #2196f3, #42a5f5);
  transition: width 0.3s ease;
}


/* Success state styling */
.global-progress-toast[data-variant="success"] .upload-title {
  color: hsl(142 76% 36%);
}

.global-progress-toast[data-variant="success"] .global-percentage {
  color: hsl(142 76% 30%);
}

.global-progress-toast[data-variant="success"] .global-progress-fill {
  background: linear-gradient(90deg, hsl(142 76% 36%), hsl(142 76% 45%));
}

/* BOTON DE ACCION DE TOAST */
.toast-action {
  display: inline-flex;
  height: 2rem;
  align-items: center;
  justify-content: center;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid hsl(var(--input));
  background: hsl(var(--background));
  padding: 0 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  text-decoration: none;
  flex-shrink: 0;
}

.toast-action:hover {
  background: hsl(var(--accent));
}

.toast-action:focus {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

.toast[data-variant="info"] .toast-action {
  border-color: hsl(var(--info-foreground) / 0.3);
  background: hsl(var(--info));
  color: hsl(var(--info-foreground));
}

.toast[data-variant="info"] .toast-action:hover {
  background: hsl(var(--info-foreground) / 0.1);
}

.toast[data-variant="error"] .toast-action {
  border-color: hsl(var(--destructive-foreground) / 0.3);
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

.toast[data-variant="error"] .toast-action:hover {
  background: hsl(var(--destructive-foreground) / 0.1);
}

.toast[data-variant="success"] .toast-action {
  border-color: hsl(355.7 100% 97.3% / 0.3);
  background: hsl(142.1 76.2% 36.3%);
  color: hsl(355.7 100% 97.3%);
}

.toast[data-variant="success"] .toast-action:hover {
  background: hsl(355.7 100% 97.3% / 0.1);
}

.toast[data-variant="warning"] .toast-action {
  border-color: hsl(222.2 84% 4.9% / 0.3);
  background: hsl(43.3 96.4% 56.3%);
  color: hsl(222.2 84% 4.9%);
}

.toast[data-variant="warning"] .toast-action:hover {
  background: hsl(222.2 84% 4.9% / 0.1);
}

/* BOTON DE CIERRE DE TOAST */
.toast-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: inline-flex;
  height: 1.5rem;
  width: 1.5rem;
  align-items: center;
  justify-content: center;
  border-radius: calc(var(--radius) - 4px);
  border: none;
  background: transparent;
  color: hsl(var(--foreground) / 0.5);
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  opacity: 0.7;
}

.toast-close:hover {
  background: hsl(var(--secondary));
  opacity: 1;
}

.toast-close:focus {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

.toast[data-variant="error"] .toast-close {
  color: hsl(var(--destructive-foreground) / 0.7);
}

.toast[data-variant="error"] .toast-close:hover {
  background: hsl(var(--destructive-foreground) / 0.1);
  color: hsl(var(--destructive-foreground));
}

.toast[data-variant="success"] .toast-close {
  color: hsl(355.7 100% 97.3% / 0.7);
}

.toast[data-variant="success"] .toast-close:hover {
  background: hsl(355.7 100% 97.3% / 0.1);
  color: hsl(355.7 100% 97.3%);
}

.toast[data-variant="warning"] .toast-close {
  color: hsl(222.2 84% 4.9% / 0.7);
}

.toast[data-variant="warning"] .toast-close:hover {
  background: hsl(222.2 84% 4.9% / 0.1);
  color: hsl(222.2 84% 4.9%);
}

/* ICONOS */
.toast-icon {
  display: flex;
  height: 1.25rem;
  width: 1.25rem;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.toast-icon svg {
  height: 1rem;
  width: 1rem;
}

/* VARIANTE DE PROGRESO */
.toast[data-variant="loading"] {
  background: hsl(210 40% 98%);
  border: 1px solid hsl(210 30% 85%);
  color: hsl(215 20% 25%);
  position: relative;
  overflow: hidden;
}

.toast[data-variant="loading"]::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    hsla(210, 100%, 90%, 0.6) 50%,
    transparent 100%
  );
  animation: toast-loading-shimmer 1.8s ease-in-out infinite;
  pointer-events: none;
}

@keyframes toast-loading-shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

.toast[data-variant="loading"] .toast-title {
  color: hsl(215 25% 15%);
  font-weight: 500;
}

.toast[data-variant="loading"] .toast-description {
  color: hsl(215 15% 40%);
}

.toast[data-variant="loading"] .toast-close {
  color: hsl(215 15% 35%);
}

.toast[data-variant="loading"] .toast-close:hover {
  background: hsl(215 20% 20% / 0.08);
  color: hsl(215 20% 20%);
}

.toast-progress-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.toast-progress-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toast-progress-bar-container {
  height: 0.25rem;
  width: 100%;
  overflow: hidden;
  border-radius: 9999px;
  background: hsl(var(--secondary));
}

.toast-progress-bar {
  height: 100%;
  background: hsl(var(--primary));
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 9999px;
}

.toast-progress-text {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  text-align: right;
  font-weight: 500;
}

/* ANIMACIONES DE KEYFRAMES */
@keyframes toast-slide-in-right {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toast-slide-out-right {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* DISEÃ‘O RESPONSIVO */
@media (max-width: 640px) {
  .toast-container,
  .map-toast-container,
  .toast-viewport {
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    max-width: 100%;
    flex-direction: column;
    padding: 1rem;
  }

  .toast {
    transform: translateY(100%);
    margin: 0;
  }

  .toast[data-state="open"] {
    transform: translateY(0);
  }

  .toast[data-state="closed"] {
    transform: translateY(100%);
  }

  .toast-title,
  .toast-description {
    font-size: 0.875rem;
  }

  .toast-action {
    height: 1.75rem;
    padding: 0 0.5rem;
    font-size: 0.8125rem;
  }
}

/* MODO DE ALTO CONTRASTE */
@media (prefers-contrast: high) {
  .toast {
    border-width: 2px;
  }

  .toast-close:focus,
  .toast-action:focus {
    outline-width: 3px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: opacity 0.15s ease;
  }

  .toast-progress-bar {
    transition: width 0.15s ease;
  }
}

/* ============================================================================
   DIALOGO DE ALERTA
   ============================================================================ */

.alert-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: hsl(var(--background) / 0.2);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 1rem;
  animation: alert-dialog-overlay-show 0.15s ease-out;
}

.alert-dialog-content {
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow:
    0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -2px rgba(0, 0, 0, 0.05);
  max-width: 32rem;
  width: 100%;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: alert-dialog-content-show 0.15s ease-out;
  position: relative;
}

.alert-dialog-header {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  text-align: center;
  padding: 1.5rem;
}

.alert-dialog-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  margin: 0 auto;
  border-radius: 50%;
  flex-shrink: 0;
}

.alert-dialog-icon[data-variant="warning"] {
  background: hsl(43.3 96.4% 56.3% / 0.1);
  color: hsl(43.3 96.4% 56.3%);
}

.alert-dialog-icon[data-variant="error"] {
  background: hsl(var(--destructive) / 0.1);
  color: hsl(var(--destructive));
}

.alert-dialog-icon[data-variant="info"] {
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
}

.alert-dialog-icon svg {
  width: 1.5rem;
  height: 1.5rem;
}

.alert-dialog-title {
  margin: 1rem 0 0 0;
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.5;
  color: hsl(var(--foreground));
}

.alert-dialog-body {
  padding: 0 1.5rem;
  color: hsl(var(--muted-foreground));
  line-height: 1.6;
  text-align: center;
  flex: 1;
  overflow-y: auto;
}

.alert-dialog-footer {
  display: flex;
  flex-direction: column-reverse;
  gap: 0.5rem;
  padding: 1.5rem;
}

@media (min-width: 640px) {
  .alert-dialog-footer {
    flex-direction: row;
    justify-content: center;
    gap: 0.75rem;
  }
}

.alert-dialog-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: calc(var(--radius) - 2px);
  font-weight: 500;
  font-size: 0.875rem;
  line-height: 1.25rem;
  padding: 0.625rem 1.5rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  min-width: 6rem;
  white-space: nowrap;
}

.alert-dialog-btn:disabled {
  pointer-events: none;
  opacity: 0.5;
}

.alert-dialog-btn-primary {
  background: hsl(170.91deg 52.38% 12.35%);
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.alert-dialog-btn-primary:hover:not(:disabled) {
  background: hsl(167.37deg 45.6% 24.51%);
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.alert-dialog-btn-primary:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

.alert-dialog-btn-secondary {
  background: transparent;
  color: hsl(var(--foreground));
  border-color: hsl(var(--border));
}

.alert-dialog-btn-secondary:hover:not(:disabled) {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.alert-dialog-btn-secondary:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

/* ANIMACIONES DE DIALOGO DE ALERTA */
@keyframes alert-dialog-overlay-show {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes alert-dialog-content-show {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* DISEÃ‘O RESPONSIVO PARA DIALOGO DE ALERTA */
@media (max-width: 640px) {
  .alert-dialog-overlay {
    padding: 1rem;
  }

  .alert-dialog-content {
    max-width: none;
    max-height: calc(100vh - 2rem);
  }

  .alert-dialog-header {
    padding: 1.5rem 1rem 1rem;
  }

  .alert-dialog-body {
    padding: 0 1rem;
  }

  .alert-dialog-footer {
    padding: 1rem;
    flex-direction: column-reverse;
    gap: 0.75rem;
  }

  .alert-dialog-btn {
    width: 100%;
    justify-content: center;
  }
}

/* MODO DE ALTO CONTRASTE PARA DIALOGO DE ALERTA */
@media (prefers-contrast: high) {
  .alert-dialog-content {
    border-width: 2px;
  }

  .alert-dialog-btn:focus {
    outline-width: 3px;
  }
}

/* REDUCCIÓN DE MOVIMIENTO PARA DIALOGO DE ALERTA */
@media (prefers-reduced-motion: reduce) {
  .alert-dialog-content {
    animation: none;
  }

  .alert-dialog-btn {
    transition: none;
  }
}