/* ============================================
   COOLDOWN MANAGER — style.css
   Aesthetic: Minimalist, Flat, High Contrast
   Fonts: Inter + JetBrains Mono
   ============================================ */

:root {
  /* Polices */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Mode Clair (Par défaut) */
  --bg-body: #f4f4f5;
  --bg-surface: #ffffff;
  --bg-input: #ffffff;
  --bg-input-focus: #fcfcfd;
  
  --text-main: #18181b;
  --text-muted: #71717a;
  --text-placeholder: #a1a1aa;
  
  --border-light: #e4e4e7;
  --border-focus: #18181b;

  --accent-blue: #2563eb;
  --accent-blue-bg: #eff6ff;
  
  --accent-orange: #d97706;
  --accent-orange-bg: #fffbeb;
  
  --accent-red: #dc2626;
  --accent-red-bg: #fef2f2;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  
  --radius: 8px;
  --transition: 0.15s ease-in-out;
}

[data-theme="dark"] {
  /* Mode Sombre */
  --bg-body: #09090b;
  --bg-surface: #18181b;
  --bg-input: #18181b;
  --bg-input-focus: #27272a;
  
  --text-main: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-placeholder: #52525b;
  
  --border-light: #27272a;
  --border-focus: #f4f4f5;

  --accent-blue: #3b82f6;
  --accent-blue-bg: rgba(59, 130, 246, 0.15);
  
  --accent-orange: #f59e0b;
  --accent-orange-bg: rgba(245, 158, 11, 0.15);
  
  --accent-red: #ef4444;
  --accent-red-bg: rgba(239, 68, 68, 0.15);

  --shadow-sm: none;
  --shadow-card: none;
}

/* ── Reset ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg-body);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ──────────────────────────────────── */
.app-header {
  height: 60px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  color: var(--text-main);
  display: flex; align-items: center;
}

.brand-name {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand-name span {
  font-weight: 400;
  color: var(--text-muted);
}

.header-meta {
  display: flex; align-items: center; gap: 16px;
}

.cooldown-count {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-body);
  border: 1px solid var(--border-light);
  padding: 4px 10px;
  border-radius: 40px;
}

.theme-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: color var(--transition);
}
.theme-toggle:hover { color: var(--text-main); }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* ── Layout ──────────────────────────────────── */
.app-layout {
  display: flex;
  flex: 1;
  width: 100%; /* Modification : On prend toute la largeur pour coller à gauche */
}

/* ── Sidebar ─────────────────────────────────── */
.sidebar {
  width: 340px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-light);
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
}

.sidebar-inner {
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  min-height: 100%;
}

.form-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.form-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── Form ────────────────────────────────────── */
.cooldown-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field-group {
  display: flex; flex-direction: column; gap: 6px; position: relative;
}

.field-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}

.field-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-main);
}
.required-dot { color: var(--accent-red); }

.field-input {
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--text-main);
  width: 100%;
  outline: none;
  transition: all var(--transition);
  color-scheme: light dark;
}
.field-input::placeholder { color: var(--text-placeholder); }
.field-input:focus {
  border-color: var(--border-focus);
  background: var(--bg-input-focus);
}
.field-input.error { border-color: var(--accent-red); }

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

.field-error {
  font-size: 0.75rem;
  color: var(--accent-red);
  display: none;
  font-weight: 500;
}
.field-error.visible { display: block; }

.char-count {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: right;
}

.btn-submit {
  background: var(--text-main);
  color: var(--bg-surface);
  border: none;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: opacity var(--transition), transform var(--transition);
  margin-top: 8px;
}
.btn-submit:hover { opacity: 0.9; }
.btn-submit:active { transform: scale(0.98); }
.btn-submit:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Sidebar Footer ──────────────────────────── */
.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-light);
  padding-top: 24px;
}
.legend {
  display: flex; flex-direction: column; gap: 12px;
}
.legend-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.8rem; color: var(--text-muted); font-weight: 500;
}
.legend-dot { width: 10px; height: 10px; border-radius: 2px; }
.legend-dot.active { background: var(--accent-blue); }
.legend-dot.urgent { background: var(--accent-orange); }
.legend-dot.expired { background: var(--text-muted); }

/* ── Main Content ────────────────────────────── */
.main-content {
  flex: 1;
  padding: 40px;
  min-width: 0;
}

.content-toolbar {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 32px;
}
.content-title { font-size: 1.5rem; font-weight: 700; }

.btn-clear-expired {
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: background var(--transition);
}
.btn-clear-expired:hover {
  background: var(--accent-red-bg);
  color: var(--accent-red);
  border-color: var(--accent-red);
}

/* ── Empty State ─────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 80px 0; text-align: center;
}
.empty-state.hidden { display: none; }
.empty-icon {
  color: var(--text-muted); margin-bottom: 16px; opacity: 0.5;
}
.empty-title { font-size: 1.1rem; font-weight: 600; color: var(--text-main); margin-bottom: 8px; }
.empty-sub { font-size: 0.9rem; color: var(--text-muted); max-width: 300px; line-height: 1.5; }

/* ── Cooldown List & Card ────────────────────── */
.cooldown-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.cooldown-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 24px;
  box-shadow: var(--shadow-card);
  transition: border-color var(--transition);
}
.cooldown-card:hover { border-color: var(--border-focus); }

/* Card Header */
.card-header {
  display: flex; flex-direction: column; gap: 8px;
}
.card-title-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}
.card-title {
  font-size: 1.05rem; font-weight: 600; line-height: 1.3;
  word-break: break-word;
}

.card-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
  padding: 4px 8px; border-radius: 4px; flex-shrink: 0;
}
.badge-active { background: var(--accent-blue-bg); color: var(--accent-blue); }
.badge-urgent { background: var(--accent-orange-bg); color: var(--accent-orange); }
.badge-expired { background: var(--bg-body); color: var(--text-muted); }

.card-description {
  font-size: 0.85rem; color: var(--text-muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* Card Timer */
.card-timer-container {
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-body);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px 0;
}

.timer-group {
  display: flex; align-items: baseline; gap: 4px;
}
.timer-unit {
  display: flex; align-items: baseline; gap: 2px;
}
.timer-digits {
  font-family: var(--font-mono);
  font-size: 1.5rem; font-weight: 700; color: var(--text-main);
}
.timer-label {
  font-family: var(--font-mono);
  font-size: 0.7rem; color: var(--text-muted); font-weight: 500;
}
.timer-sep {
  font-family: var(--font-mono); font-size: 1.2rem; color: var(--text-muted); margin: 0 4px; opacity: 0.5;
}

/* Card Footer */
.card-footer { display: flex; flex-direction: column; gap: 12px; }

.card-progress {
  width: 100%; height: 6px; background: var(--bg-body); border-radius: 3px; overflow: hidden;
}

/* Modification : La couleur de fond (background-color) est retirée d'ici pour être gérée par JS. On ajoute une transition de couleur. */
.card-progress-fill {
  height: 100%; border-radius: 3px; transition: width 1s linear, background-color 1s linear;
}

.card-meta-row {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted);
}
.card-deadline { display: flex; align-items: center; gap: 6px; }

/* States */
.cooldown-card.urgent .timer-digits { color: var(--accent-orange); }

.cooldown-card.expired { opacity: 0.7; }
.cooldown-card.expired .card-progress-fill { background-color: var(--text-muted) !important; }
.cooldown-card.expired .timer-display { 
  font-family: var(--font-mono); font-size: 0.85rem; font-weight: 600; color: var(--text-main);
}

/* Delete Button */
.btn-delete {
  position: absolute; top: 16px; right: 16px;
  background: var(--bg-surface); border: 1px solid var(--border-light);
  width: 28px; height: 28px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-muted);
  opacity: 0; transition: all var(--transition);
}
.cooldown-card:hover .btn-delete { opacity: 1; right: -14px; top: -14px; } /* Appears outside cleanly */
.btn-delete:hover { background: var(--accent-red); color: #fff; border-color: var(--accent-red); }

/* ── Toast ───────────────────────────────────── */
.toast {
  position: fixed; bottom: 32px; right: 32px;
  background: var(--text-main); color: var(--bg-surface);
  padding: 12px 20px; border-radius: var(--radius);
  font-size: 0.9rem; font-weight: 500;
  opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: all 0.2s ease-out; z-index: 200; box-shadow: var(--shadow-card);
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ── Responsive ──────────────────────────────── */
@media (max-width: 900px) {
  .app-layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border-light); }
  .main-content { padding: 24px; }
  .cooldown-card:hover .btn-delete { right: 16px; top: 16px; } /* Reset positioning on mobile */
  .btn-delete { opacity: 1; }
}