/* =====================================================
   CHRONO WATCH — style.css (version corrigée)
   ===================================================== */

/* ========== VARIABLES ========== */
:root {
  --bg:            #020B1C;
  --panel:         #020B1C;
  --panel-2:       #0b1a33;
  --border:        rgba(255, 255, 255, 0.06);
  --text:          #f4f6fb;
  --text-dim:      #7c869c;
  --text-faint:    #4d5570;
  --accent-blue:   #3b5de7;
  --accent-cyan:   #33c6f4;
  --accent-pink:   #ec4899;
  --accent-purple: #7b4cf6;
  --accent-green:  #22c98a;
  --accent-orange: #f2994a;
  --accent-red:    #ef4444;
  --radius-lg:     20px;
  --radius-md:     14px;
  --radius-sm:     10px;
  --shadow:        rgba(0, 0, 0, 0.5);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ========== MODE CLAIR ========== */
body.light-mode {
  --bg:            #f0f2f8;
  --panel:         #ffffff;
  --panel-2:       #e8ebf2;
  --border:        rgba(0, 0, 0, 0.08);
  --text:          #1a1f2e;
  --text-dim:      #4a5066;
  --text-faint:    #6b7388;
  --shadow:        rgba(0, 0, 0, 0.1);
}

/* ========== RESET & BASE ========== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: radial-gradient(circle at 15% 0%, #020B1C 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}
input {
  font-family: inherit;
}

/* ========== LAYOUT ========== */
.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
  padding: 18px;
  gap: 18px;
}

/* ========== SIDEBAR ========== */
.sidebar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  transition: background 0.3s, border-color 0.3s;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px;
}
.brand-icon {
  width: 220px;
  height: 150px;
  border-radius: 12px;
  background: transparent;
  padding: 4px;
  object-fit: contain;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}
.nav-item.is-active {
  background: linear-gradient(135deg, var(--accent-blue), #6f5bf0);
  color: #fff;
  box-shadow: 0 6px 18px -6px rgba(79, 109, 247, 0.6);
}

.event-card {
  margin-top: auto;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background 0.3s, border-color 0.3s;
}
.event-eyebrow {
  font-size: 10px;
  color: var(--accent-cyan);
  letter-spacing: 1px;
  font-weight: 700;
}
.event-title {
  font-size: 14px;
  font-weight: 800;
  margin: 4px 0 2px;
  letter-spacing: 0.3px;
}
.event-meta {
  font-size: 12px;
  color: var(--text-dim);
}
.event-end-btn {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-red);
  padding: 8px 0 0;
}
.dot-red {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-red);
  display: inline-block;
}

/* ========== THEME TOGGLE ========== */
.theme-toggle {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  transition: background 0.3s, color 0.3s, border-color 0.3s;
  width: 100%;
  justify-content: center;
}
.theme-toggle:hover {
  background: var(--border);
}
.theme-toggle .icon {
  font-size: 18px;
}

/* ========== VIEWS ========== */
.view {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: calc(100vh - 36px);
  transition: background 0.3s, border-color 0.3s;
}
.view[hidden] {
  display: none;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.view-header h1 {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--text);
}

/* ========== BUTTONS ========== */
.btn-primary {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s, border-color 0.15s;
}
.btn-primary:hover {
  background: #273575;
  border-color: var(--accent-blue);
}
.btn-primary span {
  color: var(--accent-cyan);
  font-weight: 800;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 14px 26px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

/* ========== EMPTY STATE ========== */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: var(--text-dim);
  font-size: 14px;
}

/* ========== CHRONO ========== */
.chrono-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 22px;
  flex: 1;
}

.chrono-panel {
  background: radial-gradient(circle at 50% 0%, #020B1C 0%, #020B1C 70%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 20px 26px;
  gap: 6px;
}
.chrono-eyebrow {
  font-size: 11px;
  letter-spacing: 1.5px;
  color: var(--accent-cyan);
  font-weight: 700;
}
.chrono-name {
  font-size: 30px;
  font-weight: 800;
}
.chrono-part {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.ring-wrap {
  position: relative;
  width: min(300px, 78%);
  aspect-ratio: 1/1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 6px 0 8px;
}
.ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 14;
}
.ring-fg {
  fill: none;
  stroke-width: 14;
  stroke-linecap: round;
  stroke: url(#ringGradient);
  transition: stroke-dashoffset 1s linear, stroke 0.3s ease;
}
.ring-fg--big {
  stroke: url(#ringGradientBig);
}
.ring-fg.state-warning {
  stroke: var(--accent-orange);
}
.ring-fg.state-overtime {
  stroke: var(--accent-red);
}

.ring-spin {
  fill: none;
  stroke-width: 14;
  stroke-linecap: round;
  stroke: #ffb4b4;
  opacity: 0;
  transform-origin: 150px 150px;
}
.ring-spin.is-active {
  opacity: 1;
  stroke-dasharray: 55 761;
  animation: ring-spin-rotate 1.6s linear infinite;
}
@keyframes ring-spin-rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.ring-center {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.time-display {
  font-size: 56px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #ffffff;
  transition: color 0.3s ease;
}
.time-display.state-warning {
  color: var(--accent-orange);
}
.time-display.state-overtime {
  color: var(--accent-red);
}
.time-display--xl {
  font-size: clamp(90px, 15vw, 190px);
}
.time-label {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-dim);
  font-weight: 600;
}

.stat-cards {
  display: flex;
  gap: 14px;
  margin-top: 22px;
  width: 100%;
}
.stat-card {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: center;
}
.stat-label {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-dim);
  font-weight: 700;
}
.stat-value {
  font-size: 18px;
  font-weight: 800;
}

/* ========== PROGRAMME PANEL ========== */
.programme-panel {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}
.programme-eyebrow {
  font-size: 11px;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  font-weight: 700;
}
.programme-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.prog-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.prog-item.is-current {
  background: linear-gradient(135deg, rgba(79, 109, 247, 0.25), rgba(139, 92, 246, 0.2));
  border-color: rgba(111, 91, 240, 0.5);
}
.prog-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.prog-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.prog-name {
  font-size: 13px;
  font-weight: 600;
}
.prog-time {
  font-size: 11px;
  color: var(--text-dim);
}
.prog-status {
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  padding: 3px 8px;
  border-radius: 20px;
}
.prog-status.current {
  color: var(--accent-cyan);
  background: rgba(51, 198, 244, 0.12);
}
.prog-status.upcoming {
  color: var(--text-faint);
}
.prog-status.done {
  color: var(--accent-green);
}

/* ========== PROGRAMME VIEW ========== */
.add-programme-form {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  flex-wrap: wrap;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 11px;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  font-weight: 700;
}
.field-title {
  flex: 1 1 220px;
}
.field-title input {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  width: 100%;
}
.time-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
}
.time-inputs input {
  width: 56px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  color: var(--text);
  font-size: 14px;
  text-align: center;
}
.time-inputs span {
  font-size: 12px;
  color: var(--text-dim);
}
.add-programme-form input:focus {
  outline: 2px solid var(--accent-blue);
}
.add-programme-form .btn-primary {
  height: 42px;
  align-self: flex-end;
}

.programme-editor-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.editor-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  cursor: grab;
  transition: background 0.15s;
}
.editor-item:active {
  cursor: grabbing;
}
.editor-item .prog-info {
  flex: 1;
}
.editor-status {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.editor-status.pending {
  color: var(--text-faint);
  background: rgba(255, 255, 255, 0.04);
}
.editor-status.active {
  color: var(--accent-cyan);
  background: rgba(51, 198, 244, 0.12);
}
.editor-status.done {
  color: var(--accent-green);
  background: rgba(34, 201, 138, 0.12);
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.btn-edit {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  padding: 4px 8px;
  cursor: pointer;
  transition: color 0.15s;
}
.btn-edit:hover {
  color: var(--accent-cyan);
}
.btn-start {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--accent-blue), #6f5bf0);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: filter 0.15s;
}
.btn-start:hover {
  filter: brightness(1.1);
}
.btn-delete {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-red);
  background: rgba(255, 4, 4, 0.863);
  font-size: 14px;
  font-weight: 700;
  transition: background 0.15s;
}
.btn-delete:hover {
  background: rgba(239, 68, 68, 0.22);
}
.empty-list-msg {
  color: var(--text-dim);
  font-size: 13px;
  padding: 10px 4px;
}

/* ========== HISTORIQUE ========== */
.historique-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hist-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--panel-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 13px;
  gap: 12px;
}
.hist-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.hist-name {
  font-weight: 700;
}
.hist-time {
  color: var(--text-dim);
  font-size: 11px;
}
.hist-overtime {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.hist-overtime.ok {
  color: var(--accent-green);
}
.hist-overtime.over {
  color: var(--accent-red);
}
.hist-overtime.ahead {
  color: var(--accent-cyan);
}
.hist-delete {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  padding: 4px 8px;
  cursor: pointer;
  transition: color 0.15s;
}
.hist-delete:hover {
  color: var(--accent-red);
}

/* ========== SETTINGS ========== */
.settings-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 420px;
}
.settings-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
}
.settings-form input {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
}
.settings-form input:focus {
  outline: 2px solid var(--accent-blue);
}
.settings-form .btn-primary {
  align-self: flex-start;
  margin-top: 6px;
}
.save-confirm {
  color: var(--accent-green);
  font-size: 13px;
  font-weight: 700;
}

/* ========== MINUTEUR PLEIN ÉCRAN ========== */
.minuteur-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: radial-gradient(circle at 30% 30%, #1a2345 0%, #05070f 75%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 36px;
  padding: 24px;
  overflow-y: auto;
}
.minuteur-overlay[hidden] {
  display: none;
}
.minuteur-close {
  position: absolute;
  top: 24px;
  left: 28px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}
.minuteur-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}
.minuteur-title {
  font-size: clamp(34px, 5vw, 72px);
  font-weight: 800;
  letter-spacing: 1px;
  text-align: center;
}
.ring-wrap--xl {
  width: min(90vw, 760px);
}
.minuteur-actions {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}
.minuteur-actions .btn-primary {
  padding: 14px 26px;
  font-size: 14px;
}
.minuteur-actions .btn-secondary {
  padding: 14px 26px;
  font-size: 14px;
}

/* ========== DRAG & DROP ========== */
.editor-item.dragging {
  opacity: 0.35;
  border-style: dashed;
  border-color: var(--accent-blue);
}
.editor-item.drag-over-top::before {
  content: '';
  position: absolute;
  top: -4px;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent-blue);
  border-radius: 4px;
  box-shadow: 0 0 12px var(--accent-blue), 0 0 24px rgba(79, 109, 247, 0.4);
  z-index: 10;
}
.editor-item.drag-over-bottom::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent-blue);
  border-radius: 4px;
  box-shadow: 0 0 12px var(--accent-blue), 0 0 24px rgba(79, 109, 247, 0.4);
  z-index: 10;
}
.editor-item.drag-over-top,
.editor-item.drag-over-bottom {
  border-color: rgba(79, 109, 247, 0.3);
}

/* ========== GESTION UTILISATEURS ========== */
#view-users {
  display: flex;
  flex-direction: column;
  height: 100%;
}
#view-users .view-header {
  flex-shrink: 0;
}
#view-users > div {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 10px;
}

#adminUserList .user-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: background 0.2s, border-color 0.2s;
}
#adminUserList .user-item:hover {
  background: var(--panel);
}
#adminUserList .user-item .username {
  font-weight: 600;
}
#adminUserList .user-item .role {
  color: var(--text-dim);
  font-size: 12px;
  margin-left: 8px;
}
#adminUserList .user-item .delete-btn {
  background: transparent;
  color: var(--accent-red);
  border: none;
  cursor: pointer;
  font-weight: bold;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}
#adminUserList .user-item .delete-btn:hover {
  background: rgba(239, 68, 68, 0.15);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }
  .nav {
    flex-direction: row;
  }
  .event-card {
    display: none;
  }
  .chrono-layout {
    grid-template-columns: 1fr;
  }
  .add-programme-form {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ========== ACCESSIBILITY ========== */
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

/* ========== REDUCED MOTION ========== */
@media (prefers-reduced-motion: reduce) {
  .ring-fg {
    transition: none;
  }
  .ring-spin.is-active {
    animation: none;
    opacity: 0.5;
  }
}

/* ========== BOUTON DE DÉCONNEXION ROUGE ========== */
#logoutBtn {
  background: transparent;
  color: #ef4444 !important;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  font-weight: 600;
  width: 100%;
  transition: background 0.2s, border-color 0.2s;
}
#logoutBtn:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: #ef4444;
}
