/* ==========================================================================
   styles.css – Tableau de répétition espacée
   ========================================================================== */

/* ---------- PALETTE ----------------------------------------------------- */
:root {
    /* thème clair */
    --bg-body      : #f4f4f4;
    --bg-surface   : #ffffff;
    --fg           : #222;

    --border       : #d0d0d0;
    --border-dark  : #555;

    --primary      : #0d6efd;
    --success      : #2e9b4f;
    --error        : #d13636;
    --future       : #ffc107;
    --missing      : #eeeeee;

    --header-bg    : #343a40;
    --header-fg    : #fff;

    --tag-bg       : #e9ecef;
    --tag-fg       : #495057;
}

/* thème sombre  ---------------------------------------------------------- */
body.dark {
    --bg-body    : #1e1e1e;
    --bg-surface : #262626;
    --fg         : #e5e5e5;

    --border     : #555;
    --tag-bg     : #333;
    --tag-fg     : #ccc;
}

/* ---------- RESET / BASE ------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg-body);
    color: var(--fg);
}

/* ---------- HEADER ------------------------------------------------------ */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--header-bg);
    color: var(--header-fg);
    padding: 10px 20px;
}
header h1 { margin: 0; font-size: 1.25rem; }

.count {
    background: var(--success);
    color: #fff;
    border-radius: 18px;
    padding: 3px 12px;
    margin-right: 12px;
    font-size: .85rem;
    font-weight: 600;
}

/* ---------- BUTTONS ----------------------------------------------------- */
.btn {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: .85rem;
    cursor: pointer;
    transition: opacity .15s;
}
.btn:hover   { opacity: .9; }
.btn:disabled{ opacity: .4; cursor: not-allowed; }

#darkToggle  { background: #555; }

/* ---------- FILTER BAR -------------------------------------------------- */
#filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 10px 20px;
}
input[type="search"],
select {
    padding: 5px 8px;
    font-size: .85rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-surface);
    color: var(--fg);
}

/* ---------- TABLE WRAPPER ---------------------------------------------- */
.wrapper { overflow: auto; }

/* ---------- TABLE ------------------------------------------------------- */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-surface);
}
th, td {
    border: 1px solid var(--border);
    padding: 6px 8px;
    white-space: nowrap;
    font-size: .8rem;
    text-align: center;
}
thead th {
    background: var(--bg-body);
    position: sticky;
    top: 0;
    z-index: 6;
}

/* colonnes “collantes” (Tâche + poignée drag) */
th.sticky, td.sticky {
    position: sticky;
    left: 0;
    background: var(--bg-surface);
    z-index: 5;
    box-shadow: 2px 0 0 var(--border);
}

/* alternance lignes */
tbody tr:nth-child(even) { background: rgba(0,0,0,.03); }

/* hover de ligne */
tbody tr:hover { background: rgba(0,0,0,.05); }

/* ---------- CELLULES STATUS -------------------------------------------- */
td.due  { background: var(--error);   color: #fff; cursor: pointer; } /* 🔴  à réviser */
td.done { background: var(--success); color: #fff; }                 /* ✅  révisé    */
td.todo { background: var(--future);  color: #000; }                 /* ⏳  futur     */
/* cell sans intervalle — simple gris très clair                           */
td.empty{ background: var(--missing); }

/* dark-mode override pour les cellules vives (gardent leur contraste) */
body.dark td.due  { background: #d44747; color:#fff; }
body.dark td.done { background: #3cbf65; color:#fff; }
body.dark td.todo { background: #eab22e; color:#000; }

/* ---------- TAGS -------------------------------------------------------- */
.tag {
    display: inline-block;
    background: var(--tag-bg);
    color: var(--tag-fg);
    padding: 2px 6px;
    border-radius: 12px;
    font-size: .70rem;
    margin: 0 2px;
}

/* ---------- DRAG HANDLE ------------------------------------------------- */
.drag-handle { cursor: grab; }
.drag-handle i { color: #888; }
tbody.tr-dragging .drag-handle,
.drag-handle:active { cursor: grabbing; }

/* ---------- POPOVER (tippy.js) ----------------------------------------- */
.tippy-box[data-theme~='light'] {
  background: var(--bg-surface);
  color: var(--fg);
  border: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
}

/* ---------- MODAL ------------------------------------------------------- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 12;
}
.modal > div {
    background: var(--bg-surface);
    color: var(--fg);
    max-width: 900px;
    width: 90%;
    max-height: 92%;
    overflow: auto;
    padding: 20px;
    border-radius: 6px;
}

/* ---------- CHART JS CANVAS -------------------------------------------- */
canvas { max-width: 98%; margin: 40px auto; display: block; }

/* ---------- RESPONSIVE -------------------------------------------------- */
@media (max-width: 600px) {
    thead { display: none; }
    th.sticky, td.sticky { position: static; box-shadow: none; }
    table, tbody, tr, td { display: block; width: 100%; }
    td { border: none; padding: 4px 6px; }
    td::before {
        content: attr(data-label);
        font-weight: 600;
        display: inline-block;
        width: 90px;
    }
}
