/* Global layout */
body {
  margin: 0;
  padding: 0;
  display: flex;
  height: 100vh;
  font-family: sans-serif;
  background: #111;
  color: #eee;
}

/* Sidebar */
#sidebar {
  width: 200px;
  background: #222;
  padding: 20px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

#sidebar h1 {
  margin: 0;
  font-size: 1.5rem
}

.menu-item label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold
}

.menu-item select {
  width: 100%;
  padding: 5px;
  background: #333;
  color: #eee;
  border: 1px solid #444;
}

.sidebar-btn {
  width: 100%;
  padding: 10px 12px;
  background: #333;
  color: #eee;
  border: 1px solid #444;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.2s, border-color 0.2s;
}

.sidebar-btn:hover {
  background: #444;
  border-color: #666;
}

/* Compteur temps écoulé / restant (bas de la sidebar) */
.sidebar-time-counter {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid #444;
  font-size: 0.9rem;
  color: #aaa;
}

.sidebar-time-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.sidebar-time-row:last-child {
  margin-bottom: 0;
}

.sidebar-time-label {
  font-weight: 600;
  color: #888;
}

#sidebarTimeElapsed,
#sidebarTimeRemaining,
#sidebarTimeDuration {
  font-variant-numeric: tabular-nums;
  color: #ccc;
}

/* Main area */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Editor area */
#editorArea {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Viewer container */
#viewerContainer {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000;
}



/* Audio panel */
#audioTracks {
  flex: 1;
  display: none;
  flex-direction: column;
  background: #222;
  padding: 10px;
  box-sizing: border-box;
  overflow-y: auto;
  transition: flex 0.5s ease;
}

body[data-mode="edition"] #audioTracks {
  display: flex
}

/* Preview button */
#previewAudio {
  display: none;
  margin-bottom: 8px;
  padding: 6px 12px;
  background: #444;
  border: none;
  color: #fff;
  cursor: pointer;
}

body[data-mode="edition"] #previewAudio {
  display: inline-block
}

/* Track styling */
.track-container {
  margin-bottom: 8px;
  transition: background 0.3s ease;
}

.track-container:hover {
  background: rgba(255, 255, 255, 0.05)
}

.track-label {
  display: block;
  color: #ccc;
  margin-bottom: 4px;
}

.track-list {
  display: flex;
  gap: 5px;
  min-height: 40px;
  padding: 5px;
  background: #111;
  border: 1px solid #444;
  transition: background 0.2s ease;
}

.track-list.drag-over {
  background: #333
}

/* Controls */
#controls {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 5px;
  background: rgba(0, 0, 0, 0.5);
}

#controls button,
#controls select {
  background: transparent;
  border: 1.5px solid #eee;
  color: #eee;
  padding: 12px 22px;
  font-size: 1.3em;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

/* Progress bar */
#progressContainer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 20px;
  background: #222;
}

#progress {
  flex: 1;
}

/* Thumbnails strip wrapper (for progress bar positioning) */
.thumbnails-strip {
  flex: none;
  height: 100px;
  position: relative;
  background: #222;
  border-top: 1px solid #444;
  transition: height 0.3s ease;
}

body[data-mode="edition"] .thumbnails-strip {
  height: 160px;
}

/* Thumbnails ribbon */
#thumbnails {
  position: absolute;
  inset: 0;
  display: flex;
  gap: 5px;
  padding: 5px;
  overflow-x: auto;
  overflow-y: hidden;
}

/* Fine blue progress bar above current thumbnail during play */
.thumb-play-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 4px;
  width: 80px;
  background: rgba(0, 0, 0, 0.25);
  overflow: hidden;
  pointer-events: none;
  display: none;
  z-index: 10;
  border-radius: 0 0 2px 2px;
}

.thumb-play-progress.visible {
  display: block;
}

.thumb-play-progress-fill {
  height: 100%;
  width: 0%;
  background: #22a1f0;
  border-radius: 0 0 0 2px;
  will-change: width;
}

body[data-mode="edition"] .thumb-play-progress {
  width: 120px;
}

body[data-mode="edition"] #thumbnails {
  height: 160px
}

/* Thumbnails */
.thumbnail {
  flex: 0 0 auto;
  position: relative;
  width: 80px;
  height: 80px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.3s, border-color 0.3s, box-shadow 0.3s;
}

body[data-mode="edition"] .thumbnail {
  width: 120px;
  height: 120px;
}

.thumbnail:hover,
.thumbnail.current {
  transform: scale(1.05);
  border-color: #fff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.thumbnail .caption {
  display: none;
  position: absolute;
  bottom: -18px;
  left: 0;
  width: 100%;
  text-align: center;
  font-size: 10px;
  color: #ccc;
}

body[data-mode="edition"] .thumbnail .caption {
  display: block;
}

/* Audio blocks */
.audio-block {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #444;
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: grab;
  transition: transform 0.2s, opacity 0.2s;
}

.audio-block:hover {
  transform: scale(1.05);
}

.audio-block.dragging {
  opacity: 0.6;
  transform: scale(0.95);
}

/* Hide controls in fullscreen */
#viewerContainer.fullscreen+#controls {
  display: none;
}

#exitFullscreenBtn {
  display: block;
  font-size: 3em !important;
  width: 1.5em;
  height: 1.5em;
  background: rgba(0, 0, 0, 0.40);
  color: #fff;
  border: none;
  border-radius: 50%;
  padding: 0.3em 0.45em;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.16);
  opacity: 0.20;
  transition: opacity 0.2s;
  z-index: 10010;
}

#exitFullscreenBtn:hover {
  opacity: 0.8;
}

.delete-icon {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  color: red;
  font-size: 1rem;
  line-height: 1;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10;
}

body.fullscreen-fallback {
  height: 100vh !important;
  overflow: hidden !important;
  background: #000 !important;
}

#viewerContainer.fullscreen-fallback,
canvas.fullscreen-fallback {
  width: 100vw !important;
  height: 100vh !important;
  display: block !important;
}


.desktop-overlay {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 10%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 1000;
}

.overlay-left {
  left: 0;
}

.overlay-right {
  right: 0;
}

.desktop-arrow {
  width: 48px;
  height: 48px;
  opacity: 0.20;
  transition: opacity 0.2s;
  pointer-events: none;
}

.desktop-overlay:hover .desktop-arrow {
  opacity: 0.8;
}


body.fullscreen-fallback #sidebar,
body.fullscreen-fallback #controls,
body.fullscreen-fallback #progressContainer,
body.fullscreen-fallback .thumbnails-strip,
body.fullscreen-fallback #thumbnails,
body.fullscreen-fallback #audioTracks {
  display: none !important;
}

body.fullscreen-fallback #main,
body.fullscreen-fallback #editorArea,
body.fullscreen-fallback #viewerContainer {
  width: 100vw !important;
  height: 100vh !important;
  position: fixed !important;
  left: 0;
  top: 0;
  z-index: 10000;
  background: #000 !important;
}

body.fullscreen-fallback canvas#viewer {
  width: 100vw !important;
  height: 100vh !important;
  display: block !important;
}

/* Modal Overlay */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
}

.modal-content {
  background-color: #222;
  padding: 20px;
  border-radius: 8px;
  text-align: center;
  color: #fff;
  width: 300px;
}

.progress-bar {
  background-color: #444;
  border-radius: 4px;
  overflow: hidden;
  height: 10px;
  margin-top: 20px;
}

.progress {
  background-color: #22a1f0;
  height: 100%;
  transition: width 0.2s ease;
}

/* Settings modal */
.settings-modal .modal-content {
  width: 90%;
  max-width: 420px;
  text-align: left;
  padding: 0;
  overflow: hidden;
}

.settings-modal-content {
  display: flex;
  flex-direction: column;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #444;
}

.settings-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.modal-close-btn {
  background: none;
  border: none;
  color: #aaa;
  font-size: 1.75rem;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
}

.modal-close-btn:hover {
  color: #fff;
  background: #444;
}

.settings-body {
  padding: 20px;
}

.setting-row {
  margin-bottom: 16px;
}

.setting-row:last-child {
  margin-bottom: 0;
}

.setting-row label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: #eee;
}

.setting-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.setting-input-group input[type="number"] {
  width: 80px;
  padding: 8px 10px;
  background: #333;
  color: #eee;
  border: 1px solid #444;
  border-radius: 6px;
  font-size: 1rem;
}

.setting-input-group input[type="number"]:focus {
  outline: none;
  border-color: #22a1f0;
}

.setting-unit {
  color: #999;
  font-size: 0.95rem;
}

.setting-hint {
  margin: 0;
  font-size: 0.85rem;
  color: #999;
  line-height: 1.4;
}

.settings-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 16px 20px;
  border-top: 1px solid #444;
  background: #1a1a1a;
}

.settings-footer .btn-primary,
.settings-footer .btn-secondary {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.95rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.2s, border-color 0.2s;
}

.settings-footer .btn-primary {
  background: #22a1f0;
  color: #fff;
  border-color: #1a8ad4;
}

.settings-footer .btn-primary:hover {
  background: #1a8ad4;
}

.settings-footer .btn-secondary {
  background: #333;
  color: #eee;
  border-color: #555;
}

.settings-footer .btn-secondary:hover {
  background: #444;
}


.thumbnail-drop-indicator {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 6px;
  background: #22a1f0;
  opacity: 0.8;
  border-radius: 3px;
  transition: left 0.1s;
  z-index: 20;
}

body[data-mode="edition"] .thumbnail {
  cursor: grab;
}

body[data-mode="edition"] .thumbnail.dragging {
  cursor: grabbing;
  opacity: 0.6;
  box-shadow: 0 0 12px #22a1f0;
}

body[data-mode="edition"] .thumbnail::before {
  content: "≡";
  font-size: 1.2em;
  color: #22a1f0;
  position: absolute;
  left: 6px;
  top: 6px;
  opacity: 0.7;
  pointer-events: none;
}

body[data-mode="edition"] .thumbnail {
  position: relative;
}

body[data-mode="edition"] .thumbnail {
  cursor: grab;
}

body[data-mode="edition"] .thumbnail.dragging {
  cursor: grabbing;
  opacity: 0.6;
  box-shadow: 0 0 12px #22a1f0;
}
/* États et adaptation aux petits écrans */
[hidden] { display: none !important; }
.tagline { margin: -10px 0 0; font-size: .82rem; color: #aaa; line-height: 1.45; }
#sidebar h1 { font-size: 1.35rem; overflow-wrap: anywhere; }
#sidebar .menu-item { display: grid; gap: 8px; }
#viewer { display: block; touch-action: none; }
#settingsModal { display: flex; }
.thumbnail { padding: 0; background: #333; }
.thumbnail canvas { max-width: 100%; max-height: 100%; }
.thumbnail.active { border-color: #22a1f0; }
:focus-visible { outline: 3px solid #22a1f0; outline-offset: 3px; }
.upload-label { display: grid; gap: 6px; font-size: .85rem; }
.upload-label input { max-width: 100%; }
.desktop-overlay { padding: 0; }
@media (max-width: 760px) {
  body { height: 100dvh; flex-direction: column; }
  #sidebar { width: 100%; padding: 10px 12px; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
  #sidebar h1 { margin: 0; font-size: 1.15rem; }
  .tagline, .sidebar-time-counter { display: none; }
  #sidebar .menu-item { min-width: 0; flex: 1 1 120px; gap: 4px; }
  #sidebar .menu-item label { font-size: .8rem; margin: 0; }
  #sidebar .menu-item:last-of-type { flex-basis: 100%; display: flex; }
  .sidebar-btn { padding: 6px; font-size: .8rem; }
  #main { min-height: 0; width: 100%; }
  #controls { gap: 6px; }
  #controls button { padding: 8px 12px; font-size: 1rem; }
  #controls #shareBtn { font-size: .8rem; }
  #editorArea { flex-direction: column; }
  #viewerContainer { min-height: 120px; }
  #audioTracks { flex: 0 0 150px; }
  .thumbnails-strip { height: 86px; }
}
