/* ============================================================
   Kanban clair — Styles
   ============================================================ */

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

:root {
  --bg:        #eef2f7;
  --sidebar-w: 240px;
  --topbar-h:  72px;
  --col-w:     272px;
  --col-gap:   18px;
  --col-rad:   18px;
  --card-rad:  14px;
  --blue:      #2563eb;
  --blue-lt:   #dbeafe;
  --blue-dk:   #1d4ed8;
  --text:      #0f172a;
  --text-mid:  #334155;
  --text-mute: #64748b;
  --border:    #d7e0ec;
  --white:     #ffffff;
  --surface:   #f8fafc;
  --danger-bg: #fee2e2;
  --danger:    #991b1b;
  --shadow:    rgba(15,23,42,.06);
}

html, body { height: 100%; font-family: "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--text); }

/* ── LAYOUT ─────────────────────────────────────────── */
#app { display: flex; height: 100vh; overflow: hidden; }

/* ── SIDEBAR ─────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--white);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
}
#sidebar-top { padding: 20px 18px 0; }
.sidebar-heading { font-size: 18px; font-weight: 800; color: var(--text); }
.sidebar-sub { font-size: 11px; color: var(--text-mute); margin-top: 2px; }
#search-wrap {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; margin: 12px 0 10px;
}
.search-icon { font-size: 12px; color: var(--text-mute); }
#search-input { flex: 1; border: none; background: none; font-size: 13px; color: var(--text); outline: none; }

#board-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
}
#board-list li {
  padding: 9px 12px; border-radius: 8px; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text-mid);
  display: flex; align-items: center; gap: 6px;
  transition: background .1s;
  user-select: none;
}
#board-list li:hover { background: var(--surface); }
#board-list li.active { background: var(--blue-lt); color: var(--blue); }
#board-list li.macro { font-weight: 700; color: var(--text); }

#sidebar-actions {
  padding: 10px 14px 18px;
  display: flex; flex-direction: column; gap: 6px;
}
.sb-btn {
  text-align: left; padding: 9px 14px; border-radius: 8px;
  border: none; cursor: pointer; font: 600 12px "Segoe UI", sans-serif;
  background: var(--surface); color: var(--text-mid);
  transition: background .1s;
}
.sb-btn:hover { background: #e2e8f0; }
.sb-btn.danger { background: var(--danger-bg); color: var(--danger); }
.sb-btn.danger:hover { background: #fecaca; }

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

#topbar {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  background: var(--bg);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}
#board-title { font-size: 20px; font-weight: 800; flex: 1; }
#topbar-actions { display: flex; gap: 8px; }
.tb-btn {
  padding: 8px 14px; border-radius: 8px;
  border: none; cursor: pointer; font: 600 12px "Segoe UI", sans-serif;
  background: var(--white); color: var(--text-mid);
  transition: background .1s; white-space: nowrap;
}
.tb-btn:hover { background: var(--blue-lt); }

/* ── BOARD AREA ───────────────────────────────────────── */
#board-area {
  flex: 1; overflow: auto; padding: 20px;
  background: var(--bg);
  position: relative;
}
/* Blobs décoratifs */
#board-area::before, #board-area::after {
  content: ''; position: fixed; border-radius: 50%; pointer-events: none; z-index: 0;
}
#board-area::before {
  width: 420px; height: 340px; left: var(--sidebar-w); top: var(--topbar-h);
  background: radial-gradient(ellipse at center, #dbeafe88 0%, transparent 70%);
}
#board-area::after {
  width: 380px; height: 320px; right: 0; bottom: 0;
  background: radial-gradient(ellipse at center, #ede9fe66 0%, transparent 70%);
}

#columns-wrap {
  display: flex; gap: var(--col-gap);
  min-height: calc(100vh - var(--topbar-h) - 80px);
  align-items: flex-start;
  width: max-content;
  min-width: 100%;
  position: relative; z-index: 1;
}

/* ── EMPTY BOARD ──────────────────────────────────────── */
#empty-board {
  background: var(--white); border: 1px solid var(--blue-lt);
  border-radius: 22px; padding: 40px 48px; text-align: center;
  max-width: 480px; margin: 60px auto;
}
#empty-board h3 { font-size: 20px; margin-bottom: 8px; }
#empty-board p { color: var(--text-mute); font-size: 13px; }

/* ── COLUMN ───────────────────────────────────────────── */
.column {
  width: var(--col-w); flex-shrink: 0;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--col-rad);
  box-shadow: 0 4px 0 0 #cbd5e1;
  display: flex; flex-direction: column;
  min-height: 200px;
  position: relative;
  transition: box-shadow .15s;
}
.column.drag-over { box-shadow: 0 4px 0 0 var(--blue), inset 0 0 0 2px var(--blue); }

.col-header {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid #e2e8f0;
  border-radius: 12px; margin: 12px; padding: 8px 12px;
  cursor: grab;
  user-select: none;
}
.col-header:active { cursor: grabbing; }
.col-dot { width: 13px; height: 13px; border-radius: 50%; flex-shrink: 0; }
.col-title { font-size: 13px; font-weight: 700; flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.col-count { font-size: 11px; color: var(--text-mute); font-weight: 600; }
.col-menu-btn {
  background: none; border: none; cursor: pointer; font-size: 16px;
  color: var(--text-mute); padding: 0 2px; line-height: 1;
}
.col-menu-btn:hover { color: var(--text); }

.col-cards { flex: 1; padding: 0 10px; display: flex; flex-direction: column; gap: 10px; }
.col-cards.frozen-group { padding-top: 0; }

.frozen-label {
  font-size: 11px; font-weight: 700; color: var(--text-mute);
  display: flex; align-items: center; gap: 6px;
  padding: 10px 10px 4px;
  border-top: 1px solid #e2e8f0;
  margin-top: 4px;
}

.add-card-btn {
  margin: 10px; padding: 10px;
  background: var(--surface); border: 1px solid #e2e8f0;
  border-radius: 10px; cursor: pointer;
  font: 600 12px "Segoe UI", sans-serif; color: var(--text-mute);
  text-align: center; transition: background .1s;
}
.add-card-btn:hover { background: #f1f5f9; }

/* ── CARD ─────────────────────────────────────────────── */
.card {
  background: var(--white); border: 1px solid var(--blue-lt);
  border-radius: var(--card-rad);
  box-shadow: 2px 3px 0 0 #cbd5e1;
  padding: 12px 12px 12px 18px;
  position: relative; cursor: grab;
  transition: box-shadow .12s, transform .12s;
  user-select: none;
}
.card:active { cursor: grabbing; box-shadow: 4px 6px 0 0 #94a3b8; transform: rotate(1.5deg) scale(1.02); }
.card.is-frozen {
  background: var(--surface); border-color: #cbd5e1;
  box-shadow: 2px 3px 0 0 #e2e8f0;
}
.card.dragging { opacity: .35; }
.card.drag-placeholder {
  background: none; border: 2px dashed var(--blue); box-shadow: none;
  pointer-events: none;
}

.card-accent-bar {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 7px; border-radius: var(--card-rad) 0 0 var(--card-rad);
}
.card-title {
  font-size: 13px; font-weight: 700; line-height: 1.4;
  color: var(--text); word-break: break-word;
}
.card.is-frozen .card-title { color: #475569; }
.card-note {
  font-size: 12px; color: var(--text-mute); margin-top: 6px;
  line-height: 1.45; word-break: break-word;
}
.card-marker {
  position: absolute; right: 36px; top: 12px;
  width: 14px; height: 14px; border-radius: 50%;
}
.card-menu-btn {
  position: absolute; right: 8px; top: 6px;
  background: none; border: none; cursor: pointer;
  font-size: 14px; color: #94a3b8; padding: 2px 4px;
}
.card-menu-btn:hover { color: var(--text); }
.card-frozen-badge {
  display: inline-flex; align-items: center; gap: 3px;
  margin-top: 8px; padding: 2px 8px; border-radius: 6px;
  background: #e2e8f0; font-size: 10px; font-weight: 700; color: #475569;
}

/* Drop indicator line */
.drop-line {
  height: 3px; background: var(--blue); border-radius: 2px;
  margin: 0 8px; pointer-events: none;
  position: relative;
}
.drop-line::before, .drop-line::after {
  content: ''; position: absolute; top: 50%; transform: translateY(-50%);
  width: 8px; height: 8px; border-radius: 50%; background: var(--blue);
}
.drop-line::before { left: -4px; }
.drop-line::after  { right: -4px; }

/* ── MODALES ──────────────────────────────────────────── */
#modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
#modal-overlay.hidden { display: none; }
#modal-box {
  background: var(--white); border-radius: 18px;
  width: 480px; max-width: 95vw; max-height: 90vh;
  overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
#modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 0;
}
#modal-title { font-size: 17px; font-weight: 800; }
#modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 16px; color: var(--text-mute); padding: 2px 6px;
}
#modal-close:hover { color: var(--text); }
#modal-body { padding: 16px 24px 24px; }

/* Form elements inside modal */
.form-label {
  display: block; font-size: 12px; font-weight: 700;
  color: var(--text-mid); margin-bottom: 5px;
}
.form-input {
  width: 100%; padding: 9px 12px; font-size: 14px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
  outline: none; font-family: inherit;
}
.form-input:focus { border-color: var(--blue); }
textarea.form-input { resize: vertical; min-height: 80px; }
.form-group { margin-bottom: 16px; }
.form-row { display: flex; gap: 10px; align-items: center; }

.color-preview {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid var(--border); cursor: pointer; flex-shrink: 0;
}
.color-input { width: 0; height: 0; opacity: 0; position: absolute; }

.checkbox-row { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; font-weight: 600; }
.checkbox-row input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--blue); }

.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.btn-primary {
  padding: 9px 20px; background: var(--blue); color: var(--white);
  border: none; border-radius: 8px; cursor: pointer;
  font: 700 13px "Segoe UI", sans-serif;
}
.btn-primary:hover { background: var(--blue-dk); }
.btn-secondary {
  padding: 9px 16px; background: var(--surface); color: var(--text-mid);
  border: none; border-radius: 8px; cursor: pointer;
  font: 700 13px "Segoe UI", sans-serif;
}
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger {
  padding: 9px 16px; background: var(--danger-bg); color: var(--danger);
  border: none; border-radius: 8px; cursor: pointer;
  font: 700 13px "Segoe UI", sans-serif;
}
.btn-danger:hover { background: #fecaca; }

/* ── CONTEXT MENUS ────────────────────────────────────── */
.ctx-menu {
  position: fixed; background: var(--white);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  padding: 4px; z-index: 2000; min-width: 180px;
}
.ctx-menu.hidden { display: none; }
.ctx-menu button {
  display: block; width: 100%; text-align: left;
  padding: 9px 14px; background: none; border: none;
  cursor: pointer; font: 600 13px "Segoe UI", sans-serif;
  color: var(--text-mid); border-radius: 6px;
}
.ctx-menu button:hover { background: var(--surface); }
.ctx-menu button.danger { color: var(--danger); }
.ctx-menu button.danger:hover { background: var(--danger-bg); }
.ctx-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* ── TEMPLATE SETTINGS ────────────────────────────────── */
.tpl-layout { display: flex; gap: 20px; }
.tpl-col { flex: 1; }
.tpl-list, .tcol-list {
  list-style: none; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); max-height: 220px; overflow-y: auto;
}
.tpl-list li, .tcol-list li {
  padding: 9px 12px; cursor: pointer; font: 600 13px "Segoe UI", sans-serif;
  border-bottom: 1px solid #f0f4f8;
}
.tpl-list li:last-child, .tcol-list li:last-child { border-bottom: none; }
.tpl-list li:hover, .tcol-list li:hover { background: #f0f4f8; }
.tpl-list li.active, .tcol-list li.active { background: var(--blue-lt); color: var(--blue); }
.tpl-list-label { font: 700 12px "Segoe UI", sans-serif; color: var(--text-mid); margin-bottom: 5px; }
.tpl-actions, .tcol-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tpl-actions .btn-secondary, .tcol-actions .btn-secondary { padding: 7px 10px; font-size: 11px; }

/* ── MACRO VISIBILITY ─────────────────────────────────── */
.macro-board-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 8px; cursor: pointer; font: 600 13px "Segoe UI", sans-serif;
}
.macro-board-row:hover { background: var(--surface); }
.macro-board-row input { accent-color: var(--blue); }

/* ── TOAST ────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #1e293b; color: #f1f5f9;
  padding: 10px 18px; border-radius: 10px;
  font: 600 13px "Segoe UI", sans-serif;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  z-index: 3000; transition: opacity .3s;
}
#toast.hidden { display: none; }

/* ── NEW BOARD DIALOG ─────────────────────────────────── */
.tpl-preview-cols { display: flex; flex-direction: column; gap: 6px; }
.tpl-preview-col-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-mid);
}
.tpl-preview-col-item .col-dot-sm {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}

/* ── SPLIT CARD DIALOG ────────────────────────────────── */
.split-original {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px; margin-bottom: 14px;
}
.split-original .split-title { font: 700 14px "Segoe UI", sans-serif; color: var(--text); }
.split-original .split-note { font-size: 12px; color: var(--text-mute); margin-top: 4px; }

/* ── SCROLLBAR ────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── LOADING ──────────────────────────────────────────── */
.loading {
  display: flex; align-items: center; justify-content: center;
  height: 100%; font-size: 16px; color: var(--text-mute);
}

/* ── CONFIRM DIALOG ───────────────────────────────────── */
.confirm-msg { font-size: 14px; color: var(--text-mid); margin-bottom: 20px; line-height: 1.5; }

/* ── SIDEBAR TOGGLE (masqué sur desktop) ──────────────── */
#sidebar-toggle  { display: none; }
#sidebar-overlay {
  display: none; position: fixed; inset: 0; z-index: 499;
  background: rgba(0,0,0,.35);
}
#sidebar-overlay.visible { display: block; }

/* ── RESPONSIVE MOBILE ────────────────────────────────── */
@media (max-width: 768px) {
  :root { --topbar-h: 56px; }

  /* Sidebar → drawer */
  #sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 500;
    width: 280px; max-width: 85vw;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: none;
  }
  #sidebar.open {
    transform: translateX(0);
    box-shadow: 6px 0 28px rgba(0,0,0,.18);
  }

  /* Hamburger visible */
  #sidebar-toggle { display: flex; align-items: center; justify-content: center; }

  /* Topbar */
  #topbar { padding: 0 10px; gap: 6px; height: var(--topbar-h); min-height: var(--topbar-h); }
  #board-title { font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #topbar-actions { overflow-x: auto; gap: 4px; flex-shrink: 0; }
  #topbar-actions::-webkit-scrollbar { display: none; }
  .tb-btn { padding: 7px 10px; font-size: 11px; }

  /* Board area */
  #board-area { padding: 10px 8px; }
  #board-area::before, #board-area::after { display: none; }

  /* Colonnes : scroll horizontal avec snap */
  #columns-wrap {
    gap: 10px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scroll-padding: 8px;
    min-height: calc(100vh - var(--topbar-h) - 40px);
  }
  .column {
    width: calc(100vw - 32px);
    min-width: 240px;
    max-width: 380px;
    scroll-snap-align: start;
  }

  /* Touch targets plus grands */
  .card { padding: 13px 13px 13px 20px; }
  .card-title { font-size: 14px; }
  .card-menu-btn {
    right: 4px; top: 4px; padding: 6px 8px; font-size: 17px;
    min-width: 34px; min-height: 34px;
    display: flex; align-items: center; justify-content: center;
  }
  .add-card-btn { padding: 13px; font-size: 13px; }
  .col-menu-btn { padding: 4px 8px; font-size: 19px; min-width: 34px; min-height: 34px; }

  /* Context menu → bottom sheet */
  .ctx-menu {
    position: fixed !important;
    top: auto !important; bottom: 0 !important;
    left: 0 !important; right: 0 !important;
    width: 100% !important; min-width: unset !important;
    border-radius: 18px 18px 0 0;
    padding: 4px 8px calc(12px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 24px rgba(0,0,0,.15);
    max-height: 65vh; overflow-y: auto;
  }
  .ctx-menu::before {
    content: ''; display: block; width: 40px; height: 4px;
    background: var(--border); border-radius: 2px; margin: 8px auto 10px;
  }
  .ctx-menu button { padding: 14px 16px; font-size: 15px; }
  .ctx-sep { margin: 6px 0; }

  /* Modal → bottom sheet */
  #modal-overlay { align-items: flex-end; }
  #modal-box {
    width: 100% !important; max-width: 100% !important;
    max-height: 92vh !important;
    border-radius: 18px 18px 0 0 !important;
    padding-bottom: env(safe-area-inset-bottom);
  }

  /* Template settings : empiler les colonnes */
  .tpl-layout { flex-direction: column; }
  .tpl-list, .tcol-list { max-height: 150px; }

  /* Toast : centré */
  #toast { right: auto; left: 50%; transform: translateX(-50%); bottom: 16px; }
}
