/* TrailGoat — Course Library two-pane layout. Loaded after fuel.css (shares
   tokens, .panel, .export-btn, .course-stats, .map-wrap, .elev-*, .plan-*).
   Left = sticky course list; right = the selected course's full detail. */

.lib-layout {
    display: grid; grid-template-columns: minmax(270px, 350px) 1fr; gap: 18px;
    align-items: start; margin-top: 8px;
}

/* ---- Left rail ---- */
.lib-side {
    position: sticky; top: 14px; align-self: start;
    display: flex; flex-direction: column; gap: 12px;
    max-height: calc(100vh - 28px);
}
.lib-toolbar { display: flex; gap: 8px; }
.lib-search {
    flex: 1; background: var(--glass-2); color: var(--ink); border: 1px solid var(--line);
    border-radius: 999px; padding: 10px 16px; font-family: inherit; font-size: 0.92rem;
}
.lib-search:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255,122,26,0.15); }
.lib-manage {
    background: var(--glass-2); color: var(--muted); border: 1px solid var(--line);
    border-radius: 999px; padding: 9px 15px; font-family: 'Sora', sans-serif; font-weight: 600;
    font-size: 0.82rem; cursor: pointer; transition: all 0.18s ease; white-space: nowrap;
}
.lib-manage:hover { color: var(--ink); border-color: var(--orange); }
.lib-manage.active { color: var(--gold); border-color: rgba(255,210,63,0.5); background: rgba(255,210,63,0.08); }

.lib-count { color: var(--muted); font-size: 0.82rem; padding: 0 4px; }

/* The scrollable list takes the remaining height of the sticky rail */
.lib-list { display: flex; flex-direction: column; gap: 9px; overflow-y: auto; padding: 2px 2px 6px; }
.lib-list::-webkit-scrollbar { width: 8px; }
.lib-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 8px; }

/* Course list items (vertical pills/cards) */
.lib-item {
    position: relative; text-align: left; width: 100%; cursor: pointer;
    background: var(--glass); border: 1px solid var(--line); border-radius: 14px;
    padding: 13px 15px; color: inherit; font-family: inherit;
    transition: border-color 0.16s ease, background 0.16s ease, transform 0.12s ease;
}
.lib-item:hover { border-color: rgba(255,122,26,0.55); transform: translateY(-1px); }
.lib-item.active { border-color: var(--orange); background: rgba(255,122,26,0.10);
    box-shadow: inset 3px 0 0 var(--orange); }
.lib-item-name { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 0.98rem; color: var(--ink);
    padding-right: 22px; line-height: 1.25; }
.lib-item-stats { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; font-size: 0.82rem; color: var(--muted); }
.lib-item-stats strong { color: var(--ink); font-weight: 700; }
.lib-tag { color: var(--gold); border: 1px solid rgba(255,210,63,0.4); border-radius: 999px;
    padding: 0 7px; font-size: 0.72rem; }
.lib-item-loc { color: var(--muted); font-size: 0.78rem; margin-top: 5px; }
.lib-item-date { color: var(--muted); font-size: 0.78rem; margin-top: 5px; opacity: 0.85; }
/* per-item delete (manage mode) */
.lib-del { position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%;
    background: rgba(255,93,115,0.12); color: var(--coral); border: 1px solid rgba(255,93,115,0.4);
    font-size: 0.9rem; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.lib-del:hover { background: var(--coral); color: #1a0508; }

.lib-empty { color: var(--muted); font-size: 0.9rem; padding: 14px 6px; font-style: italic; }

/* ---- Manager upload dropzone ---- */
.lib-upload { }
.lib-dropzone {
    display: flex; flex-direction: column; align-items: center; gap: 5px; text-align: center;
    border: 1.5px dashed rgba(139,108,255,0.5); border-radius: 14px; padding: 16px 14px; cursor: pointer;
    background: rgba(139,108,255,0.06); transition: border-color 0.18s ease, background 0.18s ease;
}
.lib-dropzone:hover, .lib-dropzone.drag { border-color: var(--violet); background: rgba(139,108,255,0.12); }
.lib-dz-icon { font-size: 1.4rem; }
.lib-dz-text { font-size: 0.85rem; color: var(--muted); }
.lib-dz-text strong { color: var(--ink); font-family: 'Sora', sans-serif; }
.lib-dz-status { font-size: 0.8rem; font-weight: 600; }
.lib-dz-status.err { color: var(--coral); }
.lib-dz-status.ok { color: var(--moss); }

/* ---- Bulk import progress ---- */
.lib-bulk { margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.lib-bulk-head { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 0.82rem; color: var(--ink);
    padding: 9px 12px; background: var(--glass-2); border-bottom: 1px solid var(--line); }
.lib-bulk-list { max-height: 260px; overflow-y: auto; }
.lib-bulk-row { display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 7px 12px; font-size: 0.8rem; border-bottom: 1px solid var(--line); }
.lib-bulk-row:last-child { border-bottom: none; }
.lbr-name { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lbr-status { color: var(--muted); font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.lbr-status.ok { color: var(--moss); }
.lbr-status.skip { color: var(--gold); }
.lbr-status.err { color: var(--coral); }

/* ---- Right detail panel ---- */
.lib-detail { min-height: 420px; }
#lib-map { height: 360px; width: 100%; background: var(--bg-1); }
.lib-detail-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
    min-height: 380px; text-align: center; color: var(--muted);
}
.lib-detail-empty[hidden] { display: none; }
.lib-detail-empty-icon { font-size: 2.6rem; opacity: 0.7; }
.lib-detail-empty p { max-width: 26rem; }

.lib-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.lib-detail-titles { min-width: 0; }
.lib-detail-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.lib-detail-actions[hidden] { display: none; }   /* explicit display beats the [hidden] UA rule */
.pv-meta { color: var(--muted); font-size: 0.86rem; margin-top: 6px; }

.lib-del-btn {
    background: rgba(255,93,115,0.1); color: var(--coral); border: 1px solid rgba(255,93,115,0.4);
    border-radius: 999px; padding: 8px 16px; font-family: 'Sora', sans-serif; font-weight: 600;
    font-size: 0.85rem; cursor: pointer; transition: all 0.18s ease;
}
.lib-del-btn:hover { background: var(--coral); color: #1a0508; }

/* ---- New-course save bar (manager) ---- */
.lib-savebar {
    margin: 16px 0 4px; padding: 16px; border: 1px solid rgba(139,108,255,0.4);
    background: rgba(139,108,255,0.07); border-radius: 14px;
}
.lib-savebar-row { display: flex; gap: 10px; flex-wrap: wrap; }
.lib-save-input {
    flex: 1; min-width: 180px; background: var(--glass-2); color: var(--ink); border: 1px solid var(--line);
    border-radius: 10px; padding: 10px 14px; font-family: inherit; font-size: 0.95rem;
}
.lib-save-input:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(139,108,255,0.15); }
.lib-save-date { flex: 0 0 auto; min-width: 0; color-scheme: dark; }
.lib-savebar-actions { display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.lib-discard-btn {
    background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 999px;
    padding: 8px 16px; font-family: 'Sora', sans-serif; font-weight: 600; font-size: 0.85rem; cursor: pointer;
}
.lib-discard-btn:hover { color: var(--ink); border-color: var(--coral); }
.lib-save-status { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.lib-save-status.ok { color: var(--moss); }
.lib-save-status.err { color: var(--coral); }

/* ---- Responsive: stack the rail above the detail ---- */
@media (max-width: 860px) {
    .lib-layout { grid-template-columns: 1fr; }
    .lib-side { position: static; max-height: none; }
    .lib-list { max-height: 360px; }
}
