/* ============================================================
   Media Designer Portal — Styles (formerly Sound Designer)
   Matches portal dark theme: #0a0a0a bg, #33ff33 phosphor accent,
   #ff9933 orange accent for interactive elements.
   ============================================================ */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  background: #0a0a0a;
  color: #e0e0e0;
  overflow: hidden;
}

/* ---- Layout Shell ---- */

.portal-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.portal-header {
  background: #1a1a2e;
  padding: 12px 20px;
  border-bottom: 2px solid #33ff33;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.portal-header h1 {
  color: #33ff33;
  font-size: 20px;
  text-shadow: 0 0 10px #33ff33;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.portal-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ---- Buttons ---- */

.btn-primary {
  background: #33ff33;
  color: #000;
  border: none;
  padding: 8px 16px;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
  border-radius: 2px;
}
.btn-primary:hover { background: #5fff5f; }

.btn-secondary {
  background: #222;
  color: #e0e0e0;
  border: 1px solid #555;
  padding: 8px 16px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 2px;
}
.btn-secondary:hover { background: #333; }

.btn-danger {
  background: #661111;
  color: #ff4444;
  border: 1px solid #ff4444;
  padding: 6px 12px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 2px;
}
.btn-danger:hover { background: #881111; }

.btn-small {
  padding: 4px 10px;
  font-size: 12px;
}

/* ---- Left Panel: Sound Library ---- */

.sound-library {
  width: 250px;
  background: #111;
  border-right: 1px solid #333;
  padding: 0;
  overflow-y: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sound-library h2 {
  color: #33ff33;
  font-size: 14px;
  padding: 12px 14px 8px;
  border-bottom: 1px solid #333;
}

.library-search {
  padding: 8px 12px;
  border-bottom: 1px solid #333;
}

.library-search input {
  width: 100%;
  background: #1a1a1a;
  border: 1px solid #444;
  color: #e0e0e0;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 12px;
  border-radius: 2px;
}
.library-search input:focus {
  outline: none;
  border-color: #ff9933;
}

.category-section {
  border-bottom: 1px solid #222;
}

.category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  cursor: pointer;
  color: #ff9933;
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  user-select: none;
}
.category-header:hover { background: #1a1a1a; }

.category-header .count {
  color: #666;
  font-weight: normal;
  font-size: 11px;
}

.category-header .chevron {
  transition: transform 0.15s;
  color: #666;
}
.category-header.collapsed .chevron {
  transform: rotate(-90deg);
}

.category-items {
  max-height: 5000px;  /* large enough for 103+ items; overflow scrolls if needed */
  overflow-y: auto;
  transition: max-height 0.3s ease;
}
.category-items.collapsed {
  max-height: 0;
  overflow: hidden;
}

.sound-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px 5px 24px;
  cursor: pointer;
  font-size: 12px;
  color: #ccc;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.sound-item:hover { background: #1a1a2e; color: #fff; }
.sound-item.selected { background: #1a2a1a; color: #33ff33; }

.sound-item .mini-play {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: #666;
}
.sound-item:hover .mini-play { color: #33ff33; }

/* ---- Center Panel ---- */

.center-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* -- Tab Bar -- */
.center-tabs {
  display: flex;
  background: #1a1a1a;
  border-bottom: 1px solid #333;
  flex-shrink: 0;
}

.center-tab {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #888;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
.center-tab:hover { color: #ccc; }
.center-tab.active {
  color: #ff9933;
  border-bottom-color: #ff9933;
}

/* -- Tab Panels -- */
.tab-panel {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.tab-panel.active { display: flex; flex-direction: column; gap: 16px; }

/* -- Preview Section -- */
.preview-card {
  background: #151515;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 16px;
}

.preview-card h3 {
  color: #33ff33;
  font-size: 13px;
  margin-bottom: 12px;
}

.waveform-area {
  height: 80px;
  background: #0a0a0a;
  border: 1px solid #222;
  border-radius: 2px;
  position: relative;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.waveform-area canvas {
  width: 100%;
  height: 100%;
}

.waveform-placeholder {
  color: #444;
  font-size: 12px;
}

.preview-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.preview-play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #33ff33;
  color: #000;
  border: none;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-play-btn:hover { background: #5fff5f; }

.preview-info {
  flex: 1;
}
.preview-info .name { color: #fff; font-size: 14px; }
.preview-info .meta { color: #666; font-size: 11px; margin-top: 2px; }

.preview-volume {
  width: 80px;
}
.preview-volume input[type="range"] {
  width: 100%;
  accent-color: #33ff33;
}

/* -- Assignment Section -- */
.assignment-section {
  background: #151515;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 16px;
}

.assignment-section h3 {
  color: #ff9933;
  font-size: 13px;
  margin-bottom: 12px;
}

.assignment-context-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.ctx-tab {
  padding: 6px 14px;
  background: #222;
  border: 1px solid #444;
  color: #aaa;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  border-radius: 2px;
}
.ctx-tab:hover { border-color: #ff9933; color: #fff; }
.ctx-tab.active {
  background: #2a1a00;
  border-color: #ff9933;
  color: #ff9933;
}

.assignment-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.assign-slot {
  background: #1a1a1a;
  border: 1px dashed #444;
  border-radius: 3px;
  padding: 10px;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.assign-slot .slot-label {
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.assign-slot .slot-value {
  font-size: 13px;
  color: #33ff33;
}

.assign-slot .slot-empty {
  font-size: 12px;
  color: #444;
  font-style: italic;
}

.assign-slot .slot-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.slot-btn {
  padding: 3px 8px;
  font-size: 11px;
  font-family: inherit;
  background: #222;
  border: 1px solid #555;
  color: #ccc;
  cursor: pointer;
  border-radius: 2px;
}
.slot-btn:hover { border-color: #ff9933; }
.slot-btn.remove { color: #ff4444; border-color: #ff4444; }

/* -- Upload Section -- */
.upload-section {
  background: #151515;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 16px;
}

.upload-section h3 {
  color: #ff9933;
  font-size: 13px;
  margin-bottom: 12px;
}

.upload-dropzone {
  border: 2px dashed #444;
  border-radius: 4px;
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.upload-dropzone:hover,
.upload-dropzone.drag-over {
  border-color: #ff9933;
  background: #1a1500;
}

.upload-dropzone .drop-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.upload-dropzone .drop-text {
  color: #888;
  font-size: 13px;
}

.upload-dropzone .drop-hint {
  color: #555;
  font-size: 11px;
  margin-top: 6px;
}

.upload-queue {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upload-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #1a1a1a;
  padding: 8px 12px;
  border-radius: 3px;
  border: 1px solid #333;
}

.upload-item .file-name {
  flex: 1;
  font-size: 12px;
  color: #ccc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-item .file-size {
  color: #666;
  font-size: 11px;
  flex-shrink: 0;
}

.upload-item .progress-bar {
  width: 80px;
  height: 6px;
  background: #222;
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}

.upload-item .progress-fill {
  height: 100%;
  background: #33ff33;
  border-radius: 3px;
  transition: width 0.2s;
}

.upload-item .status {
  font-size: 11px;
  flex-shrink: 0;
}
.upload-item .status.done { color: #33ff33; }
.upload-item .status.error { color: #ff4444; }

.upload-controls {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.upload-dest-select {
  background: #1a1a1a;
  border: 1px solid #444;
  color: #e0e0e0;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 12px;
  border-radius: 2px;
  flex: 1;
}
.upload-dest-select:focus { outline: none; border-color: #ff9933; }

/* ---- Right Panel: Inspector ---- */

.inspector-panel {
  width: 260px;
  background: #111;
  border-left: 1px solid #333;
  padding: 0;
  overflow-y: auto;
  flex-shrink: 0;
}

.inspector-panel h2 {
  color: #33ff33;
  font-size: 14px;
  padding: 12px 14px 8px;
  border-bottom: 1px solid #333;
}

.inspector-section {
  padding: 12px 14px;
  border-bottom: 1px solid #222;
}

.inspector-section h4 {
  color: #ff9933;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.inspector-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 12px;
}

.inspector-row .label { color: #888; }
.inspector-row .value { color: #e0e0e0; }

.inspector-field {
  margin-bottom: 10px;
}

.inspector-field label {
  display: block;
  color: #888;
  font-size: 11px;
  margin-bottom: 4px;
}

.inspector-field input,
.inspector-field select,
.inspector-field textarea {
  width: 100%;
  background: #1a1a1a;
  border: 1px solid #444;
  color: #e0e0e0;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 12px;
  border-radius: 2px;
}
.inspector-field input:focus,
.inspector-field select:focus,
.inspector-field textarea:focus {
  outline: none;
  border-color: #ff9933;
}

.inspector-field textarea {
  resize: vertical;
  min-height: 60px;
}

.assignment-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.assignment-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 3px;
  padding: 6px 10px;
  font-size: 11px;
}

.assignment-chip .chip-label { color: #ccc; }
.assignment-chip .chip-context { color: #ff9933; font-size: 10px; }
.assignment-chip .chip-remove {
  color: #666;
  cursor: pointer;
  background: none;
  border: none;
  font-size: 14px;
  line-height: 1;
}
.assignment-chip .chip-remove:hover { color: #ff4444; }

/* ---- Empty States ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: #444;
  text-align: center;
  gap: 8px;
}
.empty-state .empty-icon { font-size: 40px; }
.empty-state .empty-text { font-size: 13px; }

/* ---- Status Toast ---- */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #1a1a2e;
  border: 1px solid #33ff33;
  color: #33ff33;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 13px;
  border-radius: 3px;
  z-index: 1000;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.toast.visible {
  opacity: 1;
  transform: translateY(0);
}
.toast.error {
  border-color: #ff4444;
  color: #ff4444;
}

/* ---- Sort Dropdown ---- */
.library-sort {
  padding: 8px 12px 0;
}
.library-sort select {
  width: 100%;
  background: #1a1a1a;
  border: 1px solid #444;
  color: #e0e0e0;
  padding: 5px 8px;
  font-family: inherit;
  font-size: 11px;
  border-radius: 2px;
}
.library-sort select:focus {
  outline: none;
  border-color: #ff9933;
}

/* ---- Inspector Actions ---- */
.inspector-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.missing-warning {
  background: #331111;
  border: 1px solid #ff4444;
  color: #ff4444;
  font-size: 11px;
  padding: 6px 8px;
  border-radius: 2px;
  margin-top: 6px;
}

/* ---- Delete Marking ---- */
.sound-item.marked-for-deletion {
  text-decoration: line-through;
  opacity: 0.5;
  background: rgba(255, 68, 68, 0.08);
}
.sound-item.marked-for-deletion:hover {
  opacity: 0.7;
}

/* ---- Missing Asset Flag ---- */
.sound-item.missing-asset {
  border-left: 3px solid #ff4444;
  position: relative;
}
.sound-item.missing-asset::after {
  content: '⚠️';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-content {
  background: #1a1a2e;
  border: 1px solid #33ff33;
  border-radius: 4px;
  padding: 24px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-content h3 {
  color: #33ff33;
  font-size: 16px;
  margin-bottom: 16px;
}
#modal-body {
  color: #ccc;
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 20px;
}
#modal-body .gap-broken {
  color: #ff4444;
  margin-bottom: 8px;
}
#modal-body .gap-orphan {
  color: #ff9933;
  margin-bottom: 8px;
}
#modal-body .gap-summary {
  color: #33ff33;
  font-weight: bold;
  margin-top: 12px;
}
#modal-body .delete-list {
  max-height: 200px;
  overflow-y: auto;
  background: #111;
  border: 1px solid #333;
  border-radius: 2px;
  padding: 8px;
  margin: 8px 0;
  font-size: 12px;
}
#modal-body .delete-list div {
  padding: 2px 0;
  color: #ff4444;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ---- Video library items ---- */
.video-item {
  border-left: 3px solid #e91e63 !important;
}
.video-item.selected {
  background: rgba(233, 30, 99, 0.2) !important;
  border-color: #e91e63 !important;
}
.video-item:hover {
  background: rgba(233, 30, 99, 0.15) !important;
}
#video-library-section .category-header span:first-child {
  color: #e91e63;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #0a0a0a; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ── Mobile: Portrait (< 768px) ── */
@media (max-width: 767px) {
  .portal-header h1 { font-size: 14px; }
  .header-actions { flex-wrap: wrap; gap: 4px; }
  .header-actions button { font-size: 11px; padding: 4px 8px; }

  .portal-main {
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .sound-library {
    width: 100% !important;
    max-width: 100%;
    flex-shrink: 1;
    max-height: 45vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-right: none;
    border-bottom: 1px solid #333;
  }

  .sound-library.collapsed {
    max-height: 44px;
    overflow: hidden;
  }

  .sound-library.collapsed .library-sort,
  .sound-library.collapsed .library-search,
  .sound-library.collapsed #library-categories {
    display: none;
  }

  .sound-library h2 {
    cursor: pointer;
    position: relative;
    padding-right: 30px;
  }

  .sound-library h2::after {
    content: '▾';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: #888;
    transition: transform 0.2s;
  }

  .sound-library.collapsed h2::after {
    transform: translateY(-50%) rotate(-90deg);
  }

  .center-panel {
    min-height: 40vh;
    flex: 1;
  }

  .inspector-panel {
    width: 100% !important;
    max-width: 100%;
    border-left: none;
    border-top: 1px solid #333;
    max-height: 50vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .category-items { max-height: 200px; overflow-y: auto; }

  /* Upload dropzone touch-friendly */
  .upload-dropzone { padding: 20px 12px; }
  .drop-hint { font-size: 10px; }
}

/* ── Mobile: Landscape & small tablets (768-1024px) ── */
@media (min-width: 768px) and (max-width: 1024px) {
  .sound-library { width: 200px; }
  .inspector-panel { width: 220px; }
}
