/**
 * UI Components Styles
 * Additional styles for framework components
 */

/* ==================== Modal ==================== */
.modal-backdrop {
  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: var(--z-modal);
  opacity: 0;
  transition: opacity 250ms ease-in-out;
  pointer-events: none;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--color-bg-primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.9);
  transition: transform 250ms ease-in-out;
}

.modal.active {
  transform: scale(1);
}

.modal-sm { width: 300px; }
.modal-md { width: 500px; }
.modal-lg { width: 700px; }
.modal-xl { width: 900px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid var(--color-border);
}

.modal-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--color-text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
}

.modal-body {
  padding: var(--spacing-lg);
  overflow-y: auto;
  max-height: calc(90vh - 150px);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) var(--spacing-lg);
  border-top: 1px solid var(--color-border);
}

/* ==================== Toast ==================== */
.toast-container {
  position: fixed;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  pointer-events: none;
}

.toast-top-left { top: var(--spacing-lg); left: var(--spacing-lg); }
.toast-top-right { top: var(--spacing-lg); right: var(--spacing-lg); }
.toast-top-center { top: var(--spacing-lg); left: 50%; transform: translateX(-50%); }
.toast-bottom-left { bottom: var(--spacing-lg); left: var(--spacing-lg); }
.toast-bottom-right { bottom: var(--spacing-lg); right: var(--spacing-lg); }
.toast-bottom-center { bottom: var(--spacing-lg); left: 50%; transform: translateX(-50%); }

.toast {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--color-bg-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 250px;
  max-width: 400px;
  pointer-events: all;
  opacity: 0;
  transform: translateY(-20px);
  transition: all 300ms ease-in-out;
}

.toast.active {
  opacity: 1;
  transform: translateY(0);
}

.toast-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: bold;
}

.toast-message {
  flex: 1;
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
}

.toast-close {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--color-text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: currentColor;
  animation: toast-progress var(--duration, 3000ms) linear forwards;
}

@keyframes toast-progress {
  from { width: 100%; }
  to { width: 0%; }
}

.toast-success {
  border-left: 4px solid var(--color-success);
  color: var(--color-success);
}

.toast-error {
  border-left: 4px solid var(--color-error);
  color: var(--color-error);
}

.toast-warning {
  border-left: 4px solid var(--color-warning);
  color: var(--color-warning);
}

.toast-info {
  border-left: 4px solid var(--color-info);
  color: var(--color-info);
}

/* ==================== Loading ==================== */
.loading {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  z-index: var(--z-modal);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-sm .loading-spinner { width: 20px; height: 20px; border-width: 2px; }
.loading-md .loading-spinner { width: 40px; height: 40px; border-width: 3px; }
.loading-lg .loading-spinner { width: 60px; height: 60px; border-width: 4px; }

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

.loading-message {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

/* ==================== Dropdown ==================== */
.dropdown-menu {
  position: absolute;
  z-index: var(--z-dropdown);
  pointer-events: none;
}

.dropdown-menu.active {
  pointer-events: all;
}

.dropdown-content {
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  max-width: 300px;
  padding: var(--spacing-xs) 0;
  opacity: 0;
  transform: scale(0.95);
  transition: all 150ms ease-in-out;
  pointer-events: none;
}

.dropdown-menu.active .dropdown-content {
  opacity: 1;
  transform: scale(1);
  pointer-events: all;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.dropdown-item:hover:not(.disabled):not(.dropdown-divider):not(.dropdown-header) {
  background: var(--color-bg-secondary);
}

.dropdown-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.dropdown-divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--spacing-xs) 0;
  padding: 0;
}

.dropdown-header {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  padding: var(--spacing-xs) var(--spacing-md);
}

.dropdown-icon {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
}

.dropdown-label {
  flex: 1;
}
