/* Inline attachment thumbnails — subtle, non-intrusive */

.attachment-gallery {
  margin: 0;
}

.attachment-gallery__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
}

.attachment-gallery__item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 112px;
}

.attachment-gallery__item--file {
  max-width: 120px;
}

.attachment-gallery--compact .attachment-gallery__item--file {
  max-width: 96px;
}

.attachment-thumb {
  position: relative;
  display: block;
  width: 88px;
  height: 66px;
  padding: 0;
  border: 1px solid var(--ty-slate-200, #e2e8f0);
  border-radius: 6px;
  overflow: hidden;
  background: var(--ty-slate-50, #f8fafc);
  cursor: zoom-in;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.attachment-gallery--compact .attachment-thumb {
  width: 72px;
  height: 54px;
}

.attachment-gallery:not(.attachment-gallery--compact) .attachment-thumb {
  width: 96px;
  height: 72px;
}

.attachment-thumb:hover,
.attachment-thumb:focus-visible {
  border-color: var(--ty-teal, #0d9488);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
  outline: none;
}

.attachment-thumb__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attachment-thumb__hint {
  position: absolute;
  right: 4px;
  bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.attachment-thumb:hover .attachment-thumb__hint,
.attachment-thumb:focus-visible .attachment-thumb__hint {
  opacity: 1;
}

.attachment-thumb__video-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: linear-gradient(160deg, #1e293b 0%, #334155 100%);
  color: #fff;
  gap: 2px;
  padding: 6px;
  box-sizing: border-box;
}

.attachment-thumb__play-icon {
  opacity: 0.92;
  width: 22px;
  height: 22px;
}

.attachment-thumb__video-label {
  display: none;
}

.attachment-thumb__pdf-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: linear-gradient(160deg, #991b1b 0%, #dc2626 100%);
  color: #fff;
  gap: 4px;
  padding: 6px;
  box-sizing: border-box;
  text-align: center;
}

.attachment-thumb__pdf-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.attachment-thumb__pdf-label {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 9px;
  line-height: 1.2;
  opacity: 0.92;
}

.attachment-gallery:not(.attachment-gallery--compact) .attachment-thumb__pdf-label {
  display: none;
}

.attachment-gallery__filename {
  font-size: 10px;
  line-height: 1.25;
  color: var(--ty-slate-500, #64748b);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-file {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 88px;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  text-decoration: none;
  text-align: center;
}

.attachment-gallery--compact .attachment-file {
  width: 72px;
}

.attachment-file:hover,
.attachment-file:focus-visible {
  text-decoration: none;
  outline: none;
}

.attachment-file:hover .attachment-file__badge,
.attachment-file:focus-visible .attachment-file__badge {
  border-color: var(--ty-teal, #0d9488);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

.attachment-file__badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 54px;
  border: 1px solid var(--ty-slate-200, #e2e8f0);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-family: var(--ty-font-code, "JetBrains Mono", ui-monospace, monospace);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.attachment-gallery:not(.attachment-gallery--compact) .attachment-file__badge {
  height: 66px;
}

.attachment-file--pdf .attachment-file__badge {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.attachment-file--excel .attachment-file__badge {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.attachment-file--word .attachment-file__badge {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.attachment-file--file .attachment-file__badge {
  background: var(--ty-slate-50, #f8fafc);
  color: var(--ty-slate-600, #475569);
}

.attachment-file__name {
  width: 100%;
  font-size: 10px;
  line-height: 1.3;
  color: var(--ty-slate-600, #475569);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.attachment-file:hover .attachment-file__name,
.attachment-file:focus-visible .attachment-file__name {
  color: var(--ty-teal, #0d9488);
}

/* Light modal preview */

.attachment-preview-modal {
  width: min(92vw, 880px);
  max-height: 90vh;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
}

.attachment-preview-modal::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.attachment-preview-modal__panel {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  background: var(--ty-white, #fff);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.2);
}

.attachment-preview-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--ty-slate-100, #f1f5f9);
  background: var(--ty-white, #fff);
}

.attachment-preview-modal__title {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--ty-slate-600, #475569);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-preview-modal__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.attachment-preview-modal__link {
  font-size: 11px;
  font-weight: 600;
  color: var(--ty-teal, #0d9488);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 4px;
}

.attachment-preview-modal__link:hover {
  background: rgba(13, 148, 136, 0.08);
  text-decoration: none;
}

.attachment-preview-modal__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--ty-slate-500, #64748b);
  cursor: pointer;
}

.attachment-preview-modal__close:hover {
  background: var(--ty-slate-100, #f1f5f9);
  color: var(--ty-slate-800, #1e293b);
}

.attachment-preview-modal__body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: var(--ty-slate-900, #0f172a);
  min-height: 180px;
  overflow: auto;
}

.attachment-preview-modal__image,
.attachment-preview-modal__video {
  display: block;
  max-width: 100%;
  max-height: calc(90vh - 72px);
  width: auto;
  height: auto;
  border-radius: 4px;
}

.attachment-preview-modal__video {
  background: #000;
}

.attachment-preview-modal__pdf {
  display: block;
  width: min(920px, 100%);
  height: calc(90vh - 88px);
  min-height: 420px;
  border: 0;
  border-radius: 4px;
  background: #fff;
}

.attachment-preview-modal__loading {
  color: var(--ty-slate-400, #94a3b8);
  font-size: 13px;
}

/* Vehicle history timeline cards */
.vh-timeline-attachments {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--ty-slate-100, #f1f5f9);
}

/* CM/PM photo & video upload field */
.maintenance-media-upload__gallery {
  margin-bottom: 12px;
}

.maintenance-media-upload__gallery:empty {
  display: none;
}

.maintenance-media-upload__item {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}

.maintenance-media-upload__item .attachment-thumb video.attachment-thumb__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.maintenance-media-upload__remove {
  position: absolute;
  top: -6px;
  right: -6px;
  z-index: 2;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--ty-slate-200, #e2e8f0);
  border-radius: 999px;
  background: #fff;
  color: #64748b;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.maintenance-media-upload__remove:hover {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
}

.maintenance-media-upload__actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.maintenance-media-upload__hint {
  margin: 0;
}

.maintenance-media-upload__input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
