/* 
 * EC* Viewer - Minimal Flat High-Contrast Design
 * Clean, modern, high-contrast interface
 */

/* Minimal High-Contrast Color Palette */
:root {
  --bg: #ffffff;
  --bg-alt: #f5f5f5;
  --bg-hover: #e8e8e8;
  --accent: var(--accent-color);
  --accent-hover: #e8e8e8;
  --text: #000000;
  --text-dim: #666666;
  --border: #000000;
  --highlight: var(--accent-color);
}

/* Override parent data element to allow full height */
body:has(.ec-viewer) {
  height: 100vh;
  overflow: hidden;
}

body:has(.ec-viewer) metadata {
  height: 100vh;
  overflow-y: auto;
}

body:has(.ec-viewer) data {
  padding: 0;
  max-width: none;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Main Container - Full Width and Height */
.ec-viewer {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg);
  font-family: var(--font-family-ui);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
}

/* Controls Bar - 3 Column Flexbox Layout */
.ec-controls {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  min-height: 68px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* Left Column: Filter Switch, Filters, VU Meter, Buttons - 2 Row Grid */
.ec-controls-left {
  display: grid;
  grid-template-columns: auto auto auto auto;
  grid-template-rows: 1fr 1fr;
  grid-auto-flow: column;
  gap: 6px 12px;
  align-items: center;
  flex: 0 1 auto;
  min-width: 0;
}

/* Filter mode spans 2 rows - column 1 */
.ec-controls-left .ec-filter-mode {
  grid-column: 1;
  grid-row: 1 / 3;
}

/* Filters wrapper becomes transparent to grid - children participate directly */
.ec-controls-left .ec-filters-wrapper {
  display: contents;
}

/* First filter container - column 2, row 1 */
.ec-controls-left .ec-filter-container:nth-child(1) {
  grid-column: 2;
  grid-row: 1;
}

/* Second filter container - column 2, row 2 */
.ec-controls-left .ec-filter-container:nth-child(2) {
  grid-column: 2;
  grid-row: 2;
}

/* VU meters span 2 rows - column 3 */
.ec-controls-left .ec-vu-meters {
  grid-column: 3;
  grid-row: 1 / 3;
}

/* VU controls wrapper becomes transparent to grid */
.ec-controls-left .ec-vu-controls {
  display: contents;
}

/* First button - column 4, row 1 */
.ec-controls-left .ec-vu-controls .ec-player-btn:nth-child(1) {
  grid-column: 4;
  grid-row: 1;
}

/* Second button - column 4, row 2 */
.ec-controls-left .ec-vu-controls .ec-player-btn:nth-child(2) {
  grid-column: 4;
  grid-row: 2;
}

/* Center Column: Player is a direct child of ec-controls */
/* Styles handled in .ec-player below */

/* Right Column: Stats is a direct child of ec-controls */
/* Styles handled in .ec-stats below */

/* Player - Now Playing (Cover Art and Track Info) */
.ec-player {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px 14px;
  height: 68px;
  max-width: 394px;
  background: var(--bg);
  border: 1px solid var(--border);
  box-sizing: border-box;
  max-width: 400px;
  box-shadow: 4px 4px 8px 0 rgba(0, 0, 0, 0.15);
}

.ec-player-btn {
  width: 32px;
  height: 32px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  position: relative;
  box-shadow: 4px 4px 8px 0 rgba(0, 0, 0, 0.15);
  transition: all 0.08s ease;
}

.ec-player-btn i {
  pointer-events: none;
}

.ec-player-btn:hover {
  background: var(--bg-hover);
}

.ec-player-btn:active {
  background: var(--bg-alt);
  transform: scale(0.92);
  box-shadow: 2px 2px 4px 0 rgba(0, 0, 0, 0.15);
}

.ec-player-btn.muted {
  background: var(--accent);
}

/* Mute Button Boop Circles Animation - Extremely Discrete */
.ec-player-btn.muted::before,
.ec-player-btn.muted::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  border: 1px solid var(--accent);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
}

/* Metadata Title Row with Play Button */
.ec-metadata-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-start;
}

.ec-metadata-play-btn {
  width: 24px;
  height: 24px;
  min-width: 24px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  cursor: pointer;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  position: relative;
  transition: all 0.12s ease;
  flex-shrink: 0;
}

.ec-metadata-play-btn i {
  pointer-events: none;
  margin-left: 1px;
}

.ec-metadata-play-btn:hover {
  background: var(--bg-hover);
}

.ec-metadata-play-btn:active {
  background: var(--bg-alt);
}

/* Player Info Container */
.ec-player-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.ec-player-artwork {
  width: 48px;
  height: 48px;
  min-width: 48px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  position: relative;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.ec-player-artwork::before {
  content: '♪';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-dim);
  font-size: 24px;
}

.ec-player-artwork.has-artwork::before {
  display: none;
}

.ec-player-track-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 250px;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

/* Live Badge - Minimal and Discreet */
.ec-live-badge {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.8px;
  color: var(--text);
  background: #ff0000;
  color: white;
  border: 1px solid var(--border);
  padding: 2px 6px;
  text-transform: uppercase;
  font-family: var(--font-family-ui);
  width: fit-content;
  margin-bottom: 3px;
}

.ec-player-title,
.ec-player-artist {
  white-space: nowrap;
  overflow: hidden;
  line-height: 1.3;
  position: relative;
}

.ec-player-title {
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  font-family: var(--font-family-ui);
}

.ec-player-artist {
  font-size: 9px;
  color: var(--text-dim);
  font-family: var(--font-family-ui);
}

/* iPod-style scrolling animation for long text */
.ec-player-title:hover,
.ec-player-artist:hover {
  overflow: visible;
}

.ec-player-title > span,
.ec-player-artist > span {
  display: inline-block;
  padding-right: 40px;
}

/* Scrolling animation when text is too long - iPod style */
@keyframes scroll-text {
  0% {
    transform: translateX(0);
  }
  15% {
    transform: translateX(0);
  }
  85% {
    transform: translateX(calc(-100% + 250px));
  }
  100% {
    transform: translateX(calc(-100% + 250px));
  }
}

.ec-player-title.scrolling > span,
.ec-player-artist.scrolling > span {
  animation: scroll-text 12s ease-in-out infinite;
  animation-delay: 1s;
}

/* Go to track button in player - styled like other player buttons */
.ec-player-goto-btn {
  width: 32px;
  height: 32px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  position: relative;
  transition: all 0.08s ease;
  box-shadow: 4px 4px 8px 0 rgba(0, 0, 0, 0.15);
}

.ec-player-goto-btn i {
  pointer-events: none;
}

.ec-player-goto-btn:hover {
  background: var(--bg-hover);
}

.ec-player-goto-btn:active {
  background: var(--bg-alt);
  transform: scale(0.92);
}

.ec-player-goto-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  color: var(--text-dim);
}

.ec-player-goto-btn:disabled:hover {
  background: var(--bg);
}

/* VU Meters Container - Just the meters */
.ec-vu-meters {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 32px;
  background: var(--bg);
  border: 1px solid var(--border);
  position: relative;
  padding: 10px 6px;
  box-shadow: 4px 4px 8px 0 rgba(0, 0, 0, 0.15);
}

/* Control buttons - sit next to VU meters */
.ec-vu-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.ec-vu-meter {
  width: 5px;
  height: 40px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
  margin-top: 3px;
}

.ec-vu-meter-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 0%;
  background: linear-gradient(to top, 
    #00ff00 0%, 
    #33ff33 10%,
    #88ff00 30%, 
    #ddff00 50%, 
    #ffcc00 65%,
    #ff8800 80%, 
    #ff3300 90%,
    #ff0000 100%);
  transition: none;
  will-change: height;
  transform: translateZ(0);
}

/* Filter Mode Radio Buttons */
.ec-filter-mode {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 0 0 auto;
  box-shadow: 4px 4px 8px 0 rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border);
  padding: 6px 12px;
}

.ec-radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 11px;
  font-family: var(--font-family-ui);
  color: var(--text);
  font-weight: 500;
  user-select: none;
  padding: 4px 8px;
}

.ec-radio-label input[type="radio"] {
  cursor: pointer;
  margin: 0;
  width: 16px;
  height: 16px;
  appearance: none;
  -webkit-appearance: none;
  border-radius: 0;
  border: 1px solid var(--border);
  background: var(--bg);
  position: relative;
  transition: all 0.15s ease;
}

.ec-radio-label input[type="radio"]:checked {
  background: var(--text);
}

.ec-radio-label span {
  font-size: 10px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  font-weight: 600;
}

/* Filter containers */
.ec-filter-container {
  min-width: 180px;
  max-width: 220px;
}

/* Letter Buttons (A, B, C, D) */
.ec-letter-buttons {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-start;
}

.ec-letter-btn {
  width: 32px;
  height: 32px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-family-ui);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  position: relative;
  transition: all 0.1s ease;
}

.ec-letter-btn:hover {
  background: var(--bg-hover);
}

.ec-letter-btn:active {
  background: var(--bg-alt);
}

.ec-letter-btn.active {
  background: var(--accent);
  color: var(--bg);
}

/* Filter input styling */
#filter-playlists,
#filter-tracks {
  width: 100%;
  padding: 6px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 13px;
  font-family: var(--font-family-ui);
  color: var(--text);
  letter-spacing: 0;
  box-shadow: 4px 4px 8px 0 rgba(0, 0, 0, 0.15);
}

#filter-playlists::placeholder,
#filter-tracks::placeholder {
  color: var(--text-dim);
  font-size: 12px;
}

#filter-playlists:focus,
#filter-tracks:focus {
  outline: none;
  background: var(--bg);
}

.ec-stats {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  font-family: var(--font-family-ui);
  letter-spacing: 0.3px;
  text-align: right;
  flex: 0 0 auto;
  text-shadow: 4px 4px 8px rgba(0, 0, 0, 0.15);
}

#stats-display {
  font-family: var(--font-family-monospace);
  color: var(--text-dim);
  font-weight: 500;
}

/* 3-Column Layout (Default) - Modified to 4 columns */
.ec-columns {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 0;
  flex: 1;
  overflow: hidden;
}

/* Individual Column */
.ec-column {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.ec-column:last-child {
  border-right: none;
}


/* Column Headers - Hidden but functional */
.ec-column-header {
  display: none;
}

/* Column Content - Scrollable */
.ec-column-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
}

/* Table Styling */
.ec-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  padding: 0;
}

.ec-table tbody {
  display: block;
  width: 100%;
}

.ec-table tr {
  display: table;
  width: 100%;
  table-layout: fixed;
}

/* Playlist Rows */
.ec-playlist-row {
  height: 60px;
  cursor: pointer;
  border-bottom: none;
  border-left: 3px solid transparent;
  background: transparent;
}

.ec-playlist-row.selected {
  background: var(--bg-hover);
  border-left-color: transparent;
}

.ec-playlist-row:hover {
  background: var(--accent);
}

.ec-playlist-row.selected .ec-playlist-name,
.ec-playlist-row:hover .ec-playlist-name {
  color: var(--text);
}

.ec-thumb-cell {
  width: 60px;
  padding: 8px 0 8px 9px;
  vertical-align: middle;
}

.ec-info-cell {
  padding: 8px 12px 8px 12px;
  vertical-align: middle;
  overflow: hidden;
}

.ec-playlist-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border: 1px solid var(--border);
  display: block;
}

.ec-no-artwork {
  background: var(--bg-alt);
  border: 1px solid var(--border);
}

.ec-playlist-name {
  font-size: 13px;
  font-weight: 400;
  color: var(--text);
  line-height: 1.4;
  font-family: var(--font-family-ui);
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.ec-playlist-meta {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-family-ui);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ec-playlist-row.selected .ec-playlist-name,
.ec-playlist-row.selected .ec-playlist-meta,
.ec-playlist-row:hover .ec-playlist-name,
.ec-playlist-row:hover .ec-playlist-meta {
  color: var(--text);
}

/* Track Rows */
.ec-track-row {
  height: 60px;
  cursor: pointer;
  border-bottom: none;
  border-left: 3px solid transparent;
  background: transparent;
}

.ec-track-row.selected {
  background: var(--bg-hover);
  border-left-color: transparent;
}

.ec-track-row:hover {
  background: var(--accent);
}

.ec-track-row.selected .ec-track-title,
.ec-track-row:hover .ec-track-title {
  color: var(--text);
}

.ec-track-num-cell {
  width: 40px;
  padding: 8px 0;
  text-align: center;
  vertical-align: middle;
  color: var(--text-dim);
  font-family: var(--font-family-ui);
  font-size: 11px;
}

.ec-track-thumb-cell {
  width: 52px;
  padding: 8px 0;
  vertical-align: middle;
}

.ec-track-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border: 1px solid var(--border);
  display: block;
}

.ec-track-info-cell {
  padding: 8px 8px;
  vertical-align: middle;
  overflow: hidden;
}

.ec-track-title {
  font-size: 13px;
  font-weight: 400;
  color: var(--text);
  line-height: 1.4;
  font-family: var(--font-family-ui);
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.ec-track-artist {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-family-ui);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ec-track-row.selected .ec-track-num-cell,
.ec-track-row.selected .ec-track-artist,
.ec-track-row.selected .ec-track-duration-cell,
.ec-track-row:hover .ec-track-num-cell,
.ec-track-row:hover .ec-track-artist,
.ec-track-row:hover .ec-track-duration-cell {
  color: var(--text);
}

.ec-track-duration-cell {
  width: 60px;
  padding: 8px 8px 8px 8px;
  text-align: right;
  vertical-align: middle;
  font-family: var(--font-family-ui);
  color: var(--text-dim);
  font-size: 11px;
  white-space: nowrap;
}


/* Empty State */
.ec-empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  color: var(--text);
  font-size: 12px;
  font-family: var(--font-family-ui);
}

/* Metadata Display */
.ec-metadata-content {
  padding: 12px 12px;
  color: var(--text);
}

.ec-metadata-artwork {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid var(--border);
  margin-bottom: 10px;
  cursor: pointer;
  transition: transform 0.1s ease;
  box-shadow: 4px 4px 8px 0 rgba(0, 0, 0, 0.15);
}

.ec-metadata-artwork.no-artwork {
  background: var(--bg-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 48px;
  cursor: default;
}

.ec-metadata-artwork.no-artwork:hover {
  transform: none;
}

/* Artwork Lightbox */
.artwork-lightbox {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 10000;
  align-items: center;
  justify-content: center;
}

.artwork-lightbox.active {
  display: flex;
}

.artwork-lightbox-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  opacity: 0.95;
  cursor: pointer;
}

.artwork-lightbox-img {
  position: relative;
  max-width: 98vw;
  max-height: 98vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border: 1px solid var(--border);
  cursor: pointer;
  animation: artwork-zoom-in 0.3s ease-out;
}

@keyframes artwork-zoom-in {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.ec-metadata-section {
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.ec-metadata-section:last-child {
  border-bottom: none;
}

.ec-metadata-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  font-weight: 600;
  font-family: var(--font-family-ui);
  margin-bottom: 4px;
}

.ec-metadata-value {
  font-size: 11px;
  color: var(--text);
  font-family: var(--font-family-ui);
  line-height: 1.4;
  word-wrap: break-word;
}

.ec-metadata-value.large {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}

.ec-metadata-badges {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.ec-badge {
  display: inline-block;
  padding: 2px 6px;
  font-size: 8px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border: 1px solid var(--border);
  font-family: var(--font-family-ui);
}

.ec-badge.explicit {
  background: var(--text);
  color: var(--bg);
}

.ec-badge.lyrics {
  background: var(--text);
  color: var(--bg);
}

.ec-metadata-link {
  display: inline-block;
  margin-top: 8px;
  padding: 5px 12px;
  background: var(--bg);
  color: var(--bg);
  text-decoration: none;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3px;
  font-family: var(--font-family-ui);
  border: 1px solid var(--border);
}

.ec-metadata-link:hover {
  background: var(--accent);
}

/* Keyboard Navigation Indicators */
.ec-playlist-row:focus,
.ec-track-row:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Table row transitions - Keep it reactive */
.ec-playlist-row,
.ec-track-row {
  transition: background-color 0.05s ease;
}

/* User selection styling */
.ec-playlist-row::selection,
.ec-track-row::selection,
.ec-playlist-name::selection,
.ec-track-title::selection {
  background: var(--highlight);
  color: var(--text);
}

/* Scrollbar Styling - Minimal Flat */
.ec-column-content::-webkit-scrollbar {
  width: 12px;
  background: var(--bg);
}

.ec-column-content::-webkit-scrollbar-track {
  background: var(--bg);
  border-left: 1px solid var(--border);
}

.ec-column-content::-webkit-scrollbar-thumb {
  background: var(--text);
  border: 1px solid var(--border);
  min-height: 40px;
}

.ec-column-content::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

.ec-column-content::-webkit-scrollbar-thumb:active {
  background: var(--accent);
}

/* Responsive Design - Single breakpoint at 1400px */
@media (max-width: 1400px) {
  /* Stack controls vertically */
  .ec-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    min-height: auto;
  }
  
  /* Order: stats on top, controls-left below, player at bottom */
  .ec-stats {
    order: 1;
    justify-content: center;
    text-align: center;
  }
  
  .ec-controls-left {
    width: 100%;
    grid-template-columns: auto 1fr auto auto;
    order: 2;
  }
  
  .ec-player {
    width: 100%;
    height: auto;
    min-height: 68px;
    justify-content: center;
    margin: 0 auto;
    order: 3;
  }
  
  .ec-player-track-info {
    width: 200px;
  }
  
  @keyframes scroll-text {
    0% {
      transform: translateX(0);
    }
    15% {
      transform: translateX(0);
    }
    85% {
      transform: translateX(calc(-100% + 200px));
    }
    100% {
      transform: translateX(calc(-100% + 200px));
    }
  }
}

/* Loading Animation - VSCode Spinner */
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.ec-loading {
  animation: spin 1s linear infinite;
  color: var(--vsc-blue);
}
