/* ═══════════════════════════════════════════════════
   TAGS
   ═══════════════════════════════════════════════════ */

/* ── Color picker (shared: tags page + panel) ── */
.tag-color-picker {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    flex-shrink: 0;
}

.tag-color-option {
    position: relative;
    cursor: pointer;
}

.tag-color-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.tag-color-dot {
    display: block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid transparent;
    transition: transform 0.15s, border-color 0.15s;
    cursor: pointer;
}

.tag-color-dot--blue   { background: var(--accent); }
.tag-color-dot--green  { background: var(--green); }
.tag-color-dot--amber  { background: var(--amber); }
.tag-color-dot--red    { background: #e05c6e; }
.tag-color-dot--purple { background: #9b8ecf; }
.tag-color-dot--teal   { background: #4db6ac; }

.tag-color-option input[type="radio"]:checked + .tag-color-dot {
    border-color: var(--text-primary);
    transform: scale(1.2);
}

.tag-color-option:hover .tag-color-dot {
    transform: scale(1.15);
}

/* ── Tags page: create card ── */
.tag-create-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.tag-create-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.tag-name-input {
    flex: 1;
    min-width: 160px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    padding: 0.45rem 0.75rem;
    outline: none;
    transition: border-color 0.15s;
}

.tag-name-input:focus {
    border-color: var(--accent);
}

.tag-name-input::placeholder {
    color: var(--text-muted);
}

.tag-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.45rem 0.9rem;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.15s;
}

.tag-add-btn:hover { opacity: 0.85; }

.tag-add-btn .material-icons {
    font-size: 16px;
}

/* ── Tags page: list ── */
.tag-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.tag-list-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.65rem 1rem;
    transition: border-color 0.15s;
}

.tag-list-item:hover {
    border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

.tag-list-color-dot {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.tag-list-badge {
    font-size: 0.78rem;
    min-width: 0;
}

.tag-task-count {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-left: auto;
    flex-shrink: 0;
}

.tag-list-actions {
    display: flex;
    gap: 0.1rem;
    flex-shrink: 0;
}

.clear-red-btn:hover {
    color: var(--clear-red) !important;
    background: color-mix(in srgb, var(--clear-red) 10%, transparent) !important;
}

/* ── Tags page: edit form ── */
.tag-edit-form {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    width: 100%;
}

.tag-edit-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.tag-save-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.35rem 0.7rem;
    cursor: pointer;
    transition: opacity 0.15s;
}

.tag-save-btn:hover { opacity: 0.85; }

.tag-save-btn .material-icons { font-size: 15px; }

.tag-cancel-btn {
    display: inline-flex;
    align-items: center;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    padding: 0.35rem 0.7rem;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.tag-cancel-btn:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

/* ── Panel: 'Add tags' picker trigger ── */
.tag-picker-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: transparent;
    border: 1px dashed var(--border-color);
    border-radius: 20px;
    color: var(--text-muted);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.65rem;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.tag-picker-add-btn:hover,
.tag-picker-add-btn:focus-visible {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
}

.tag-picker-add-btn .material-icons { font-size: 14px; }

/* The picker's container is normally the positioning anchor for its own
   (small, intrinsically-sized) dropdown — see .inline-tag-picker-container,
   tasks.css. Inside the task panel we want it to anchor to the whole tag
   row instead (.task-panel-tags, position: relative — tags.css) so the
   panel variant can span the full row width rather than the width of the
   'Add tags' chip; see the near-identical .panel-tag-create-form overflow
   fix this replaced. */
.task-panel-tags .inline-tag-picker-container {
    position: static;
}

/* ── Archived tags section ── */
.tag-archived-section {
    margin-top: 1.25rem;
}

.tag-archived-toggle {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.25rem 0;
    transition: color 0.15s;
    user-select: none;
}

.tag-archived-toggle:hover {
    color: var(--text-secondary);
}

.tag-archived-toggle-icon {
    font-size: 18px;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.tag-archived-section.is-open .tag-archived-toggle-icon {
    transform: rotate(180deg);
}

.tag-archived-list {
    display: none;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.6rem;
}

.tag-archived-section.is-open .tag-archived-list {
    display: flex;
}

.tag-list-item--archived {
    opacity: 0.6;
}

/* ── Tag row delete animation ── */
@keyframes tagRowOut {
    0%   { opacity: 1; transform: translateX(0); }
    100% { opacity: 0; transform: translateX(-10px); }
}

.tag-list-item.is-deleting {
    animation: tagRowOut 380ms ease forwards;
    pointer-events: none;
}

/* ── Delete confirmation modal ── */
.confirm-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.confirm-modal-backdrop.is-open {
    opacity: 1;
    pointer-events: all;
}

.confirm-modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 2rem 2rem 1.75rem;
    max-width: 380px;
    width: calc(100% - 2rem);
    text-align: center;
    transform: scale(0.93);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.confirm-modal-backdrop.is-open .confirm-modal {
    transform: scale(1);
}

.confirm-modal-icon {
    font-size: 2.25rem;
    color: var(--clear-red);
    display: block;
    margin-bottom: 0.75rem;
}

.confirm-modal-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.6rem;
}

.confirm-modal-body {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin: 0 0 1.5rem;
}

.confirm-modal-actions {
    display: flex;
    gap: 0.65rem;
    justify-content: center;
}

.confirm-modal-cancel {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.88rem;
    font-weight: 500;
    padding: 0.5rem 1.25rem;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.confirm-modal-cancel:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.confirm-modal-confirm {
    background: var(--clear-red);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 0.5rem 1.25rem;
    cursor: pointer;
    transition: opacity 0.15s;
}

.confirm-modal-confirm:hover { opacity: 0.85; }

/* ── Panel tag pills (toggle buttons) ── */
.task-panel-tags {
    position: relative;
    display: flex;
    flex: 1;
    min-width: 0;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.task-panel-tags-item {
    align-items: flex-start;
}

.task-panel-tags-item .task-panel-meta-label {
    padding-top: 0.2rem;
}

.task-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.65rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    font-family: 'DM Sans', sans-serif;
    letter-spacing: 0.02em;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-primary);
    transition: all 0.15s;
    white-space: nowrap;
}

.task-tag:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.task-tag:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* Unselected pills — border tinted to the tag's own colour so each stays
   identifiable at rest. Was `color: var(--text-muted)` on --bg-card, which
   measures ~2.1:1 contrast — well under the 4.5:1 AA floor. */
.task-tag--blue   { border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.task-tag--green  { border-color: color-mix(in srgb, var(--green)  35%, transparent); }
.task-tag--amber  { border-color: color-mix(in srgb, var(--amber)  35%, transparent); }
.task-tag--red    { border-color: color-mix(in srgb, #e05c6e       35%, transparent); }
.task-tag--purple { border-color: color-mix(in srgb, #9b8ecf       35%, transparent); }
.task-tag--teal   { border-color: color-mix(in srgb, #4db6ac       35%, transparent); }

/* Active state — default colour */
.task-tag--active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* Colour variants */
.task-tag--active.task-tag--blue   { background: var(--accent);  border-color: var(--accent); }
.task-tag--active.task-tag--green  { background: var(--green);   border-color: var(--green);  color: #fff; }
.task-tag--active.task-tag--amber  { background: var(--amber);   border-color: var(--amber);  color: #1a1a2e; }
.task-tag--active.task-tag--red    { background: #e05c6e;        border-color: #e05c6e;        color: #fff; }
.task-tag--active.task-tag--purple { background: #9b8ecf;        border-color: #9b8ecf;        color: #fff; }
.task-tag--active.task-tag--teal   { background: #4db6ac;        border-color: #4db6ac;        color: #fff; }

/* ── Inline badges on task rows ── */
.task-tags-inline {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    align-items: center;
    flex-shrink: 0;
}

.task-tag-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.1rem 0.5rem;
    border-radius: 20px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

/* Removable variant (task panel) — same badge, but a real button so a tag
   can be detached with one click instead of round-tripping through the
   picker to find and re-toggle it. */
.task-tag-badge--removable {
    font-family: 'DM Sans', sans-serif;
    gap: 0.2rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.task-tag-badge--removable:hover,
.task-tag-badge--removable:focus-visible {
    border-color: var(--clear-red);
    background: color-mix(in srgb, var(--clear-red) 12%, transparent);
}

.task-tag-badge-remove-icon {
    font-size: 12px;
    margin-left: 0.05rem;
    flex-shrink: 0;
    opacity: 0.6;
}

.task-tag-badge--removable:hover .task-tag-badge-remove-icon,
.task-tag-badge--removable:focus-visible .task-tag-badge-remove-icon {
    opacity: 1;
    color: var(--clear-red);
}

/* ── Archived tag badge ── */
.task-tag-badge--archived {
    opacity: 0.5;
    border-style: dashed;
}

.task-tag-badge-archive-icon {
    font-size: 10px;
    margin-right: 0.2rem;
    flex-shrink: 0;
    vertical-align: middle;
}

/* ── Tag search/create picker (row dropdown + task panel) ── */
@keyframes pickerFadeIn {
    from { opacity: 0; transform: translateY(2px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Shell: card chrome + positioning. .tag-picker--row is anchored via
   absolute positioning on .inline-tag-picker-container (position: relative,
   tasks.css) rather than fixed + JS-computed coordinates — see the matching
   comment on .inline-note-popover in habits.css for why.
   .tag-picker--flip-up (set once at open time by the inline script, when
   there isn't room below) renders it above the trigger instead.
   .tag-picker--panel spans the full tag row (position: relative on
   .task-panel-tags, plus the .inline-tag-picker-container override above)
   for the same overflow reason as the create-form fix it replaced. */
.tag-picker {
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 200;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 4px;
    box-shadow: var(--shadow-drop);
    animation: pickerFadeIn 0.12s ease;
}

/* The task tag picker never renders this element until it's meant to be
   open (htmx swaps it in/out entirely), so it never needed this. fk_combo's
   version instead stays in the DOM permanently and toggles the `hidden`
   attribute via JS — but author CSS always wins over the browser's default
   `[hidden]{display:none}`, regardless of specificity, so the `display:
   flex` above silently defeated `hidden` outright. Higher specificity than
   .tag-picker alone forces it back off. */
.tag-picker[hidden] {
    display: none;
}

.tag-picker--row {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 200px;
    max-width: 260px;
}

.tag-picker--row.tag-picker--flip-up {
    top: auto;
    bottom: calc(100% + 4px);
}

.tag-picker--panel {
    position: absolute;
    bottom: calc(100% + 0.5rem);
    left: 0;
    right: 0;
}

.tag-picker-search {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 2px;
}

.tag-picker-search-icon {
    font-size: 16px !important;
    color: var(--text-muted);
    flex-shrink: 0;
}

.tag-picker-input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.82rem;
    padding: 0.35rem 0;
}

.tag-picker-input::placeholder { color: var(--text-muted); }

.tag-picker-list {
    max-height: 220px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.tag-picker-list::-webkit-scrollbar { width: 4px; }
.tag-picker-list::-webkit-scrollbar-track { background: transparent; }
.tag-picker-list::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
.tag-picker-list:hover::-webkit-scrollbar-thumb { background: var(--text-muted); }

.inline-tag-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 0.45rem 0.85rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.82rem;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s;
    text-align: left;
}

/* Same fix as .tag-picker[hidden] above, same reason: fk_combo's items stay
   in the DOM and toggle `hidden` via JS to filter/hide (the task tag picker
   never needed this — non-matching items simply aren't rendered). */
.inline-tag-dropdown-item[hidden] {
    display: none;
}

.inline-tag-dropdown-item:hover,
.inline-tag-dropdown-item--active,
.inline-tag-dropdown-item.is-highlighted {
    background: var(--accent-glow);
}

/* ── Quick-create row, appended when the search query has no exact match ── */
.tag-picker-create-btn {
    color: var(--accent);
    font-weight: 600;
    border-top: 1px solid var(--border-color);
    border-radius: 8px 8px 0 0;
    margin-top: 2px;
}

.tag-picker-create-btn.is-highlighted {
    background: var(--accent-glow);
}

.tag-picker-create-btn .material-icons {
    font-size: 16px;
    flex-shrink: 0;
}

.tag-picker-create-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inline-tag-dropdown-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inline-tag-dropdown-check {
    font-size: 16px !important;
    color: var(--accent);
    flex-shrink: 0;
}

.inline-tag-dropdown-empty {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0.6rem 0.85rem;
}

/* Color dot for tag dropdown items */
.tag-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.tag-dot--blue   { background: var(--accent); }
.tag-dot--green  { background: var(--green); }
.tag-dot--amber  { background: var(--amber); }
.tag-dot--red    { background: #e05c6e; }
.tag-dot--purple { background: #9b8ecf; }
.tag-dot--teal   { background: #4db6ac; }

/* ── Inline project/goal picker dropdown ──
   Anchored via absolute positioning on .inline-tag-picker-container
   (position: relative, tasks.css) — see .tag-picker--row above. Also
   used by shopping_list_picker.html, which sets its own position via an
   inline style already matching these defaults. */
.inline-project-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 200;
    min-width: 220px;
    max-width: 300px;
    max-height: 280px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 4px;
    box-shadow: var(--shadow-drop);
    animation: pickerFadeIn 0.12s ease;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.inline-project-dropdown--flip-up {
    top: auto;
    bottom: calc(100% + 4px);
}

.inline-project-dropdown::-webkit-scrollbar {
    width: 4px;
}

.inline-project-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.inline-project-dropdown::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.inline-project-dropdown:hover::-webkit-scrollbar-thumb {
    background: var(--text-muted);
}

/* Sticks above .inline-project-dropdown-items so it stays visible while
   that list scrolls beneath it inside the same overflow:auto container
   (.inline-project-dropdown itself, above) — reuses .tag-picker-search's
   look verbatim, just anchored differently. */
.inline-project-dropdown-search {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--bg-card);
    margin: -4px -4px 2px;
    padding: 6px 8px;
}

.inline-project-dropdown-section {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.4rem 0.85rem 0.2rem;
}

.inline-project-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 0.45rem 0.85rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.82rem;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s;
    text-align: left;
}

.inline-project-dropdown-item:hover {
    background: var(--accent-glow);
}

/* Same fix as .inline-tag-dropdown-item[hidden] above, same reason: the
   search box added to this picker toggles `hidden` on items via JS to
   filter them. */
.inline-project-dropdown-item[hidden] {
    display: none;
}

.inline-project-dropdown-item .material-icons {
    font-size: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.inline-project-dropdown-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Wrapper used only when an item also shows an inherited-goal subline
   (task-creation picker's project rows) — keeps name+subline stacked
   while .inline-project-dropdown-name's own flex:1/ellipsis rules still
   apply to the name line itself. */
.inline-project-dropdown-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.inline-project-dropdown-item-goal {
    font-size: 0.68rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inline-project-dropdown-empty {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0.6rem 0.85rem;
}

/* Colour variants for inline badges */
.task-tag-badge--blue   { background: color-mix(in srgb, var(--accent) 15%, transparent); border-color: var(--accent);  color: var(--accent); }
.task-tag-badge--green  { background: color-mix(in srgb, var(--green)  15%, transparent); border-color: var(--green);   color: var(--green); }
.task-tag-badge--amber  { background: color-mix(in srgb, var(--amber)  15%, transparent); border-color: var(--amber);   color: var(--amber); }
.task-tag-badge--red    { background: color-mix(in srgb, #e05c6e       15%, transparent); border-color: #e05c6e;        color: #e05c6e; }
.task-tag-badge--purple { background: color-mix(in srgb, #9b8ecf       15%, transparent); border-color: #9b8ecf;        color: #9b8ecf; }
.task-tag-badge--teal   { background: color-mix(in srgb, #4db6ac       15%, transparent); border-color: #4db6ac;        color: #4db6ac; }

