/* =============================================
   MultiStream — style.css
   ============================================= */

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

:root {
  --purple: #9147ff;
  --purple-dark: #7b2ff7;
  --purple-dim: #1a1230;
  --bg-app: #0d0d0d;
  --bg-bar: #1a1a1a;
  --bg-card: #111;
  --bg-input: #2a2a2a;
  --border: #333;
  --border-mid: #444;
  --text: #ffffff;
  --text-muted: #888;
  --text-faint: #555;
  --red: #e24b4a;
  --radius: 8px;
  --radius-sm: 6px;
  --gap: 4px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-app);
  color: var(--text);
  overflow: hidden;
}

/* ── APP LAYOUT ── */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

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

/* ── TOOLBAR ── */
.toolbar {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--bg-bar);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 46px;
}

.logo {
  font-weight: 600;
  font-size: 15px;
  color: var(--purple);
  white-space: nowrap;
  margin-right: 4px;
  letter-spacing: -0.3px;
  text-decoration: none;
  cursor: pointer;
}
.logo:hover { color: var(--purple-dark); }

/* ── FORM AJOUT ── */
.add-form {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.add-form input {
  background: var(--bg-input);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0 10px;
  font-size: 13px;
  height: 32px;
  outline: none;
  transition: border-color 0.15s, width 0.25s ease;
  flex-shrink: 0;
}
.add-form input::placeholder { color: #555; }
.add-form input:focus { border-color: var(--purple); }
.add-form input.error { border-color: var(--red); }

/* ── BOUTONS ── */
.btn {
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius);
  border: 1px solid #555;
  background: var(--bg-input);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s;
}

.btn:hover { background: #333; }
.btn:active { transform: scale(0.98); }

.btn.purple {
  background: var(--purple);
  border-color: var(--purple);
  color: #fff;
}
.btn.purple:hover { background: var(--purple-dark); border-color: var(--purple-dark); }

.btn.danger { border-color: var(--red); color: var(--red); }
.btn.danger:hover { background: #2a1515; }

.btn.chat-active { border-color: var(--purple); color: var(--purple); }

.status { font-size: 12px; color: var(--text-faint); white-space: nowrap; }

/* ── BOUTON MASQUER / AFFICHER LE BANDEAU ── */
.btn-hide-toolbar {
  margin-left: auto;
  flex-shrink: 0;
  border-color: transparent;
  color: var(--text-faint);
}
.btn-hide-toolbar:hover { color: var(--text); border-color: var(--border-mid); }

.toolbar.hidden { display: none !important; }

.show-toolbar-btn {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  height: 22px;
  padding: 0 20px;
  background: var(--bg-bar);
  border: 1px solid var(--border-mid);
  border-top: none;
  border-radius: 0 0 8px 8px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: background 0.12s, color 0.12s;
}
.show-toolbar-btn:hover { background: #2a2a2a; color: var(--text); }
.show-toolbar-btn.hidden { display: none !important; }

/* ── ZONE STREAMS ── */
.streams-area {
  flex: 1;
  overflow: hidden;
  padding: var(--gap);
  display: flex;
  flex-direction: column;
}

#gridContainer {
  flex: 1;
  min-height: 0;
  min-width: 0;
  height: 100%;
}

#cellPool {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  width: 100%;
  height: 100%;
}

.streams-area {
  flex: 1;
  overflow: hidden;
  padding: var(--gap);
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

/* ── CELLULE STREAM ── */
.stream-cell {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  min-width: 0;
  min-height: 0;
  transition: border-color 0.15s, box-shadow 0.15s, opacity 0.15s, transform 0.15s;
}

.stream-cell:hover { border-color: #555; }
.stream-cell.active-chat { border-color: var(--purple); box-shadow: 0 0 0 1px var(--purple); }

/* Drag & Drop */
.stream-cell.dragging { opacity: 0.35; transform: scale(0.97); }
.stream-cell.drag-over { border-color: var(--purple); border-style: dashed; border-width: 2px; background: #16082a; }

.stream-cell iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ── OVERLAY CELLULE ── */
.cell-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 6px;
  pointer-events: none;
}

.cell-top {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

.cell-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

.stream-cell:hover .cell-top,
.stream-cell:hover .cell-bottom {
  opacity: 1;
  pointer-events: auto;
}

/* Les boutons de l'overlay sont au-dessus de tout, y compris
   la page de fin de stream Twitch */
.cell-top button { position: relative; z-index: 10; }

.cell-top button,
.cell-bottom button { pointer-events: auto; }

.drag-handle { pointer-events: auto; }

/* Poignée de déplacement */
.drag-handle {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 6;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: rgba(0,0,0,0.72);
  border: 1px solid rgba(255,255,255,0.12);
  color: #aaa;
  cursor: grab;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}
.drag-handle:active { cursor: grabbing; }
.stream-cell:hover .drag-handle { opacity: 1; }

/* Boutons dans la cellule */
.cell-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: rgba(0,0,0,0.75);
  border: 1px solid rgba(255,255,255,0.18);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, border-color 0.12s;
}
.cell-btn:hover { background: rgba(100,50,200,0.85); border-color: var(--purple); }
.cell-btn.close:hover { background: rgba(180,40,40,0.85); border-color: var(--red); }
.cell-btn.cell-btn-chat-active { background: rgba(145,71,255,0.5); border-color: var(--purple); }

.cell-label {
  font-size: 11px;
  background: rgba(0,0,0,0.68);
  padding: 2px 8px;
  border-radius: 4px;
  color: #ccc;
}

.click-hint {
  font-size: 10px;
  color: rgba(255,255,255,0.3);
  padding: 2px 6px;
}

/* ── ÉCRAN DE DÉMARRAGE ── */
.start-screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(13,13,13,0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  border-radius: var(--radius-sm);
}
.start-icon {
  font-size: 40px;
  color: var(--purple);
  opacity: 0.6;
}
.start-screen p {
  font-size: 14px;
  color: #888;
}
.start-btn {
  height: 42px;
  padding: 0 28px;
  font-size: 14px;
  gap: 8px;
}

/* ── TAGS STREAMS ── */
.stream-tags {
  display: flex;
  flex-wrap: nowrap;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  height: 32px;
}
.stream-tags:empty { flex: 1; }

.stream-tag {
  display: flex;
  flex-direction: row;
  flex-shrink: 1;
  min-width: 40px;
  align-items: center;
  gap: 4px;
  padding: 2px 6px 2px 9px;
  background: var(--bg-input);
  border: 1px solid var(--border-mid);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: default;
  transition: border-color 0.12s;
}
.stream-tag:hover { border-color: var(--purple); color: var(--text); }
.stream-tag.active-tag { border-color: var(--purple); color: var(--purple); }

.stream-tag-name {
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.stream-tag-name:hover { text-decoration: underline; }

.stream-tag-edit {
  background: transparent;
  border: none;
  outline: none;
  color: var(--purple);
  font-size: 12px;
  width: 80px;
  padding: 0;
}

.stream-tag-close {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  padding: 0;
  flex-shrink: 0;
}
.stream-tag-close:hover { background: var(--red); color: #fff; }
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 14px;
  color: var(--text-faint);
  padding: 2rem;
  text-align: center;
}

.empty-icon {
  font-size: 48px;
  color: var(--purple);
  opacity: 0.3;
}

.empty p {
  font-size: 14px;
  line-height: 1.7;
  color: #555;
}

.empty p strong { color: var(--purple); }

.empty-sub {
  font-size: 12px !important;
  color: #3a3a3a !important;
  margin-top: -6px;
}

.suggestions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
}

.suggestion {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 20px;
  background: #1e1e1e;
  border: 1px solid var(--border-mid);
  color: #888;
  cursor: pointer;
  transition: all 0.12s;
}
.suggestion:hover { border-color: var(--purple); color: var(--purple); background: var(--purple-dim); }

/* ── PANNEAU CHAT ── */
/* ── RESIZE CHAT ── */
.chat-resizer {
  width: 5px;
  flex-shrink: 0;
  background: transparent;
  cursor: ew-resize;
  position: relative;
  transition: background 0.15s;
}
.chat-resizer:hover, .chat-resizer:active { background: var(--purple); }
.chat-resizer.hidden { display: none; }

.chat-panel {
  width: 280px;
  min-width: 180px;
  max-width: 600px;
  background: var(--bg-bar);
  border-left: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-panel.hidden { display: none; }

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--purple);
  display: flex;
  align-items: center;
  gap: 7px;
}

.chat-actions { display: flex; gap: 4px; }

.chat-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-mid);
  color: #888;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
}
.chat-btn:hover { background: #333; color: var(--text); border-color: var(--purple); }

.chat-tabs {
  display: flex;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-tab {
  padding: 7px 12px;
  font-size: 12px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  color: #666;
  transition: color 0.12s, border-color 0.12s;
}
.chat-tab:hover { color: #aaa; }
.chat-tab.active { color: var(--purple); border-bottom-color: var(--purple); }

.chat-frame {
  flex: 1;
  overflow: hidden;
}

.chat-frame iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* ── SCROLLBARS MINIMALISTES ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ── RESPONSIVE BASIQUE ── */
@media (max-width: 700px) {
  .logo { display: none; }
  .layout-info { display: none; }
  .chat-panel { width: 220px; }
}
