/* Table and Dark Overrides */
.trip-management-container {
  width: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
}

/* Improve DataTable font across headers, cells, paginator, and body */
.trip-management-container .p-datatable,
.trip-management-container .p-datatable th,
.trip-management-container .p-datatable td,
.trip-management-container .p-paginator,
.trip-management-container .p-datatable .p-datatable-header,
.trip-management-container .p-datatable .p-datatable-footer{
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif !important;
  font-weight: 500 !important;
  font-size: 0.95rem !important;
  line-height: 1.25rem !important;
}

/* Keep monospace for any code or ident columns */
.trip-management-container .p-datatable td.code, 
.trip-management-container .p-datatable td.mono {
  font-family: ui-monospace, "JetBrains Mono", "Fira Code", "Roboto Mono", "Consolas", "Monaco", "Courier New", monospace !important;
  font-weight: 400 !important;
}

.trip-management-container .table-wrapper {
  width: 100%;
}

.trip-management-container .p-datatable {
  width: 100% !important;
  display: block !important;
}

.trip-management-container .p-datatable-wrapper {
  width: 100% !important;
  overflow-x: auto;
}

.trip-management-container .p-datatable-table {
  width: 100% !important;
  table-layout: fixed !important;
  min-width: 100% !important;
}

/* Force header and body rows to fill width */
.trip-management-container .p-datatable-thead,
.trip-management-container .p-datatable-tbody {
  width: 100% !important;
}

.trip-management-container .p-datatable-thead > tr,
.trip-management-container .p-datatable-tbody > tr {
  width: 100% !important;
}

/* Column widths - distribute across table */
.trip-management-container .p-datatable-thead > tr > th,
.trip-management-container .p-datatable-tbody > tr > td {
  /* Default column distribution: uniform padding and vertical alignment */
  padding: 0.65rem 0.5rem;
  vertical-align: middle;
}

/* ID column - narrow */
.trip-management-container .p-datatable-thead > tr > th:nth-child(1),
.trip-management-container .p-datatable-tbody > tr > td:nth-child(1) {
  width: 10% !important;
}

/* Target column - widest */
.trip-management-container .p-datatable-thead > tr > th:nth-child(2),
.trip-management-container .p-datatable-tbody > tr > td:nth-child(2) {
  width: 22% !important;
}

/* Tracks column */
.trip-management-container .p-datatable-thead > tr > th:nth-child(3),
.trip-management-container .p-datatable-tbody > tr > td:nth-child(3) {
  width: 10% !important;
}

/* Status column */
.trip-management-container .p-datatable-thead > tr > th:nth-child(4),
.trip-management-container .p-datatable-tbody > tr > td:nth-child(4) {
  width: 12% !important;
  text-align: center;
}

/* Progress column */
.trip-management-container .p-datatable-thead > tr > th:nth-child(5),
.trip-management-container .p-datatable-tbody > tr > td:nth-child(5) {
  width: 16% !important;
  text-align: center;
}

/* Quality column */
.trip-management-container .p-datatable-thead > tr > th:nth-child(6),
.trip-management-container .p-datatable-tbody > tr > td:nth-child(6) {
  width: 10% !important;
  text-align: center;
}

/* Tarball column - fills remaining */
.trip-management-container .p-datatable-thead > tr > th:nth-child(7),
.trip-management-container .p-datatable-tbody > tr > td:nth-child(7) {
  width: 20% !important;
}

.trip-management-container .p-datatable td span.truncate {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Row hover cursor - indicate clickable */
.trip-management-container .p-datatable-tbody > tr {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

/* Center-align headers for centered columns */
.trip-management-container .p-datatable-thead > tr > th:nth-child(4),
.trip-management-container .p-datatable-thead > tr > th:nth-child(5),
.trip-management-container .p-datatable-thead > tr > th:nth-child(6) {
  text-align: center !important;
}

/* Skeleton loading styles */
.table-skeleton {
  width: 100%;
  border-radius: 0.5rem;
  overflow: hidden;
}

.skeleton-row {
  display: flex;
  padding: 1rem 0.75rem;
  border-bottom: 1px solid rgba(128, 128, 128, 0.2);
}

.skeleton-row:last-child {
  border-bottom: none;
}

.skeleton-cell {
  padding: 0 0.5rem;
}

.skeleton-bar {
  height: 1rem;
  background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 0.25rem;
  width: 80%;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Light mode skeleton */
[data-theme="light"] .skeleton-bar {
  background: linear-gradient(90deg, #e5e5e5 25%, #f0f0f0 50%, #e5e5e5 75%);
  background-size: 200% 100%;
}

/* Empty state styles */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  text-align: center;
}

.empty-state-icon {
  font-size: 3rem;
  color: #6b7280;
  margin-bottom: 1rem;
}

.empty-state-text {
  font-size: 1.125rem;
  font-weight: 600;
  color: #9ca3af;
  margin-bottom: 0.25rem;
}

.empty-state-subtext {
  font-size: 0.875rem;
  color: #6b7280;
}

/* Dark Mode for Table */
[data-theme="dark"] .trip-management-container .p-datatable {
  color: #e5e7eb !important;
}
[data-theme="dark"] .trip-management-container .p-datatable-thead > tr > th {
  background-color: #1f1f1f !important;
  color: #e5e7eb !important;
  border-bottom: 1px solid #374151;
}
[data-theme="dark"] .trip-management-container .p-datatable-tbody > tr {
  background-color: #1a1a1a !important;
  border-bottom: 1px solid #374151;
  color: #e5e7eb !important;
}
[data-theme="dark"] .trip-management-container .p-datatable-tbody > tr:nth-child(odd) {
  background-color: #222 !important;
}
[data-theme="dark"] .trip-management-container .p-datatable-tbody > tr:hover {
  background-color: #333 !important;
  color: #fff !important;
}

/* Paginator Dark Mode */
[data-theme="dark"] .trip-management-container .p-paginator {
  background-color: #121212 !important;
  color: #e5e7eb !important;
  border-top: 1px solid #374151 !important;
}
[data-theme="dark"] .trip-management-container .p-paginator .p-paginator-page,
[data-theme="dark"] .trip-management-container .p-paginator .p-paginator-next,
[data-theme="dark"] .trip-management-container .p-paginator .p-paginator-prev,
[data-theme="dark"] .trip-management-container .p-paginator .p-paginator-first,
[data-theme="dark"] .trip-management-container .p-paginator .p-paginator-last {
  color: #e5e7eb !important;
  background: transparent !important;
  border: none !important;
}
[data-theme="dark"] .trip-management-container .p-paginator .p-paginator-page:hover,
[data-theme="dark"] .trip-management-container .p-paginator .p-paginator-next:hover,
[data-theme="dark"] .trip-management-container .p-paginator .p-paginator-prev:hover {
  background-color: #374151 !important;
  color: #fff !important;
  border-radius: 0.25rem;
}
[data-theme="dark"] .trip-management-container .p-paginator .p-highlight {
  background-color: #6b7280 !important;
  color: #fff !important;
  border-radius: 0.25rem !important;
}

/* Dark Mode for PrimeReact Dialog - rendered via portal so needs global selector */
[data-theme="dark"] .p-dialog.dark\:bg-neutral-900 {
  background-color: #1a1a1a !important;
  color: #e5e7eb !important;
  border-color: #374151 !important;
}
[data-theme="dark"] .p-dialog.dark\:bg-neutral-900 .p-dialog-header {
  background-color: #171717 !important;
  color: #e5e7eb !important;
  border-bottom: 1px solid #374151 !important;
}
[data-theme="dark"] .p-dialog.dark\:bg-neutral-900 .p-dialog-header .p-dialog-header-icon {
  color: #e5e7eb !important;
}
[data-theme="dark"] .p-dialog.dark\:bg-neutral-900 .p-dialog-header .p-dialog-header-icon:hover {
  background-color: #374151 !important;
  color: #fff !important;
}
[data-theme="dark"] .p-dialog.dark\:bg-neutral-900 .p-dialog-content {
  background-color: #1a1a1a !important;
  color: #e5e7eb !important;
}
[data-theme="dark"] .p-dialog.dark\:bg-neutral-900 .p-dialog-footer {
  background-color: #171717 !important;
  border-top: 1px solid #374151 !important;
}

/* Progress Bar Styles */
.rm-progress-container {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 0.5rem; /* space between track and percent */
}


.rm-progress-track {
  position: relative;
  flex: 1 1 0%;
  min-width: 0;
  height: 6px;
  background-color: rgba(128, 128, 128, 0.2);
  border-radius: 999px; /* rounded track so fill edge is hidden when smaller */
  overflow: hidden; /* must clip when scaled */
  margin: 0 !important;
  padding: 0 !important;
  margin-right: 0; /* ensure neighbor percent isn't pushed inside */
}

.rm-progress-track-lg {
  height: 10px;
}

.rm-progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 100% !important; /* full width; we scale via transform to avoid subpixel gaps */
  transform-origin: left center;
  transform: scaleX(var(--rm-progress, 0)); /* use custom property (0-1 range) */
  border-top-left-radius: 999px;
  border-bottom-left-radius: 999px;
  transition: transform .5s cubic-bezier(.25,.8,.25,1), background-color .28s ease, border-radius .28s;
  margin: 0 !important;
  padding: 0 !important;
  right: 0;
  min-width: 0;
  will-change: transform, background-color;
  box-sizing: border-box;
  z-index: 1; /* ensure fill sits beneath the percent text */
}

/* Ensure percent label appears above the fill even when inside the track */
.rm-progress-text {
  position: relative;
  z-index: 2;
  flex: none; /* don't stretch */
  margin-left: 0.5rem;
  white-space: nowrap;
  overflow: visible;
}

/* Finalizing pulse for near-100% jobs */
.rm-finalizing {
  animation: rm-finalize-pulse 1.6s ease-in-out infinite;
}

@keyframes rm-finalize-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 193, 7, 0);
  }
  50% {
    box-shadow: 0 0 12px 4px rgba(255, 193, 7, 0.10);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 193, 7, 0);
  }
}

/* Fix for native audio progress bar (range input) */
.audio-progress-range {
  width: 100%;
  height: 6px;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  border-radius: 999px;
  overflow: hidden;
  margin: 0;
  padding: 0;
}
.audio-progress-range::-webkit-slider-runnable-track {
  height: 6px;
  background: rgba(128, 128, 128, 0.2);
  border-radius: 999px;
}
.audio-progress-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #2563eb;
  box-shadow: 0 0 2px rgba(0,0,0,0.2);
  margin-top: -3px;
  cursor: pointer;
  border: none;
}
.audio-progress-range::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #2563eb;
  border: none;
  cursor: pointer;
}
.audio-progress-range::-ms-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #2563eb;
  border: none;
  cursor: pointer;
}
.audio-progress-range::-ms-fill-lower {
  background: #2563eb;
  border-radius: 999px;
}
.audio-progress-range::-ms-fill-upper {
  background: rgba(128, 128, 128, 0.2);
  border-radius: 999px;
}
.audio-progress-range::-webkit-slider-thumb {
  box-shadow: 0 0 2px rgba(0,0,0,0.2);
}
.audio-progress-range:focus {
  outline: none;
}
.audio-progress-range::-webkit-slider-runnable-track {
  background: linear-gradient(to right, #2563eb 0%, #2563eb var(--progress, 0%), rgba(128,128,128,0.2) var(--progress, 0%), rgba(128,128,128,0.2) 100%);
}
.audio-progress-range::-moz-range-progress {
  background-color: #2563eb;
  border-radius: 999px;
}
.audio-progress-range::-moz-range-track {
  background-color: rgba(128, 128, 128, 0.2);
  border-radius: 999px;
}
.audio-progress-range::-ms-fill-lower {
  background-color: #2563eb;
  border-radius: 999px;
}
.audio-progress-range::-ms-fill-upper {
  background-color: rgba(128, 128, 128, 0.2);
  border-radius: 999px;
}
.audio-progress-range:focus::-webkit-slider-runnable-track {
  background: linear-gradient(to right, #2563eb 0%, #2563eb var(--progress, 0%), rgba(128,128,128,0.2) var(--progress, 0%), rgba(128,128,128,0.2) 100%);
}
.audio-progress-range::-ms-tooltip {
  display: none;
}

.rm-progress-text {
  font-size: 0.75rem;
  font-weight: 600;
  color: inherit;
}

/* Ensure progress styles apply when rendered within a PrimeReact Dialog (portal) */
.p-dialog .rm-progress-container {
  display: flex;
  align-items: center;
  width: 100%;
}
.p-dialog .rm-progress-track {
  position: relative;
  flex: 1 1 0%;
  min-width: 0;
  height: 6px;
  background-color: #80808033;
  border-radius: 999px;
  overflow: hidden;
  margin: 0 !important;
  padding: 0 !important;
}
.p-dialog .rm-progress-track-lg { height: 10px; }
.p-dialog .rm-progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 100% !important;
  transform-origin: left center;
  transform: scaleX(var(--rm-progress, 0));
  border-top-left-radius: 999px;
  border-bottom-left-radius: 999px;
  transition: transform .5s cubic-bezier(.25,.8,.25,1), background-color .28s ease, border-radius .28s;
  margin: 0 !important;
  padding: 0 !important;
  right: 0;
  min-width: 0;
  will-change: transform, background-color;
  box-sizing: border-box;
}
.p-dialog .rm-progress-text { font-size: .75rem; font-weight: 600; color: #e5e7eb !important; margin-left: 0.5rem; white-space: nowrap; }

/* Request Details Dialog - Responsive Track List */
.request-details-dialog .p-dialog-content {
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  overflow: hidden;
}

.request-details-content {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.request-details-content > .track-list-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.track-list-scrollable {
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
}

/* Container Styles */
.trip-management-container {
  width: 100%;
}

.trip-management-container .overflow-x-auto {
  overflow-x: auto;
  max-width: 100%;
}

.trip-request-form {
  width: 100%;
}

@media (max-width: 768px) {
  .trip-management-container {
    padding: 1rem;
    margin: 1rem 0;
  }
  
  .trip-management-container h2 {
    font-size: 1.5rem;
  }
  
  /* Stack filters on mobile */
  .trip-management-container .flex-wrap {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  /* Make table horizontally scrollable */
  .trip-management-container .overflow-x-auto {
    margin: 0 -1rem;
    padding: 0 1rem;
  }
  
  /* Reduce column widths on mobile */
  .p-datatable-thead > tr > th,
  .p-datatable-tbody > tr > td {
    padding: 0.5rem 0.25rem !important;
    font-size: 0.8rem !important;
  }
  
  /* Hide less important columns on small screens */
  .p-datatable .hide-mobile {
    display: none !important;
  }
}

@media (max-width: 480px) {
  .trip-management-container {
    padding: 0.75rem;
    border-radius: 0.5rem;
  }
  
  .trip-management-container .rm-progress-container {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
  
  .trip-management-container .rm-progress-track {
    width: 100%;
  }
  
  .trip-management-container .rm-progress-text {
    text-align: left;
  }
}

/* ===== MediaRequestForm Mobile Styles ===== */

/* Form container responsive */
.trip-request-form {
  width: 100%;
  max-width: 48rem;
  margin: 2.5rem auto;
  padding: 1.5rem;
}

@media (max-width: 768px) {
  .trip-request-form {
    margin: 1rem auto;
    padding: 1rem;
    border-radius: 0.75rem;
  }
  
  .trip-request-form h2 {
    font-size: 1.5rem;
  }
  
  /* Quality buttons stack on mobile */
  .trip-quality-buttons {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .trip-quality-buttons button {
    width: 100%;
  }
  
  /* Accordion improvements for mobile */
  .p-accordion-header .p-accordion-header-link {
    padding: 0.75rem !important;
    font-size: 0.9rem !important;
  }
  
  .p-accordion-content {
    padding: 0.5rem !important;
  }
  
  /* Track list items more compact on mobile */
  .p-accordion-content li {
    padding: 0.5rem !important;
    font-size: 0.85rem !important;
  }

/* Track list scrollbar and status pill adjustments */
.rm-track-list {
  /* Give room for overlay scrollbars so status pills don't overlap */
  padding-inline-end: 1.25rem; /* ~20px */
}

.rm-track-status {
  /* Ensure the status pill has extra right padding and sits visually clear of the scrollbar */
  padding-right: 0.75rem !important;
  margin-right: 0.25rem !important;
  border-radius: 999px !important;
}

/* Slightly reduce spacing on very small screens */
@media (max-width: 480px) {
  .rm-track-list { padding-inline-end: 0.75rem; }
  .rm-track-status { padding-right: 0.5rem !important; }
}
  
  /* Album header info stacks */
  .album-header-info {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.25rem;
  }
  
  /* Audio player controls smaller on mobile */
  .track-audio-controls button {
    padding: 0.25rem 0.5rem !important;
  }
}

@media (max-width: 480px) {
  .trip-request-form {
    margin: 0.5rem;
    padding: 0.75rem;
  }
  
  .trip-request-form h2 {
    font-size: 1.25rem;
  }
  
  /* Input fields full width */
  .p-autocomplete,
  .p-autocomplete-input {
    width: 100% !important;
  }
  
  /* Smaller text in track listings */
  .p-accordion-content li span {
    font-size: 0.75rem !important;
  }
  
  /* Submit button full width */
  .trip-submit-button {
    width: 100%;
  }
}

/* ========================================
   Mobile Card Layout for Request Table
   ======================================== */
@media (max-width: 768px) {
  /* Hide table header on mobile */
  .trip-management-container .p-datatable-thead {
    display: none !important;
  }
  
  /* Convert table to block layout */
  .trip-management-container .p-datatable-table {
    display: block !important;
    table-layout: auto !important;
  }
  
  .trip-management-container .p-datatable-tbody {
    display: block !important;
  }
  
  /* Each row becomes a card */
  .trip-management-container .p-datatable-tbody > tr {
    display: flex !important;
    flex-wrap: wrap !important;
    padding: 1rem !important;
    margin-bottom: 0.75rem !important;
    border-radius: 0.5rem !important;
    border: 1px solid rgba(128, 128, 128, 0.3) !important;
    gap: 0.5rem 1rem;
    align-items: flex-start;
  }
  
  /* Reset column widths */
  .trip-management-container .p-datatable-tbody > tr > td {
    width: auto !important;
    padding: 0.25rem 0 !important;
    border: none !important;
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
    flex: 1 1 48%;
    min-width: 48%;
  }
  
  /* Add labels before each cell */
  .trip-management-container .p-datatable-tbody > tr > td::before {
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: #9ca3af;
    min-width: 60px;
    line-height: 1.1;
    display: inline-block;
  }
  
  /* Target takes full width */
  .trip-management-container .p-datatable-tbody > tr > td:nth-child(2) {
    width: 100% !important;
    order: -1;
    font-weight: 600;
    font-size: 1rem;
    padding-bottom: 0.5rem !important;
    border-bottom: 1px solid rgba(128, 128, 128, 0.2) !important;
    margin-bottom: 0.25rem;
    flex: 1 1 100%;
  }
  
  .trip-management-container .p-datatable-tbody > tr > td:nth-child(2)::before {
    display: none;
  }
  
  /* ID - small, muted */
  .trip-management-container .p-datatable-tbody > tr > td:nth-child(1) {
    font-size: 0.75rem;
    color: #6b7280;
  }
  .trip-management-container .p-datatable-tbody > tr > td:nth-child(1)::before {
    content: "ID";
  }
  
  /* Tracks */
  .trip-management-container .p-datatable-tbody > tr > td:nth-child(3)::before {
    content: "Tracks";
  }
  
  /* Status */
  .trip-management-container .p-datatable-tbody > tr > td:nth-child(4)::before {
    content: "Status";
  }
  
  /* Progress - full width */
  .trip-management-container .p-datatable-tbody > tr > td:nth-child(5) {
    width: 100% !important;
    order: 10;
    flex: 1 1 100%;
  }
  .trip-management-container .p-datatable-tbody > tr > td:nth-child(5)::before {
    content: "Progress";
  }
  
  /* Quality */
  .trip-management-container .p-datatable-tbody > tr > td:nth-child(6)::before {
    content: "Quality";
  }
  
  /* Tarball - full width */
  .trip-management-container .p-datatable-tbody > tr > td:nth-child(7) {
    width: 100% !important;
    order: 11;
    flex: 1 1 100%;
  }
  .trip-management-container .p-datatable-tbody > tr > td:nth-child(7)::before {
    content: "Download";
  }
  
  /* Progress bar adjustments for mobile */
  .trip-management-container .rm-progress-container {
    flex: 1;
  }
  
  /* Skeleton adjustments for mobile */
  .table-skeleton .skeleton-row {
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(128, 128, 128, 0.2);
  }
  
  .table-skeleton .skeleton-cell {
    width: 100% !important;
  }
  
  .table-skeleton .skeleton-bar {
    width: 60%;
  }
  
  .table-skeleton .skeleton-cell:first-child .skeleton-bar {
    width: 100%;
    height: 1.25rem;
  }
}
