/**
 * GeoFazendas Toast Notification Component
 * 
 * Global toast/notification system with mobile-first design:
 * - Mobile (≤768px): Bottom popup with slide-up animation
 * - Desktop (>768px): Bottom-right stacked notifications
 * 
 * Usage: Include this CSS globally via base.html
 * See static/js/toast.js for JavaScript controller
 * 
 * @version 1.0.0
 */

/* ==========================================================================
   CSS Custom Properties (Design Tokens)
   ========================================================================== */

:root {
  /* Toast sizing */
  --gf-toast-max-width: 400px;
  --gf-toast-min-width: 280px;
  --gf-toast-mobile-margin: 1rem;
  --gf-toast-desktop-margin: 1.5rem;
  --gf-toast-gap: 0.75rem;
  
  /* Animation timing */
  --gf-toast-duration: 0.3s;
  --gf-toast-easing: cubic-bezier(0.32, 0.72, 0, 1);
  
  /* Z-index layer (below modals) */
  --gf-toast-z-index: 1050;
  
  /* Border radius */
  --gf-toast-border-radius: 0.75rem;
  --gf-toast-mobile-border-radius: 1rem 1rem 0 0;
  
  /* Shadows */
  --gf-toast-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.2),
                     0 4px 12px rgba(0, 0, 0, 0.1);
  --gf-toast-mobile-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  
  /* Variant colors */
  --gf-toast-info-bg: #eff6ff;
  --gf-toast-info-border: #bfdbfe;
  --gf-toast-info-icon: #2563eb;
  --gf-toast-info-text: #1e40af;
  
  --gf-toast-success-bg: #f0fdf4;
  --gf-toast-success-border: #bbf7d0;
  --gf-toast-success-icon: #16a34a;
  --gf-toast-success-text: #166534;
  
  --gf-toast-warning-bg: #fffbeb;
  --gf-toast-warning-border: #fde68a;
  --gf-toast-warning-icon: #d97706;
  --gf-toast-warning-text: #92400e;
  
  --gf-toast-error-bg: #fef2f2;
  --gf-toast-error-border: #fecaca;
  --gf-toast-error-icon: #dc2626;
  --gf-toast-error-text: #991b1b;
}

/* ==========================================================================
   Toast Container - Manages positioning and stacking
   ========================================================================== */

.gf-toast-container {
  position: fixed;
  z-index: var(--gf-toast-z-index);
  display: flex;
  flex-direction: column-reverse; /* Newest toast at bottom, stack upward */
  gap: var(--gf-toast-gap);
  pointer-events: none;
}

/* Mobile: Bottom center, full width */
.gf-toast-container {
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0;
  align-items: stretch;
}

/* Desktop: Bottom right, stacked */
@media (min-width: 768px) {
  .gf-toast-container {
    bottom: var(--gf-toast-desktop-margin);
    right: var(--gf-toast-desktop-margin);
    left: auto;
    max-width: var(--gf-toast-max-width);
    align-items: flex-end;
  }
}

/* ==========================================================================
   Toast Item - Individual notification
   ========================================================================== */

.gf-toast {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--gf-toast-info-bg);
  border: 1px solid var(--gf-toast-info-border);
  border-radius: var(--gf-toast-mobile-border-radius);
  box-shadow: var(--gf-toast-mobile-shadow);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--gf-toast-info-text);
  pointer-events: auto;
  
  /* Animation initial state */
  opacity: 0;
  transform: translateY(100%);
  transition: opacity var(--gf-toast-duration) var(--gf-toast-easing),
              transform var(--gf-toast-duration) var(--gf-toast-easing);
}

/* Visible state */
.gf-toast.gf-toast--visible {
  opacity: 1;
  transform: translateY(0);
}

/* Exiting state */
.gf-toast.gf-toast--exiting {
  opacity: 0;
  transform: translateY(100%);
}

/* Desktop adjustments */
@media (min-width: 768px) {
  .gf-toast {
    min-width: var(--gf-toast-min-width);
    max-width: var(--gf-toast-max-width);
    border-radius: var(--gf-toast-border-radius);
    box-shadow: var(--gf-toast-shadow);
    
    /* Desktop: slide from right */
    transform: translateX(calc(100% + var(--gf-toast-desktop-margin)));
  }
  
  .gf-toast.gf-toast--visible {
    transform: translateX(0);
  }
  
  .gf-toast.gf-toast--exiting {
    transform: translateX(calc(100% + var(--gf-toast-desktop-margin)));
  }
}

/* ==========================================================================
   Toast Icon
   ========================================================================== */

.gf-toast__icon {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gf-toast-info-icon);
}

.gf-toast__icon .material-icons,
.gf-toast__icon .material-icons-outlined {
  font-size: 1.375rem;
}

/* ==========================================================================
   Toast Content
   ========================================================================== */

.gf-toast__content {
  flex: 1;
  min-width: 0;
}

.gf-toast__title {
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 0.25rem;
  color: inherit;
}

.gf-toast__message {
  font-weight: 400;
  color: inherit;
  opacity: 0.9;
}

/* When only message (no title) */
.gf-toast__content:not(:has(.gf-toast__title)) .gf-toast__message {
  font-weight: 500;
}

/* ==========================================================================
   Toast Close Button
   ========================================================================== */

.gf-toast__close {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: -0.25rem -0.375rem -0.25rem 0;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0.375rem;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}

.gf-toast__close:hover {
  opacity: 1;
  background-color: rgba(0, 0, 0, 0.05);
}

.gf-toast__close:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
  opacity: 1;
}

.gf-toast__close .material-icons,
.gf-toast__close .material-icons-outlined {
  font-size: 1.125rem;
}

/* ==========================================================================
   Toast Progress Bar (auto-dismiss indicator)
   ========================================================================== */

.gf-toast__progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: currentColor;
  opacity: 0.3;
  transform-origin: left;
  border-radius: 0 0 var(--gf-toast-border-radius) var(--gf-toast-border-radius);
}

.gf-toast__progress.gf-toast__progress--animated {
  animation: gf-toast-progress linear forwards;
}

@keyframes gf-toast-progress {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

/* Mobile: adjust progress bar radius */
@media (max-width: 767.98px) {
  .gf-toast__progress {
    border-radius: 0;
  }
}

/* ==========================================================================
   Variant: Success
   ========================================================================== */

.gf-toast--success {
  background: var(--gf-toast-success-bg);
  border-color: var(--gf-toast-success-border);
  color: var(--gf-toast-success-text);
}

.gf-toast--success .gf-toast__icon {
  color: var(--gf-toast-success-icon);
}

/* ==========================================================================
   Variant: Warning
   ========================================================================== */

.gf-toast--warning {
  background: var(--gf-toast-warning-bg);
  border-color: var(--gf-toast-warning-border);
  color: var(--gf-toast-warning-text);
}

.gf-toast--warning .gf-toast__icon {
  color: var(--gf-toast-warning-icon);
}

/* ==========================================================================
   Variant: Error
   ========================================================================== */

.gf-toast--error {
  background: var(--gf-toast-error-bg);
  border-color: var(--gf-toast-error-border);
  color: var(--gf-toast-error-text);
}

.gf-toast--error .gf-toast__icon {
  color: var(--gf-toast-error-icon);
}

/* ==========================================================================
   Variant: Info (default)
   ========================================================================== */

.gf-toast--info {
  background: var(--gf-toast-info-bg);
  border-color: var(--gf-toast-info-border);
  color: var(--gf-toast-info-text);
}

.gf-toast--info .gf-toast__icon {
  color: var(--gf-toast-info-icon);
}

/* ==========================================================================
   Reduced Motion Support
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .gf-toast {
    transition: opacity var(--gf-toast-duration) ease;
    transform: none !important;
  }
  
  .gf-toast.gf-toast--visible {
    transform: none !important;
  }
  
  .gf-toast.gf-toast--exiting {
    transform: none !important;
  }
  
  .gf-toast__progress.gf-toast__progress--animated {
    animation: none;
    transform: scaleX(0);
  }
}

/* ==========================================================================
   Safe Area Support (iOS notch/home indicator)
   ========================================================================== */

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .gf-toast-container {
    padding-bottom: env(safe-area-inset-bottom);
  }
}
