/* ===================================
   TOAST NOTIFICATIONS
=================================== */

.toast-container {
  position: fixed;
  top: 80px; /* Sotto la navbar */
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
  max-width: 400px;
}

.toast {
  display: flex;
  align-items: start;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  pointer-events: all;
  transform: translateX(400px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 320px;
  max-width: 100%;
}

.toast-show {
  transform: translateX(0);
  opacity: 1;
}

.toast-hide {
  transform: translateX(400px);
  opacity: 0;
}

/* Icona toast */
.toast-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-icon svg {
  width: 100%;
  height: 100%;
}

/* Contenuto */
.toast-content {
  flex: 1;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

/* Azioni */
.toast-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.toast-action-btn {
  background: transparent;
  border: none;
  color: var(--azul);
  font-size: 13px;
  font-weight: 600;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s ease;
}

.toast-action-btn:hover {
  background: rgba(25, 118, 210, 0.08);
}

.toast-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  line-height: 1;
  padding: 0;
  width: 24px;
  height: 24px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.toast-close:hover {
  background: rgba(0,0,0,0.05);
  color: var(--text-primary);
}

[data-theme="dark"] .toast-close:hover {
  background: rgba(255,255,255,0.1);
}

/* Tipi di toast */
.toast-info {
  border-left: 4px solid #2196f3;
}

.toast-info .toast-icon {
  color: #2196f3;
}

.toast-success {
  border-left: 4px solid #4caf50;
}

.toast-success .toast-icon {
  color: #4caf50;
}

.toast-warning {
  border-left: 4px solid #ff9800;
}

.toast-warning .toast-icon {
  color: #ff9800;
}

.toast-error {
  border-left: 4px solid #f44336;
}

.toast-error .toast-icon {
  color: #f44336;
}

/* Dark mode adjustments */
[data-theme="dark"] .toast {
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}

/* Responsive */
@media (max-width: 768px) {
  .toast-container {
    right: 12px;
    left: 12px;
    top: 70px;
    max-width: none;
  }

  .toast {
    min-width: auto;
    width: 100%;
  }
}

/* Animazioni aggiuntive */
@keyframes toast-progress {
  from { width: 100%; }
  to { width: 0%; }
}

.toast-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: currentColor;
  opacity: 0.3;
  animation: toast-progress linear forwards;
}

/* ===================================
   COMPONENTI UI AGGIUNTIVI
=================================== */

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-primary {
  background: #e3f2fd;
  color: #1976d2;
  border: 1px solid #bbdefb;
}

.badge-success {
  background: #e8f5e9;
  color: #388e3c;
  border: 1px solid #c8e6c9;
}

.badge-warning {
  background: #fff3e0;
  color: #f57c00;
  border: 1px solid #ffe0b2;
}

.badge-danger {
  background: #ffebee;
  color: #d32f2f;
  border: 1px solid #ffcdd2;
}

[data-theme="dark"] .badge-primary {
  background: #1e3a5f;
  color: #90cdf4;
  border-color: #2c5282;
}

[data-theme="dark"] .badge-success {
  background: #1e4620;
  color: #9ae6b4;
  border-color: #276749;
}

[data-theme="dark"] .badge-warning {
  background: #5a3e1a;
  color: #fbd38d;
  border-color: #744210;
}

[data-theme="dark"] .badge-danger {
  background: #5a1a1a;
  color: #fc8181;
  border-color: #742a2a;
}

/* Skeleton Loaders */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--border-soft) 0%,
    var(--border) 50%,
    var(--border-soft) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: 4px;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skeleton-item {
  height: 40px;
  width: 100%;
}

.skeleton-text {
  height: 16px;
  width: 100%;
  margin: 8px 0;
}

.skeleton-text.short {
  width: 60%;
}

.skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

/* Spinner / Loading */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(25, 118, 210, 0.2);
  border-top-color: var(--azul);
  border-radius: 50%;
  animation: spinner-rotate 0.8s linear infinite;
}

@keyframes spinner-rotate {
  to { transform: rotate(360deg); }
}

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 4px;
}

.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  backdrop-filter: blur(2px);
}

.loading-overlay .spinner {
  width: 60px;
  height: 60px;
  border-width: 6px;
  border-top-color: #fff;
  border-right-color: rgba(255,255,255,0.3);
  border-bottom-color: rgba(255,255,255,0.3);
  border-left-color: rgba(255,255,255,0.3);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.empty-state-description {
  font-size: 14px;
  margin-bottom: 24px;
}

/* Tooltip */
[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: #1f2d3d;
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1000;
}

[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

[data-theme="dark"] [data-tooltip]::after {
  background: #f1f5f9;
  color: #1f2d3d;
}
