/* Palette DeckPuls (alignée sur le site deckpuls.com) */
:root {
  --bg: #0c0e12;
  --bg-elevated: #14171e;
  --surface: #1a1d26;
  --border: #2a2e3a;
  --text: #e6e8ec;
  --text-muted: #8b92a0;
  --accent: #F5A623;
  --accent-hover: #f7b84d;
  --radius: 12px;
  --font: 'Outfit', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; height: 100%; }
#app { min-height: 100vh; height: 100%; width: 100%; }

/* Login */
#login-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  padding: 1rem;
}
.login-box { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; width: 100%; max-width: 360px; box-shadow: 0 4px 24px rgba(0,0,0,0.3); }
.login-box h1 { font-size: 1.35rem; margin-bottom: 0.25rem; }
.login-box h2 { font-size: 1.15rem; margin-bottom: 1rem; }
.subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.5rem; }
.login-box input { width: 100%; padding: 0.75rem; margin-bottom: 0.75rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 1rem; }
.login-box input::placeholder { color: var(--text-muted); }
.login-box button { width: 100%; padding: 0.75rem; margin-top: 0.5rem; background: var(--accent); color: #0c0e12; border: none; border-radius: 8px; font-size: 1rem; font-weight: 600; cursor: pointer; }
.login-box button:hover { background: var(--accent-hover); }
.login-box .error { color: #f87171; font-size: 0.85rem; margin-top: 0.5rem; min-height: 1.2em; }
.login-box .small { margin-top: 1rem; font-size: 0.85rem; }
.login-box .small a { color: var(--accent); text-decoration: none; }
.login-box .small a:hover { color: var(--accent-hover); text-decoration: underline; }

/* Dashboard layout */
#dashboard-view { display: flex; flex-direction: column; min-height: 100vh; }
.header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.5rem; background: var(--bg-elevated); border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: 0.5rem; }
.header-brand { display: flex; align-items: center; gap: 0.5rem; }
.header-brand .brand-name { font-weight: 700; font-size: 1.15rem; color: var(--accent); }
.header-brand .header-sep { color: var(--text-muted); font-weight: 400; }
.header-brand .header-title { font-size: 1.1rem; font-weight: 600; margin: 0; }
.user { color: var(--text-muted); font-size: 0.9rem; }
.header-link { color: var(--accent); text-decoration: none; font-size: 0.9rem; }
.header-link:hover { color: var(--accent-hover); text-decoration: underline; }
.btn-logout { padding: 0.4rem 0.8rem; background: transparent; border: 1px solid var(--border); color: var(--text-muted); border-radius: 6px; cursor: pointer; font-size: 0.9rem; }
.btn-logout:hover { background: var(--surface); color: var(--text); }

.nav-wrap { position: relative; background: var(--bg-elevated); border-bottom: 1px solid var(--border); }
.nav { display: flex; gap: 0; padding: 0 1.5rem; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav-link { padding: 0.75rem 1.1rem; color: var(--text-muted); text-decoration: none; font-size: 0.9rem; border-bottom: 2px solid transparent; white-space: nowrap; flex-shrink: 0; }
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Flèches de défilement nav (mobile) */
.nav-scroll-arrow {
  display: none;
  position: absolute; top: 0; bottom: 0;
  width: 2.5rem;
  align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 700;
  color: var(--accent);
  pointer-events: none;
  transition: opacity 0.2s;
}
.nav-scroll-right { right: 0; background: linear-gradient(to right, transparent, var(--bg-elevated) 65%); }
.nav-scroll-left  { left: 0;  background: linear-gradient(to left,  transparent, var(--bg-elevated) 65%); }
.nav-scroll-arrow.hidden { opacity: 0; }

.main { flex: 1; padding: 1.5rem; max-width: 900px; margin: 0 auto; width: 100%; }
.section { display: none; }
.section.active { display: block; }
.section h2 { font-size: 1.2rem; margin-bottom: 0.5rem; }
.section h3 { font-size: 1rem; margin: 1rem 0 0.5rem; }
.section p, .section .meta { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1rem; }

.form-inline { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 1rem; }
.form-inline input { padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font-size: 0.95rem; }
.form-inline input[type="text"] { width: 120px; }
.form-inline button { padding: 0.5rem 1rem; background: var(--accent); color: #0c0e12; border: none; border-radius: 6px; font-weight: 600; cursor: pointer; font-size: 0.95rem; }
.form-inline button:hover { background: var(--accent-hover); }

.form-stack { margin-bottom: 1rem; }
.form-stack input { padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font-size: 0.95rem; width: 100%; max-width: 320px; margin-right: 0.5rem; margin-bottom: 0.5rem; }
.form-stack button { padding: 0.5rem 1rem; background: var(--accent); color: #0c0e12; border: none; border-radius: 6px; font-weight: 600; cursor: pointer; font-size: 0.95rem; }
.form-stack button:hover { background: var(--accent-hover); }

.upload-form { margin-bottom: 1rem; display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.upload-form input[type="file"] { font-size: 0.9rem; }
.upload-form button { padding: 0.5rem 1rem; background: var(--accent); color: #0c0e12; border: none; border-radius: 6px; font-weight: 600; cursor: pointer; }
.upload-form button:hover { background: var(--accent-hover); }

.message { min-height: 1.5em; font-size: 0.9rem; }
.message.success { color: #34d399; }
.message.error { color: #f87171; }

.card-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.card h4 { font-size: 0.95rem; margin-bottom: 0.25rem; }
.card .meta { color: var(--text-muted); font-size: 0.8rem; }
.card .actions { margin-top: 0.75rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.card .actions button { padding: 0.35rem 0.65rem; font-size: 0.8rem; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
.card .actions button:hover { background: var(--border); }
.card .actions button.primary { background: var(--accent); color: #0c0e12; border-color: var(--accent); }
.card .actions button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-manage-playlist { display: inline-block; margin-top: 0.5rem; margin-right: 0.25rem; padding: 0.4rem 0.75rem; font-size: 0.85rem; background: var(--accent); color: #0c0e12; border: none; border-radius: 6px; font-weight: 600; cursor: pointer; }
.btn-manage-playlist:hover { background: var(--accent-hover); }
.btn-delete-playlist, .btn-delete-media, .btn-delete-device { display: inline-block; margin-top: 0.5rem; padding: 0.4rem 0.75rem; font-size: 0.85rem; background: #7f1d1d; color: #fecaca; border: none; border-radius: 6px; cursor: pointer; font-weight: 500; }
.btn-delete-playlist:hover, .btn-delete-media:hover, .btn-delete-device:hover { background: #991b1b; }
.media-card .btn-delete-media { margin-top: 0.5rem; }
.device-status-online { color: #34d399; font-weight: 600; font-size: 0.85rem; }
.device-status-offline { color: var(--text-muted); font-size: 0.85rem; }

.media-card h4 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-card .thumb { width: 100%; aspect-ratio: 16/10; background: var(--surface); border-radius: 6px; object-fit: cover; margin-bottom: 0.5rem; }
.media-card .media-thumb { width: 100%; aspect-ratio: 16/10; background: var(--surface); border-radius: 6px; margin-bottom: 0.5rem; display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 0.9rem; }
.media-card .media-thumb-video { color: var(--text-muted); }
.media-card .media-thumb-video-link { position: relative; display: block; width: 100%; aspect-ratio: 16/10; background: var(--surface); border-radius: 6px; margin-bottom: 0.5rem; overflow: hidden; text-decoration: none; color: inherit; }
.media-card .media-video-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-card .media-thumb-label { position: absolute; bottom: 0; left: 0; right: 0; padding: 0.35rem 0.5rem; background: rgba(0,0,0,0.75); color: var(--text); font-size: 0.8rem; text-align: center; }

select { padding: 0.4rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font-size: 0.9rem; }
.schedule-panels { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1.25rem; margin-top: 0.5rem; }
.schedule-panel { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.schedule-panel h3 { font-size: 1rem; margin-bottom: 0.25rem; }
.schedule-panel > .meta { margin-bottom: 0.75rem; }
.schedule-form label { display: block; margin-top: 0.5rem; }
.schedule-form select, .schedule-form input[type="text"], .schedule-form input[type="number"], .schedule-form input[type="date"] { margin-bottom: 0.5rem; }
.schedule-table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.schedule-table th, .schedule-table td { padding: 0.5rem; text-align: left; border-bottom: 1px solid var(--border); }
.schedule-table .btn-delete-slot { font-size: 0.8rem; color: #f87171; background: none; border: none; cursor: pointer; }
.schedule-table .btn-delete-slot:hover { text-decoration: underline; }
.playlist-detail { margin-top: 1rem; padding: 1rem; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); }
.playlist-detail ul { list-style: none; margin: 0.5rem 0 1rem; }
.playlist-detail li { padding: 0.35rem 0; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.playlist-detail li .playlist-item-preview-wrap { flex-shrink: 0; width: 64px; height: 48px; border-radius: 6px; overflow: hidden; background: var(--surface); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; }
.playlist-detail li .playlist-item-preview { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; display: block; }
.playlist-detail li .playlist-item-preview-video { width: 100%; height: 100%; object-fit: cover; }
.playlist-detail li .playlist-item-label { flex: 1; min-width: 0; }
.playlist-detail li .playlist-item-dur-wrap { display: flex; align-items: center; gap: 0.25rem; font-size: 0.9rem; color: var(--text-muted); white-space: nowrap; }
.playlist-detail li .playlist-item-duration { width: 3.5rem; padding: 0.25rem 0.35rem; font-size: 0.9rem; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; color: var(--text); }
.playlist-detail li .playlist-item-actions { display: flex; align-items: center; gap: 0.25rem; }
.playlist-detail li .btn-move-up,
.playlist-detail li .btn-move-down { width: 2rem; padding: 0.25rem; font-size: 1rem; line-height: 1; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 4px; cursor: pointer; }
.playlist-detail li .btn-move-up:hover,
.playlist-detail li .btn-move-down:hover { background: var(--border); color: var(--accent); }
.playlist-detail li .remove-item { font-size: 0.8rem; color: #f87171; cursor: pointer; background: none; border: none; padding: 0.25rem 0.5rem; }
.playlist-detail li .remove-item:hover { text-decoration: underline; }
.playlist-detail #playlist-add-form { margin-top: 0.75rem; }
.playlist-detail #playlist-add-form label { margin-right: 0.5rem; }

/* Onglet Templates */
.templates-forms { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.template-form-card { padding: 1rem; }
.template-form-card h4 { margin-bottom: 0.75rem; font-size: 1rem; }
.template-form-card .form-stack label { display: block; margin-bottom: 0.25rem; font-size: 0.9rem; color: var(--text-muted); }
.template-form-card .form-stack input { margin-bottom: 0.75rem; width: 100%; }
.template-form-card .form-stack button { margin-top: 0.25rem; }
.template-form-card .form-stack label.checkbox-inline,
#templates-list .template-card-edit label.checkbox-inline { display: flex; align-items: center; gap: 0.5rem; flex-direction: row; max-width: 100%; }
.template-form-card .form-stack label.checkbox-inline input[type="checkbox"],
#templates-list .template-card-edit label.checkbox-inline input[type="checkbox"] { width: auto; margin: 0; max-width: none; }
#templates-list .card .meta { word-break: break-all; overflow-wrap: break-word; }
#templates-list .template-card-actions { display: block; margin-top: 0.5rem; }
#templates-list .btn-edit-template { font-size: 0.85rem; margin-right: 0.5rem; padding: 0.25rem 0.5rem; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 4px; cursor: pointer; }
#templates-list .btn-edit-template:hover { background: var(--border); }
#templates-list .btn-delete-template { font-size: 0.85rem; color: #f87171; background: none; border: none; cursor: pointer; padding: 0.25rem 0; }
#templates-list .btn-delete-template:hover { text-decoration: underline; }
#templates-list .template-card-edit .template-edit-form label { display: block; margin-top: 0.5rem; margin-bottom: 0.25rem; font-size: 0.9rem; color: var(--text-muted); }
#templates-list .template-card-edit .template-edit-form input[type="text"] { width: 100%; margin-bottom: 0.25rem; }
#templates-list .template-card-edit .template-edit-actions { display: block; margin-top: 0.75rem; }
#templates-list .template-card-edit .btn-cancel-edit-template { margin-left: 0.5rem; padding: 0.25rem 0.5rem; background: transparent; color: var(--text-muted); border: none; cursor: pointer; font-size: 0.9rem; }
#templates-list .template-card-edit .btn-cancel-edit-template:hover { color: var(--text); }

/* Phase 4 : capture écran, alertes */
.device-screenshot-wrap { width: 100%; max-width: 260px; aspect-ratio: 16/9; overflow: hidden; border-radius: 8px; border: 1px solid var(--border); margin: 0.5rem 0; display: block; background: var(--surface); }
.device-screenshot-wrap .device-screenshot-thumb { width: 100%; height: 100%; object-fit: contain; display: block; }
.device-screenshot-thumb { max-width: 200px; max-height: 120px; object-fit: contain; border-radius: 6px; border: 1px solid var(--border); margin: 0.5rem 0; display: block; }
.alert-card { border-left: 3px solid var(--border); }
.alert-card.alert-unread { border-left-color: var(--accent); }
.alert-card .btn-alert-read { margin-top: 0.5rem; padding: 0.35rem 0.65rem; font-size: 0.85rem; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
.alert-card .btn-alert-read:hover { background: var(--border); }

/* ─── Bouton secondaire générique ─── */
.btn-secondary {
  padding: 0.4rem 0.75rem; font-size: 0.85rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}
.btn-secondary:hover { background: var(--border); }

/* ─── Bouton Renommer playlist ─── */
.btn-rename-playlist {
  display: inline-block; margin-top: 0.5rem; margin-right: 0.25rem;
  padding: 0.4rem 0.75rem; font-size: 0.85rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; font-weight: 500;
}
.btn-rename-playlist:hover { background: var(--border); }

/* ─── Cartes écrans ─── */
#devices-list { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.device-card { display: flex; flex-direction: column; gap: 0; }
.device-header { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.35rem; }
.device-header h4 { margin-bottom: 0; font-size: 1rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-uuid { font-size: 0.72rem; color: var(--text-muted); word-break: break-all; line-height: 1.4; margin: 0 0 0.2rem; }
.device-heartbeat { font-size: 0.8rem; color: var(--text-muted); margin: 0 0 0.6rem; }
.device-controls {
  display: flex; flex-direction: column; gap: 0.5rem;
  padding: 0.65rem 0; border-top: 1px solid var(--border);
}
.device-control-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.ctrl-label { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; min-width: 4.5rem; }
.device-control-row label { display: flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; cursor: pointer; }
.device-footer {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
  padding-top: 0.65rem; border-top: 1px solid var(--border); margin-top: 0.1rem;
}
.device-footer .btn-delete-device { margin-top: 0; }

/* ─── Responsive mobile ─── */
@media (max-width: 640px) {
  /* Header compact sur une seule ligne */
  .header { flex-wrap: nowrap; padding: 0.65rem 0.75rem; gap: 0.5rem; }
  .header-brand .header-sep,
  .header-brand .header-title { display: none; }
  .user { display: none; }
  .header-link { font-size: 0.8rem; white-space: nowrap; }
  .btn-logout { font-size: 0.78rem; padding: 0.3rem 0.55rem; white-space: nowrap; flex-shrink: 0; }

  /* Flèches nav visibles */
  .nav-scroll-arrow { display: flex; }

  .main { padding: 1rem 0.75rem; max-width: 100%; }
  .card-list { grid-template-columns: 1fr; }
  #devices-list { grid-template-columns: 1fr; }
  .templates-forms { grid-template-columns: 1fr; }
  .form-inline { flex-direction: column; align-items: stretch; }
  .form-inline input[type="text"] { width: 100%; }
  .schedule-table { font-size: 0.8rem; }
  .schedule-table th, .schedule-table td { padding: 0.35rem 0.25rem; }
}
