/* ============================================================
   Portal Design System — Components
   ============================================================ */

/* ---------- Avatar ---------- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: var(--weight-semibold);
  overflow: hidden;
  position: relative;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar--xs { width: 24px; height: 24px; font-size: 0.625rem; }
.avatar--sm { width: 32px; height: 32px; font-size: 0.6875rem; }
.avatar--md { width: 40px; height: 40px; font-size: 0.8125rem; }
.avatar--lg { width: 56px; height: 56px; font-size: 1rem; }
.avatar--xl { width: 80px; height: 80px; font-size: 1.25rem; }

.avatar--online::after {
  content: "";
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid var(--surface);
}

.avatar-stack {
  display: flex;
}

.avatar-stack .avatar {
  margin-left: -8px;
  border: 2px solid var(--surface);
}

.avatar-stack .avatar:first-child {
  margin-left: 0;
}

.avatar-stack__more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-left: -8px;
  border-radius: var(--radius-full);
  background: var(--surface-hover);
  border: 2px solid var(--surface);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1;
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease),
              border-color var(--duration-fast) var(--ease),
              color var(--duration-fast) var(--ease),
              box-shadow var(--duration-fast) var(--ease),
              opacity var(--duration-fast) var(--ease);
}

.btn:disabled,
.btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn--primary {
  background: var(--primary);
  color: var(--text-on-primary);
}

.btn--primary:hover {
  background: var(--primary-hover);
  color: var(--text-on-primary);
}

.btn--secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-primary);
}

.btn--secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn--ghost:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.btn--danger {
  background: var(--danger);
  color: #fff;
}

.btn--danger:hover {
  background: #b91c1c;
  color: #fff;
}

.btn--danger-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--danger);
}

.btn--danger-outline:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.btn--sm {
  min-height: 32px;
  padding: 0.375rem 0.75rem;
  font-size: var(--text-xs);
}

.btn--sm svg {
  width: 16px;
  height: 16px;
}

.btn--lg {
  min-height: 44px;
  padding: 0.625rem 1.25rem;
}

.btn--icon {
  width: 40px;
  padding: 0;
}

.btn--icon.btn--sm {
  width: 32px;
}

.btn--block {
  width: 100%;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.card__title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}

.card__body {
  padding: 1.25rem;
}

.card__footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--duration-fast) var(--ease),
              box-shadow var(--duration-fast) var(--ease);
}

.kpi-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.kpi-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-card__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  color: var(--primary);
}

.kpi-card__icon svg {
  width: 20px;
  height: 20px;
}

.kpi-card__icon--success { background: var(--success-soft); color: var(--success); }
.kpi-card__icon--warning { background: var(--warning-soft); color: var(--warning); }
.kpi-card__icon--danger { background: var(--danger-soft); color: var(--danger); }
.kpi-card__icon--info { background: var(--info-soft); color: var(--info); }

.kpi-card__label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: var(--weight-medium);
}

.kpi-card__value {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  line-height: 1;
}

.kpi-card__trend {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.kpi-card__trend--up { color: var(--success); }
.kpi-card__trend--down { color: var(--danger); }

/* ---------- Forms ---------- */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
}

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  min-height: 42px;
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-primary);
  font-size: var(--text-sm);
  transition: border-color var(--duration-fast) var(--ease),
              box-shadow var(--duration-fast) var(--ease);
}

.form-textarea {
  min-height: 120px;
  padding: 0.75rem 0.875rem;
  resize: vertical;
  line-height: var(--leading-relaxed);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-tertiary);
}

.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(--border-focus);
  box-shadow: var(--shadow-focus);
}

.form-input.is-invalid,
.form-select.is-invalid,
.form-textarea.is-invalid {
  border-color: var(--danger);
}

.form-input.is-invalid:focus,
.form-select.is-invalid:focus,
.form-textarea.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
}

.form-hint {
  margin-top: 0.375rem;
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.form-error {
  margin-top: 0.375rem;
  font-size: var(--text-xs);
  color: var(--danger);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 640px) {
  .form-row--2 {
    grid-template-columns: 1fr 1fr;
  }
}

.input-group {
  position: relative;
}

.input-group__icon {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.input-group .form-input {
  padding-left: 2.5rem;
}

.checkbox,
.radio {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text-primary);
  min-height: 44px;
}

.checkbox input,
.radio input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.1875rem 0.625rem;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1.4;
  white-space: nowrap;
}

.badge__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge--neutral {
  background: var(--surface-hover);
  color: var(--text-secondary);
}

.badge--success {
  background: var(--success-soft);
  color: var(--success);
}

.badge--warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge--danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge--info {
  background: var(--info-soft);
  color: var(--info);
}

.badge--primary {
  background: var(--primary-soft);
  color: var(--primary);
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: var(--weight-semibold);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  background: var(--background);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr {
  transition: background var(--duration-fast) var(--ease);
}

.table tbody tr:hover {
  background: var(--surface-hover);
}

.table__user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.table__user-name {
  font-weight: var(--weight-medium);
}

.table__user-meta {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.table-toolbar__filters {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.table-toolbar__search {
  position: relative;
  min-width: 220px;
}

.table-toolbar__search svg {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.table-toolbar__search .form-input {
  min-height: 38px;
  padding-left: 2.25rem;
}

/* Mobile table cards */
.table-cards {
  display: none;
}

@media (max-width: 767px) {
  .table-wrap--responsive .table {
    display: none;
  }

  .table-cards {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .table-card {
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
  }

  .table-card__row {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.375rem 0;
    font-size: var(--text-sm);
  }

  .table-card__label {
    color: var(--text-secondary);
  }
}

/* ---------- Dropdown ---------- */
.dropdown {
  position: relative;
}

.dropdown__menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: var(--z-dropdown);
  min-width: 200px;
  padding: 0.375rem;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity var(--duration-fast) var(--ease),
              transform var(--duration-fast) var(--ease),
              visibility var(--duration-fast) var(--ease);
}

.dropdown.is-open .dropdown__menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown__menu--left {
  right: auto;
  left: 0;
}

.dropdown__menu--wide {
  min-width: 360px;
  max-width: calc(100vw - 2rem);
}

.dropdown__header {
  padding: 0.75rem 0.875rem 0.5rem;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.dropdown__item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-primary);
  text-decoration: none;
  transition: background var(--duration-fast) var(--ease);
  min-height: 40px;
}

.dropdown__item:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.dropdown__item--danger {
  color: var(--danger);
}

.dropdown__item--danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.dropdown__item svg {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.dropdown__item--danger svg {
  color: var(--danger);
}

.dropdown__divider {
  height: 1px;
  margin: 0.375rem 0.5rem;
  background: var(--border);
}

.dropdown__footer {
  padding: 0.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.dropdown__footer a {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-normal) var(--ease),
              visibility var(--duration-normal) var(--ease);
}

.modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  transform: scale(0.96) translateY(8px);
  transition: transform var(--duration-normal) var(--ease);
  overflow: hidden;
}

.modal-overlay.is-open .modal {
  transform: scale(1) translateY(0);
}

.modal--md { max-width: 560px; }
.modal--lg { max-width: 720px; }
.modal--sm { max-width: 400px; }

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

.modal__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
}

.modal__close:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.modal__close svg {
  width: 20px;
  height: 20px;
}

.modal__body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: min(380px, calc(100vw - 2rem));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  animation: toast-in var(--duration-normal) var(--ease);
}

.toast.is-leaving {
  animation: toast-out var(--duration-normal) var(--ease) forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(16px); }
}

.toast__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.toast__icon svg {
  width: 14px;
  height: 14px;
}

.toast--success .toast__icon {
  background: var(--success-soft);
  color: var(--success);
}

.toast--error .toast__icon {
  background: var(--danger-soft);
  color: var(--danger);
}

.toast--warning .toast__icon {
  background: var(--warning-soft);
  color: var(--warning);
}

.toast--info .toast__icon {
  background: var(--info-soft);
  color: var(--info);
}

.toast__content {
  flex: 1;
  min-width: 0;
}

.toast__message {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
}

.toast__close {
  color: var(--text-tertiary);
  padding: 2px;
}

.toast__close:hover {
  color: var(--text-primary);
}

.toast__close svg {
  width: 16px;
  height: 16px;
}

/* ---------- Empty state ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.5rem;
}

.empty-state__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin-bottom: 1.25rem;
  border-radius: var(--radius-xl);
  background: var(--surface-hover);
  color: var(--text-tertiary);
}

.empty-state__icon svg {
  width: 28px;
  height: 28px;
}

.empty-state__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: 0.375rem;
}

.empty-state__text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  max-width: 320px;
  margin-bottom: 1.5rem;
}

/* ---------- Skeleton ---------- */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-hover) 25%,
    var(--surface-active) 50%,
    var(--surface-hover) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton--text {
  height: 14px;
  margin-bottom: 0.5rem;
}

.skeleton--title {
  height: 24px;
  width: 40%;
  margin-bottom: 0.75rem;
}

.skeleton--avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
}

.skeleton--card {
  height: 120px;
  border-radius: var(--radius-lg);
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
  overflow-x: auto;
}

.tabs__btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  min-height: 44px;
  transition: color var(--duration-fast) var(--ease),
              border-color var(--duration-fast) var(--ease);
}

.tabs__btn:hover {
  color: var(--text-primary);
}

.tabs__btn.is-active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ---------- Activity timeline ---------- */
.activity-list {
  display: flex;
  flex-direction: column;
}

.activity-item {
  display: flex;
  gap: 0.875rem;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--border);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-item__dot {
  width: 10px;
  height: 10px;
  margin-top: 0.375rem;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.activity-item__content {
  flex: 1;
  min-width: 0;
}

.activity-item__text {
  font-size: var(--text-sm);
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.activity-item__text strong {
  font-weight: var(--weight-semibold);
}

.activity-item__meta {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

/* ---------- Quick actions ---------- */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}

.quick-action {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text-primary);
  transition: border-color var(--duration-fast) var(--ease),
              background var(--duration-fast) var(--ease),
              box-shadow var(--duration-fast) var(--ease);
  min-height: 88px;
}

.quick-action:hover {
  border-color: var(--primary-muted);
  background: var(--primary-soft);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.quick-action__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  color: var(--primary);
}

.quick-action__icon svg {
  width: 18px;
  height: 18px;
}

.quick-action__label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 0;
}

.pagination__info {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.pagination__controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.pagination__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 0.5rem;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  border: 1px solid transparent;
}

.pagination__btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.pagination__btn.is-active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: var(--weight-semibold);
}

.pagination__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- Alert ---------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  border: 1px solid transparent;
}

.alert--success {
  background: var(--success-soft);
  border-color: rgba(22, 163, 74, 0.2);
  color: var(--success);
}

.alert--error {
  background: var(--danger-soft);
  border-color: rgba(220, 38, 38, 0.2);
  color: var(--danger);
}

.alert--warning {
  background: var(--warning-soft);
  border-color: rgba(217, 119, 6, 0.2);
  color: var(--warning);
}

.alert--info {
  background: var(--info-soft);
  border-color: rgba(2, 132, 199, 0.2);
  color: var(--info);
}

.alert svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ---------- File type icon ---------- */
.file-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  font-size: 0.625rem;
  font-weight: var(--weight-bold);
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.file-icon--pdf { background: #fef2f2; color: #dc2626; }
.file-icon--xls { background: #f0fdf4; color: #16a34a; }
.file-icon--doc { background: #eff6ff; color: #2563eb; }
.file-icon--img { background: #faf5ff; color: #9333ea; }
.file-icon--zip { background: #fff7ed; color: #ea580c; }
.file-icon--default { background: var(--surface-hover); color: var(--text-secondary); }

[data-theme="dark"] .file-icon--pdf { background: rgba(220,38,38,0.15); }
[data-theme="dark"] .file-icon--xls { background: rgba(22,163,74,0.15); }
[data-theme="dark"] .file-icon--doc { background: rgba(37,99,235,0.15); }
[data-theme="dark"] .file-icon--img { background: rgba(147,51,234,0.15); }
[data-theme="dark"] .file-icon--zip { background: rgba(234,88,12,0.15); }

/* ---------- Upload dropzone ---------- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--background);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease),
              background var(--duration-fast) var(--ease);
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.dropzone__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--border);
}

.dropzone__icon svg {
  width: 22px;
  height: 22px;
}

.dropzone__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.dropzone__hint {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.upload-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
}

.upload-item__info {
  flex: 1;
  min-width: 0;
}

.upload-item__name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  margin-bottom: 0.375rem;
}

.upload-item__bar {
  height: 6px;
  background: var(--surface-hover);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.upload-item__progress {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-full);
  transition: width var(--duration-normal) var(--ease);
}

.upload-item__status {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  white-space: nowrap;
}

.upload-item__status--done {
  color: var(--success);
}

/* ---------- Content grid helpers ---------- */
.content-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 1024px) {
  .content-grid--2 {
    grid-template-columns: 1fr 1fr;
  }

  .content-grid--sidebar {
    grid-template-columns: 1fr 340px;
  }
}

.section-title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  margin-bottom: 1rem;
}

/* ---------- Spinner ---------- */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner--lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}
