/* DiveLog shared form components. Class prefix: dlf- ("DiveLog form"). */

.dlf-field {
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
}

.dlf-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
    letter-spacing: 0.2px;
}

.dlf-required { color: var(--err); }

.dlf-hint {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 6px;
    line-height: 1.45;
}

.dlf-error {
    font-size: 12.5px;
    color: var(--err);
    min-height: 0;
    margin-top: 6px;
    line-height: 1.4;
}

.dlf-has-error .dlf-input,
.dlf-has-error .dlf-combo {
    border-color: var(--err);
}

/* ── Input ───────────────────────────────────────────────────────────── */
/* §18 form controls. Applied to `.dlf-input` — the class DL.Form actually
   emits — rather than to the spec's `.dl-input`, because that is where it wins:
   every form in the app is built by DL.Form, and a parallel class would style
   nothing. `.dl-input` in dl-components.css carries the same values for new
   hand-written markup.
   Three things changed here beyond the tokens:
     - min-height is now the 44px WCAG 2.5.5 target. It was ~36px.
     - the focus ring was a hardcoded rgba(56,189,248,.15) — the OLD accent, so
       it no longer matched any theme. It is now var(--accent-soft).
     - readonly is visibly distinct from disabled: readonly content is still
       selectable and copyable, so dimming it the same way was wrong. */
.dlf-input {
    width: 100%;
    min-height: var(--touch-target);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-subtle);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: var(--font-size-sm);
    transition: border-color var(--duration-normal) var(--ease-standard),
                box-shadow var(--duration-normal) var(--ease-standard),
                background-color var(--duration-normal) var(--ease-standard);
}
.dlf-input:hover:not(:disabled):not([readonly]) { border-color: var(--border-strong); }
.dlf-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.dlf-input:disabled { opacity: .55; cursor: not-allowed; }
.dlf-input[readonly] { background: transparent; border-style: dashed; }
/* flatpickr makes its input readonly so the calendar owns the value; that
   is an editable field, not a read-only one, so it keeps the normal surface. */
.dlf-input.dlf-input-date[readonly],
.dlf-input.flatpickr-input[readonly] { background: var(--bg-subtle); border-style: solid; cursor: pointer; }
.dlf-input.dlf-input-date[readonly]:hover { border-color: var(--border-strong); }
/* Unit suffix: DL.Form.number({unit: "m"}). */
.dlf-unit-wrap { display: flex; align-items: stretch; }
.dlf-unit-wrap > .dlf-input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); min-width: 0; }
.dlf-unit {
    display: inline-flex;
    align-items: center;
    padding: 0 var(--space-3);
    border: 1px solid var(--border);
    border-left: 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: var(--bg-elev);
    color: var(--text-muted);
    font-size: var(--font-size-xs);
    white-space: nowrap;
}
.dlf-input[aria-invalid="true"] { border-color: var(--err); }
.dlf-input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--err-soft); }
.dlf-input-number { font-variant-numeric: tabular-nums; }
/* A textarea must not be forced to a single control height. */
textarea.dlf-input { min-height: 6rem; resize: vertical; }

/* The dropdown control is now the searchable combobox — styles live in
   /common/css/dl-combo.css (.dlf-combo / .dl-combo). Pages that load
   dl-form.css are expected to also load dl-combo.css. */

/* ── Tags (multi-select chips) ───────────────────────────────────────── */
/* A row of chips above a single "+ Add" pill that opens DL.Combo with the
   remaining choices. The whole thing reads as an input field by sitting
   inside the same border + radius as .dlf-input, so it visually lines up
   with the rest of the form. */
.dlf-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 8px;
    min-height: 40px;
}
.dlf-tags-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
}
.dlf-tags-empty {
    color: var(--text-muted);
    font-size: 13px;
    padding: 4px 2px;
}
.dlf-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 4px 4px 10px;
    background: var(--accent-soft);
    color: var(--text);
    border-radius: 999px;
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
}
.dlf-tag-chip-label { font-weight: 500; }
/* Chips with a thumbnail image (e.g. animal sightings). The chip
 * shrinks its left padding so the image sits flush against the
 * rounded edge; the image is a small rounded square. */
.dlf-tag-chip-has-image { padding-left: 3px; }
.dlf-tag-chip-image {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 auto;
    background: var(--bg-elev);
}
/* Inline-SVG placeholder used when an option carries placeholderHtml
 * but no on-disk photo (e.g. seed animals without a user-uploaded
 * picture). Matches the .dlf-tag-chip-image footprint so the chip
 * keeps the same shape; the light-blue palette mirrors the 96 px
 * animal-card placeholder (.am-avatar-placeholder) — fixed colours,
 * not theme tokens, because the placeholder is media, not chrome. */
.dlf-tag-chip-placeholder {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    flex: 0 0 auto;
    background: #ffffff;
    border: 1px solid #7dd3fc;     /* sky-300 — matches animal cards */
    color: var(--accent);          /* fill for the inline SVG */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    overflow: hidden;
}
.dlf-tag-chip-placeholder svg {
    width: 70%;
    height: 70%;
    display: block;
    /* svgFor() returns paths with fill="currentColor", so the color
     * rule above tints the silhouette. */
}
/* Items+sets picker uses the placeholder slot to surface an FNV-1a → HSL
 * tile that fills the entire slot (DL.Items.chipPlaceholderHtml). The
 * `.im-chip-fill` marker class on the SVG opts the chip out of the
 * sky-blue ring above so the colour tile reads cleanly. `:has()` is
 * supported in every target browser (Safari 15.4+, Chrome 105+,
 * Edge 105+). Scoped to the items chip — animal chips stay sky-blue. */
.dlf-tag-chip-placeholder:has(> svg.im-chip-fill) {
    background: transparent;
    border: 0;
}
.dlf-tag-chip-placeholder > svg.im-chip-fill {
    width: 100%;
    height: 100%;
    display: block;
}
.dlf-tag-chip-remove {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    line-height: 16px;
    padding: 0;
    transition: background .12s ease, color .12s ease;
}
.dlf-tag-chip-remove:hover {
    background: rgba(248,113,113,0.18);
    color: var(--err);
}
.dlf-tags-add {
    appearance: none;
    background: transparent;
    color: var(--accent);
    border: 1px dashed var(--border);
    border-radius: 999px;
    padding: 3px 12px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .12s ease, color .12s ease, background .12s ease;
}
.dlf-tags-add:hover:not(:disabled) {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.dlf-tags-add.dlf-tags-add-open {
    border-style: solid;
    border-color: var(--accent);
}
.dlf-tags-add:disabled,
.dlf-tags-add-disabled {
    color: var(--text-muted);
    cursor: not-allowed;
    border-style: dotted;
}

/* ── Toggle ──────────────────────────────────────────────────────────── */
.dlf-toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
/* Off: a visible track (--border-strong) with a solid knob, so "off" reads
   as a control on the dark themes too. On: accent track + accent knob. */
.dlf-toggle {
    position: relative;
    flex: 0 0 auto;
    width: 44px;
    height: 24px;
    border-radius: 999px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-strong);
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
    padding: 0;
}
.dlf-toggle:hover { border-color: var(--accent); }
.dlf-toggle:focus { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.dlf-toggle:focus-visible { outline: var(--focus-width) solid var(--focus-ring); outline-offset: var(--focus-offset); }
/* 44 px hit area on every pointer, without changing the 44x24 track. */
.dlf-toggle::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: var(--touch-target);
    height: var(--touch-target);
    transform: translate(-50%, -50%);
}
.dlf-toggle-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-muted);
    box-shadow: 0 1px 2px rgba(0,0,0,.25);
    transition: left .18s ease, background .18s ease;
}
.dlf-toggle.dlf-toggle-on {
    background: var(--accent-soft);
    border-color: var(--accent);
}
.dlf-toggle.dlf-toggle-on .dlf-toggle-knob {
    left: 22px;
    background: var(--accent);
}
.dlf-toggle:disabled { cursor: not-allowed; opacity: .55; }
/* DL.Form.toggle({stateText: true}): "On" / "Off" next to the switch. */
.dlf-toggle-state {
    min-width: 2.5em;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}
.dlf-toggle-on + .dlf-toggle-state { color: var(--accent); }

/* ── Buttons ─────────────────────────────────────────────────────────
   DL.Form.button() still emits `dlf-button dlf-button-<kind>`, but the rules
   now live with `.dl-btn` in dl-components.css as aliases of the same
   declarations — one button system for the whole app. Do not restyle
   .dlf-button here; change .dl-btn and both follow. */

/* ── Settings layout ─────────────────────────────────────────────────── */
.cfg-shell {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 24px;
    align-items: start;
}
.cfg-sidebar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    position: sticky;
    top: 80px;
}
.cfg-sidebar-link {
    display: block;
    padding: 8px 12px;
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
}
.cfg-sidebar-link:hover {
    background: var(--bg-elev);
    color: var(--text);
    text-decoration: none;
}
.cfg-sidebar-link.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.cfg-content { min-width: 0; }

.cfg-group {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 18px;
}
.cfg-group-title {
    margin: 0 0 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.cfg-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 12px;
}

/* ── Catalogs panel (synthetic settings entry) ─────────────────── */
/* Renders a vertical stack of catalog cards inside the standard
   .cfg-group container. Each card is self-contained: title, blurb,
   live row count, and a primary action that opens the modal editor. */
.cfg-group-hint {
    margin: 0 0 18px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.5;
}
.catalog-card {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "title    actions"
        "desc     actions"
        "count    actions";
    gap: 4px 16px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-elev);
    margin-bottom: 12px;
    align-items: center;
}
.catalog-card:last-child { margin-bottom: 0; }
.catalog-card-title {
    grid-area: title;
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}
.catalog-card-desc {
    grid-area: desc;
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.45;
}
.catalog-card-count {
    grid-area: count;
    font-size: 12.5px;
    opacity: 0.75;
    font-variant-numeric: tabular-nums;
}
.catalog-card-actions {
    grid-area: actions;
    align-self: center;
}
@media (max-width: 600px) {
    .catalog-card {
        grid-template-columns: 1fr;
        grid-template-areas: "title" "desc" "count" "actions";
    }
    .catalog-card-actions { justify-self: stretch; }
    .catalog-card-actions .dlf-button { width: 100%; }
}

@media (max-width: 720px) {
    .cfg-shell { grid-template-columns: 1fr; }
    .cfg-sidebar { position: static; }
}

/* ── Toasts ──────────────────────────────────────────────────────────── */
.dlf-toasts {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}
.dlf-toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 16px;
    color: var(--text);
    font-size: 13.5px;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity .2s ease, transform .2s ease;
}
.dlf-toast.dlf-toast-show { opacity: 1; transform: translateY(0); }
.dlf-toast-success { border-color: var(--ok); }
.dlf-toast-error { border-color: var(--err); color: var(--err); }

/* ── DL.PhoneField (dl-phone-field.js) ─────────────────────────────
   Flag + dial-code country button next to a tel input. Lives in
   dl-form.css because the JS already auto-loads through dl-form
   consumers; sites that use the widget pick it up implicitly. */
.dlf-phone-row {
    display: flex;
    gap: 6px;
    align-items: stretch;
}
.dlf-phone-cc {
    /* Sized and filled to match .dlf-input pixel-for-pixel — it sits in
     * the same flex row as .dlf-phone-local, so a different height,
     * radius or surface splits one control into two mismatched halves. */
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 var(--space-3);
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    cursor: pointer;
    line-height: 1.4;
    min-height: var(--touch-target);
    white-space: nowrap;
}
.dlf-phone-cc:focus {
    outline: none;
    border-color: var(--accent);
}
.dlf-phone-flag {
    /* Emoji rendering varies by OS — bump the size so the flag is
     * recognisable next to a small dial-code label. */
    font-size: 18px;
    line-height: 1;
}
.dlf-phone-dial {
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    font-size: 13px;
}
.dlf-phone-caret {
    color: var(--text-muted);
    font-size: 10px;
    margin-left: 2px;
}
.dlf-phone-local {
    flex: 1;
    min-width: 0;          /* let the flex item shrink past min-content */
}

/* (The toggle's 44 px hit area now applies on every pointer — see Toggle.) */
