/* Reusable drag & drop zone component */
.dropzone[hidden] {
  display: none;
}

.dropzone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-large);
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: var(--card-bg);
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.dropzone::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    color-mix(in srgb, var(--link) 10%, transparent),
    transparent
  );
  transition: left 0.5s ease;
}

.dropzone:hover {
  border-color: var(--link);
  background: color-mix(in srgb, var(--link) 2%, transparent);
}

.dropzone:hover::before {
  left: 100%;
}

.dropzone.drag-over {
  border-style: solid;
  border-color: var(--link);
  background: color-mix(in srgb, var(--link) 8%, transparent);
  transform: scale(1.02);
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--link) 25%, transparent),
    0 10px 30px color-mix(in srgb, var(--link) 25%, transparent);
}

.dropzone.drag-over::before {
  left: 100%;
  animation: dropzone-shimmer 1.5s infinite;
}

/* Center glow shown while a file is dragged over the zone. Sits above the
   background but behind the icon/text (z-index: -1). */
.dropzone::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    circle at center,
    color-mix(in srgb, var(--link) 30%, transparent),
    transparent 70%
  );
  transition: opacity 0.25s ease;
}

.dropzone.drag-over::after {
  opacity: 1;
}

@keyframes dropzone-shimmer {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

.dropzone-icon {
  font-size: 56px;
  color: var(--link);
  margin-bottom: 8px;
  margin-right: 0 !important;
  animation: dropzone-upload-float 1.8s ease-in-out infinite;
  transform-origin: center top;
}

@keyframes dropzone-upload-float {
  0%,
  100% {
    transform: translateY(-5px);
  }
  50% {
    transform: translateY(1px);
  }
}

.dropzone.drag-over .dropzone-icon {
  animation-duration: 0.9s;
}

.dropzone-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--heading-color);
  margin-bottom: 5px;
}

.dropzone-hint {
  color: var(--muted-text);
  font-size: 0.9em;
}

.dropzone-type-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 0 !important;
  order: 3;
}

.dropzone-type-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 999px;
  background: color-mix(in srgb, var(--link) 8%, transparent);
  color: var(--heading-color);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  padding: 6px 9px;
}

.dropzone-type-chip i {
  font-size: 12px;
  line-height: 1;
  margin-right: 0 !important;
  color: currentColor !important;
}

.dropzone-type-chip svg {
  color: currentColor !important;
  fill: currentColor;
}

.dropzone-type-chip span {
  line-height: 1;
  color: currentColor;
}

.dropzone-type-chip--pdf {
  background: #fee2e2;
  border-color: #fecaca;
  color: #b91c1c;
}

.dropzone-type-chip--doc {
  background: color-mix(
    in srgb,
    var(--primary-blue) 14%,
    var(--container-bg, transparent)
  );
  border-color: color-mix(in srgb, var(--primary-blue) 28%, transparent);
  color: var(--primary-blue);
}

.dropzone-type-chip--ppt {
  background: #ffedd5;
  border-color: #fed7aa;
  color: #c2410c;
}

.dropzone-type-chip--img {
  background: #dcfce7;
  border-color: #bbf7d0;
  color: #166534;
}

.dropzone-type-chip--txt {
  background: #fef3c7;
  border-color: #fde68a;
  color: #92400e;
}

.dropzone-type-chip--xls {
  background: #d1fae5;
  border-color: #a7f3d0;
  color: #065f46;
}

body.theme-dark .dropzone-type-chip--pdf {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(248, 113, 113, 0.45);
  color: #fecaca;
}

body.theme-dark .dropzone-type-chip--doc {
  background: color-mix(in srgb, var(--primary-blue) 20%, transparent);
  border-color: color-mix(in srgb, var(--primary-blue) 45%, transparent);
  color: color-mix(in srgb, var(--primary-blue) 35%, #ffffff);
}

body.theme-dark .dropzone-type-chip--ppt {
  background: rgba(249, 115, 22, 0.2);
  border-color: rgba(251, 146, 60, 0.45);
  color: #fed7aa;
}

body.theme-dark .dropzone-type-chip--img {
  background: rgba(34, 197, 94, 0.2);
  border-color: rgba(74, 222, 128, 0.45);
  color: #dcfce7;
}

body.theme-dark .dropzone-type-chip--txt {
  background: rgba(245, 158, 11, 0.2);
  border-color: rgba(251, 191, 36, 0.45);
  color: #fef3c7;
}

body.theme-dark .dropzone-type-chip--xls {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(52, 211, 153, 0.45);
  color: #d1fae5;
}

.dropzone-limits {
  color: var(--muted-text);
  font-size: 11px;
  margin-top: 6px;
  order: 3;
}

.dropzone-browse-btn {
  border: 1px solid color-mix(in srgb, var(--link) 35%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--link) 12%, transparent);
  color: var(--heading-color);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 10px 13px;
  margin-top: 28px;
  margin-right: 0;
  margin-bottom: 0 !important;
  order: 4;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    transform 0.18s ease;
}

.dropzone-browse-btn:hover {
  background: color-mix(in srgb, var(--link) 20%, transparent);
  border-color: color-mix(in srgb, var(--link) 55%, transparent);
  transform: translateY(-1px);
}

.dropzone-browse-btn:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--link) 45%, transparent);
  outline-offset: 1px;
}

.dropzone-file-input {
  display: none;
  order: 5;
}

/* Uploading state */
.dropzone.dropzone-uploading {
  pointer-events: none;
  opacity: 0.7;
  border-color: var(--link);
}

.dropzone.dropzone-uploading .dropzone-icon {
  animation: none;
}

.dropzone-upload-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: color-mix(in srgb, var(--link) 12%, transparent);
  overflow: hidden;
}

.dropzone-upload-progress-bar {
  height: 100%;
  background: var(--link);
  border-radius: 0 2px 2px 0;
  animation: dropzone-progress-indeterminate 1.6s ease-in-out infinite;
  width: 40%;
}

@keyframes dropzone-progress-indeterminate {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(350%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dropzone-icon {
    animation: none;
  }

  .dropzone-upload-progress-bar {
    animation: none;
    width: 100%;
    opacity: 0.5;
  }
}

@media (max-width: 768px) {
  .dropzone {
    padding: 20px 10px;
  }

  .dropzone-icon {
    font-size: 48px;
  }
}

/* "Already uploaded" state: replaces the dropzone with a compact file chip
   showing the stored file's name and a button to remove it. */
.dropzone-stored {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-large);
  background: var(--card-bg);
}

.dropzone-stored[hidden] {
  display: none;
}

.dropzone-stored-icon {
  flex: 0 0 auto;
  color: var(--link);
  font-size: 18px;
  margin-right: 0 !important;
}

.dropzone-stored-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--heading-color);
}

.dropzone-stored-remove {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted-text);
  cursor: pointer;
  transition:
    background 0.18s ease,
    color 0.18s ease;
}

.dropzone-stored-remove:hover {
  background: rgba(220, 53, 69, 0.12);
  color: #dc3545;
}

.dropzone-stored-remove:focus-visible {
  outline: 2px solid rgba(220, 53, 69, 0.45);
  outline-offset: 1px;
}

.dropzone-stored-remove i {
  margin-right: 0 !important;
}

.dropzone-stored-download {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted-text);
  cursor: pointer;
  transition:
    background 0.18s ease,
    color 0.18s ease;
}

.dropzone-stored-download:hover {
  background: color-mix(in srgb, var(--primary-blue) 12%, transparent);
  color: var(--link);
}

.dropzone-stored-download:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--primary-blue) 45%, transparent);
  outline-offset: 1px;
}

.dropzone-stored-download i {
  margin-right: 0 !important;
}

/* Auto-upload lanes: one row per file with progress, speed and time left. */
.dropzone-lanes {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.dropzone-lanes:empty {
  display: none;
}

.dropzone-lane {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-medium, 8px);
  background: var(--card-bg);
  transition:
    opacity 0.4s ease,
    transform 0.4s ease;
}

/* Auto-hide a completed upload: fade + slide out before the row is removed. */
.dropzone-lane--dismissing {
  opacity: 0;
  transform: translateX(12px);
  pointer-events: none;
}

.dropzone-lane-icon {
  flex: 0 0 auto;
  width: 20px;
  text-align: center;
  color: var(--link);
  font-size: 16px;
}

.dropzone-lane-icon i {
  margin-right: 0 !important;
}

.dropzone-lane-body {
  flex: 1 1 auto;
  min-width: 0;
}

.dropzone-lane-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  color: var(--heading-color);
}

.dropzone-lane-bar {
  position: relative;
  height: 5px;
  margin: 6px 0 5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--link) 14%, transparent);
  overflow: hidden;
}

.dropzone-lane-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--link);
  transition: width 0.2s ease-out;
}

.dropzone-lane-meta {
  font-size: 11px;
  color: var(--muted-text);
}

.dropzone-lane-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.dropzone-lane-retry,
.dropzone-lane-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted-text);
  cursor: pointer;
  transition:
    background 0.18s ease,
    color 0.18s ease;
}

.dropzone-lane-retry i,
.dropzone-lane-remove i {
  margin-right: 0 !important;
}

.dropzone-lane-retry:hover {
  background: color-mix(in srgb, var(--link) 12%, transparent);
  color: var(--link);
}

.dropzone-lane-remove:hover {
  background: rgba(220, 53, 69, 0.12);
  color: #dc3545;
}

.dropzone-lane-retry:focus-visible,
.dropzone-lane-remove:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--link) 45%, transparent);
  outline-offset: 1px;
}

.dropzone-lane--success .dropzone-lane-icon {
  color: #16a34a;
}

.dropzone-lane--success .dropzone-lane-bar-fill {
  background: #16a34a;
}

.dropzone-lane--error {
  border-color: rgba(220, 53, 69, 0.45);
}

.dropzone-lane--error .dropzone-lane-icon {
  color: #dc3545;
}

.dropzone-lane--error .dropzone-lane-meta {
  color: #dc3545;
}

.dropzone-lane--stalled {
  border-color: rgba(230, 145, 30, 0.5);
}

.dropzone-lane--stalled .dropzone-lane-icon {
  color: var(--warning-color, #e6911e);
}

.dropzone-lane--stalled .dropzone-lane-meta {
  color: var(--warning-color, #e6911e);
}

.dropzone-lane--stalled .dropzone-lane-bar-fill {
  opacity: 0.5;
}

body.theme-dark .dropzone-lane--stalled .dropzone-lane-icon,
body.theme-dark .dropzone-lane--stalled .dropzone-lane-meta {
  color: #fbbf24;
}

body.theme-dark .dropzone-lane--success .dropzone-lane-icon,
body.theme-dark .dropzone-lane--success .dropzone-lane-bar-fill {
  color: #4ade80;
}

body.theme-dark .dropzone-lane--success .dropzone-lane-bar-fill {
  background: #4ade80;
}

body.theme-dark .dropzone-lane--error .dropzone-lane-icon,
body.theme-dark .dropzone-lane--error .dropzone-lane-meta {
  color: #f87171;
}

@media (prefers-reduced-motion: reduce) {
  .dropzone-lane-bar-fill {
    transition: none;
  }

  .dropzone::after {
    transition: none;
  }
}

/* Floating lane host: upload progress on pages without an inline dropzone
 * (mobile app pages). Dismissible; uploads continue when hidden. Projects
 * can raise it above bottom chrome via --dropzone-float-bottom. */
.dropzone-lane-float {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: var(--dropzone-float-bottom, 16px);
  z-index: 9000;
  background: var(--surface-container, var(--container-bg, #ffffff));
  border: 1px solid var(--border-color, rgba(0, 0, 0, 0.1));
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  padding: 10px 12px 12px;
  max-height: 45vh;
  overflow-y: auto;
}

.dropzone-lane-float-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.dropzone-lane-float-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted-text, #6b7280);
}

.dropzone-lane-float-close {
  border: none !important;
  background: transparent !important;
  margin: 0 !important;
  padding: 4px 6px !important;
  min-height: 0 !important;
  color: var(--muted-text, #6b7280) !important;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.dropzone-lanes--float {
  margin: 0;
}
