/* =============================================================================
 * file-upload.css — File upload, media grid, lightbox styles
 * spec: file-upload-ui-spec.md §7
 * ========================================================================== */

/* ─── Upload Progress Bar ─────────────────────────────────────────────────── */
/* spec: §1.2 */

.upload-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--border-color, #e2e8f0);
  overflow: hidden;
  margin-top: 8px;
  display: none;
}

.upload-progress.active {
  display: block;
}

.upload-progress-bar {
  height: 100%;
  border-radius: 2px;
  background: var(--primary, #2563eb);
  transition: width 200ms ease;
  width: 0%;
}

/* ─── Media Grid ──────────────────────────────────────────────────────────── */
/* spec: §4.1, §4.2 */

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  padding: 16px 0;
}

.media-card {
  position: relative;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface, #fff);
  cursor: pointer;
  transition: box-shadow 150ms ease, transform 150ms ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.media-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
}

.media-card-thumb {
  width: 100%;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary, #f1f5f9);
  overflow: hidden;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.media-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-card-thumb .file-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  color: #fff;
  letter-spacing: 0.5px;
}

.file-icon-pdf {
  background: #dc2626;
}

.file-icon-video {
  background: #7c3aed;
}

.file-icon-generic {
  background: #6b7280;
}

.media-card-info {
  padding: 10px 12px;
}

.media-card-filename {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary, #1e293b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.media-card-meta {
  font-size: 11px;
  color: var(--text-tertiary, #94a3b8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 3px;
  line-height: 1.3;
}

.media-card-caption {
  font-size: 11px;
  color: var(--text-tertiary, #94a3b8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 3px;
  line-height: 1.3;
  cursor: pointer;
  border-radius: 3px;
  padding: 1px 2px;
  margin: 2px -2px 0;
  transition: background 150ms;
}

.media-card-caption:hover {
  background: var(--bg-secondary, #f1f5f9);
}

.media-card-caption--placeholder {
  font-style: normal;
  color: var(--primary, #2563eb);
  opacity: 0.7;
}

.media-card-caption--placeholder:hover {
  opacity: 1;
}

.media-caption-inline-input {
  width: 100%;
  font-size: 11px;
  border: 1px solid var(--primary, #2563eb);
  border-radius: 3px;
  padding: 1px 4px;
  outline: none;
  background: var(--surface, #fff);
  color: var(--text-primary, #1e293b);
  line-height: 1.3;
}

.media-card-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  backdrop-filter: blur(4px);
  transition: background 150ms;
  z-index: 2;
}

.media-card:hover .media-card-delete {
  display: flex;
}

.media-card-delete:hover {
  background: var(--danger, #dc2626);
}

/* ─── Media Tab Header ────────────────────────────────────────────────────── */

.media-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0 4px;
}

.media-count {
  font-size: 13px;
  color: var(--text-secondary, #64748b);
  font-weight: 500;
}

/* ─── Lightbox ────────────────────────────────────────────────────────────── */
/* spec: §1.3 */

.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
}

.lightbox-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 90vw;
  max-height: 90vh;
}

.lightbox-img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 4px;
}

.lightbox-caption {
  color: #e2e8f0;
  font-size: 13px;
  margin-top: 12px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.lightbox-counter {
  color: #94a3b8;
  font-size: 12px;
  margin-top: 4px;
}

.lightbox-close {
  position: fixed;
  top: 16px;
  right: 20px;
  z-index: 2;
  background: none;
  border: none;
  color: #fff;
  font-size: 36px;
  cursor: pointer;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 150ms;
}

.lightbox-close:hover {
  opacity: 1;
}

.lightbox-prev,
.lightbox-next {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  font-size: 48px;
  cursor: pointer;
  width: 48px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  opacity: 0.7;
  transition: opacity 150ms, background 150ms;
}

.lightbox-prev:hover,
.lightbox-next:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.2);
}

.lightbox-prev {
  left: 16px;
}

.lightbox-next {
  right: 16px;
}

/* ─── Upload Preview List (per-file captions modal) ──────────────────────── */

.upload-preview-list {
  max-height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.upload-preview-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  background: var(--bg-secondary, #f8fafc);
}

.upload-preview-thumb {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-secondary, #f1f5f9);
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-preview-thumb .file-icon {
  width: 32px;
  height: 32px;
  font-size: 9px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  text-transform: uppercase;
  color: #fff;
}

.upload-preview-fields {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.upload-preview-filename {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary, #1e293b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-preview-caption {
  font-size: 12px !important;
  padding: 4px 8px !important;
  height: 28px !important;
}

.upload-preview-remove {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--text-tertiary, #94a3b8);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: color 150ms, background 150ms;
}

.upload-preview-remove:hover {
  color: var(--danger, #dc2626);
  background: rgba(220, 38, 38, 0.08);
}

/* ─── Receipt Field in Modal ──────────────────────────────────────────────── */
/* spec: §5.1 */

.receipt-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px dashed var(--border-color, #e2e8f0);
  border-radius: 6px;
  background: var(--bg-secondary, #f8fafc);
  min-height: 40px;
}

.receipt-field-file {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-primary, #1e293b);
  min-width: 0;
}

.receipt-field-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.receipt-field-size {
  color: var(--text-tertiary, #94a3b8);
  font-size: 12px;
  white-space: nowrap;
}

.receipt-field-remove {
  background: none;
  border: none;
  color: var(--text-tertiary, #94a3b8);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 4px;
  line-height: 1;
}

.receipt-field-remove:hover {
  color: var(--danger, #dc2626);
}

/* ─── Receipt Indicator in Table ──────────────────────────────────────────── */

.receipt-indicator {
  color: var(--text-tertiary, #94a3b8);
  cursor: pointer;
  transition: color 150ms;
}

.receipt-indicator:hover {
  color: var(--primary, #2563eb);
}

/* ─── Dispatch Document Cards ─────────────────────────────────────────────── */

.doc-grid {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.doc-card {
  cursor: default;
}

.doc-card-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary, #2563eb);
  margin-bottom: 4px;
}

.doc-card-empty {
  cursor: pointer;
}

.doc-card-empty .media-card-thumb {
  cursor: pointer;
}

.doc-card-empty:hover {
  border-color: var(--primary, #2563eb);
}

.doc-card-empty:hover .media-card-thumb {
  background: var(--bg-primary, #eff6ff);
}

.doc-card-actions {
  display: flex;
  gap: 6px;
  padding: 0 12px 10px;
}

.doc-card-actions .btn {
  flex: 1;
  font-size: 11px;
  padding: 4px 0;
}

.doc-card .upload-progress {
  margin: 0 12px 8px;
}

.doc-card-upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-bottom: 1px dashed var(--border-color, #e2e8f0);
}
