/**
 * Professional UI Components
 * Notification System, Forms, Modals, and More
 */

/* ========================================
   Notification System
   ======================================== */

.notification-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 420px;
  pointer-events: none;
}

.notification {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: var(--surface-strong);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
  min-width: 320px;
}

.notification--visible {
  opacity: 1;
  transform: translateX(0);
}

.notification__icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: 14px;
}

.notification--success {
  border-left: 3px solid var(--success);
}

.notification--success .notification__icon {
  background: rgba(63, 185, 80, 0.15);
  color: var(--success);
}

.notification--error {
  border-left: 3px solid var(--error);
}

.notification--error .notification__icon {
  background: rgba(248, 81, 73, 0.15);
  color: var(--error);
}

.notification--warning {
  border-left: 3px solid var(--warning);
}

.notification--warning .notification__icon {
  background: rgba(210, 153, 34, 0.15);
  color: var(--warning);
}

.notification--info {
  border-left: 3px solid var(--info);
}

.notification--info .notification__icon {
  background: rgba(88, 166, 255, 0.15);
  color: var(--info);
}

.notification__content {
  flex: 1;
}

.notification__message {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  margin: 0;
}

.notification__close {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  border-radius: 4px;
  transition: var(--transition-fast);
}

.notification__close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

@media (max-width: 768px) {
  .notification-container {
    top: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
  }

  .notification {
    min-width: auto;
  }
}

/* ========================================
   Form Components
   ======================================== */

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.form-label--required::after {
  content: '*';
  color: var(--error);
  margin-left: 4px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
  font-family: inherit;
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
  border-color: var(--border-strong);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 129, 247, 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-tertiary);
}

.form-textarea {
  min-height: 120px;
  resize: vertical;
}

.input-error {
  border-color: var(--error) !important;
}

.input-error:focus {
  box-shadow: 0 0 0 3px rgba(248, 81, 73, 0.1) !important;
}

.form-error {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 13px;
  color: var(--error);
}

.form-error::before {
  content: '⚠';
  font-size: 14px;
}

.form-help {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.form-checkbox,
.form-radio {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  margin-bottom: 12px;
}

.form-checkbox input,
.form-radio input {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
}

.form-checkbox label,
.form-radio label {
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
}

/* ========================================
   Search Component
   ======================================== */

.search-box {
  position: relative;
  width: 100%;
  max-width: 600px;
}

.search-input {
  width: 100%;
  padding: 12px 16px 12px 44px;
  font-size: 15px;
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 129, 247, 0.1);
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 18px;
  pointer-events: none;
}

.search-clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  display: none;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  border-radius: 4px;
  transition: var(--transition-fast);
}

.search-clear:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.search-input:not(:placeholder-shown) ~ .search-clear {
  display: flex;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: 400px;
  overflow-y: auto;
  background: var(--surface-strong);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 100;
}

.search-result-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition-fast);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: var(--surface-hover);
}

.search-result-item mark {
  background: rgba(47, 129, 247, 0.2);
  color: var(--accent);
  padding: 2px 4px;
  border-radius: 3px;
}

.search-no-results {
  padding: 32px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

/* ========================================
   Loading States
   ======================================== */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 23, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  backdrop-filter: blur(4px);
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spinner-rotate 0.8s linear infinite;
}

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

.loading-text {
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-secondary);
}

/* Inline loading spinner */
.spinner-inline {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spinner-rotate 0.6s linear infinite;
  vertical-align: middle;
}

/* ========================================
   Modal Component
   ======================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 23, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9997;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  backdrop-filter: blur(4px);
}

.modal-backdrop.is-active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface-strong);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow: hidden;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

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

.modal__header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal__title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.modal__close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
  transition: var(--transition-fast);
}

.modal__close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.modal__body {
  padding: 24px;
  overflow-y: auto;
  max-height: calc(90vh - 140px);
}

.modal__footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ========================================
   Buttons
   ======================================== */

.btn-secondary {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.btn-secondary:active {
  transform: scale(0.98);
}

.btn-outline {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-outline:hover {
  background: rgba(47, 129, 247, 0.1);
}

.btn-outline:active {
  transform: scale(0.98);
}

/* ========================================
   Tooltips
   ======================================== */

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

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  background: var(--surface-strong);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-fast);
  pointer-events: none;
  z-index: 1000;
}

[data-tooltip]:hover::before {
  opacity: 1;
  visibility: visible;
}

/* ========================================
   Progress Bar
   ======================================== */

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--surface);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* ========================================
   Tabs
   ======================================== */

.tabs {
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 0;
  margin-bottom: 24px;
}

.tab {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition-fast);
}

.tab:hover {
  color: var(--text-primary);
}

.tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content {
  display: none;
}

.tab-content.is-active {
  display: block;
}
