/* ═══════════════════════════════════════════════════════════════════
   S56 — Settings › Calendar: lookup cards (Event categories / Holiday types)
   Goals: ONE border (no card-in-card-in-card), consistent action column,
   clean edit-in-place, colour chip, theme-aware (uses design tokens only).
   Load AFTER s39-calendar.css / app.css (overrides the !important shell).
   ═══════════════════════════════════════════════════════════════════ */

/* ── 1. Card header ─────────────────────────────────────────────── */
.calendar-lookup-card { padding: 20px 22px; }
.calendar-lookup-head { align-items: flex-start; }
.calendar-lookup-title-wrap { align-items: flex-start; gap: 12px; }
.calendar-lookup-title-wrap::before {            /* accent bar */
    content: ""; flex: 0 0 4px; align-self: stretch; min-height: 40px;
    border-radius: 4px; background: var(--primary);
}
.calendar-lookup-title-wrap h3 { font-size: 1.05rem; font-weight: 700; margin: 0 0 4px; line-height: 1.4; }
.calendar-lookup-title-wrap p  { font-size: .84rem; line-height: 1.6; max-width: 62ch; }
.calendar-lookup-count {
    background: color-mix(in srgb, var(--primary) 12%, var(--surface));
    border-color: color-mix(in srgb, var(--primary) 25%, var(--border));
    color: var(--primary); margin-top: 1px;
}

/* ── 2. Panel: flatten nested boxes → a single bordered table ───── */
.calendar-lookup-panel { margin-top: 18px; padding-top: 0; border-top: 0; }
.calendar-lookup-panel .hrms-table-shell {
    padding: 0 !important; border: 0 !important; box-shadow: none !important;
    background: transparent !important; margin: 0 !important;
}
.calendar-lookup-panel .hrms-table-shell > .table-top-controls,
.calendar-lookup-panel .hrms-table-shell > .hrms-table-toolbar {
    padding: 0 !important; margin: 0 0 12px !important; min-height: 0 !important;
}
.calendar-lookup-panel .per-page-control { font-size: .82rem; color: var(--text-muted); gap: 8px; }
.calendar-lookup-panel .per-page-control select { height: 34px; border-radius: var(--radius-sm); }

.calendar-lookup-table-wrap {
    border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
    background: var(--surface); box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.calendar-lookup-table-wrap .data-table { border-collapse: separate; border-spacing: 0; }
.calendar-lookup-table thead th {
    background: var(--surface-alt); color: var(--text-muted);
    font-size: .72rem; font-weight: 700; letter-spacing: .04em;
    padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.calendar-lookup-table tbody td {
    padding: 12px 16px; border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.calendar-lookup-table tbody tr:last-child td { border-bottom: 0; }
.calendar-lookup-table .table-row-number { width: 56px; text-align: center; color: var(--text-muted); font-weight: 600; font-size: .8rem; }
.calendar-lookup-row { transition: background .15s ease; }
.calendar-lookup-row:hover { background: color-mix(in srgb, var(--primary) 4%, var(--surface)); }

/* Names */
.lookup-display { min-height: 36px; font-weight: 500; gap: 8px; }
.calendar-kh-value { font-weight: 500; }
.lookup-system-pill {
    display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
    font-size: .68rem; font-weight: 600; color: var(--text-muted);
    background: var(--surface-alt); border: 1px solid var(--border);
}
.lookup-system-pill svg { width: 11px; height: 11px; }

/* Colour chip */
.calendar-color-display {
    gap: 8px; padding: 4px 10px 4px 6px; border-radius: 999px;
    background: var(--surface-alt); border: 1px solid var(--border);
    min-height: 32px; font-weight: 400;
}
.calendar-color-display i {
    width: 18px; height: 18px; border-radius: 50%; border: 0;
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px color-mix(in srgb, currentColor 0%, var(--border));
}
.calendar-color-display code { font-size: .75rem; letter-spacing: .02em; text-transform: uppercase; }

/* ── 3. Actions: fixed-width group so every row lines up ────────── */
.calendar-col-actions { width: 168px; text-align: right; }
.calendar-lookup-actions { text-align: right; }
.calendar-lookup-actions .row-actions {
    display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; min-width: 132px;
}
.calendar-lookup-actions form { display: inline-flex; margin: 0; }
.calendar-lookup-actions .btn {
    width: 34px; height: 34px; padding: 0; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--surface); border: 1px solid var(--border); color: var(--text-muted);
    box-shadow: none; transition: background .15s, color .15s, border-color .15s, transform .1s;
}
.calendar-lookup-actions .btn svg { width: 16px; height: 16px; }
.calendar-lookup-actions .btn:hover { transform: translateY(-1px); }
.calendar-lookup-actions .calendar-row-edit:hover {
    color: var(--primary); border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 8%, var(--surface));
}
.calendar-lookup-actions .calendar-row-save {
    background: var(--primary); border-color: var(--primary); color: #fff;
}
.calendar-lookup-actions .calendar-row-save:hover { filter: brightness(1.08); }
.calendar-lookup-actions .calendar-row-cancel:hover { background: var(--surface-alt); color: var(--text); }
.calendar-lookup-actions .btn-danger {              /* soft-danger instead of a loud red block */
    background: color-mix(in srgb, #DC2626 8%, var(--surface));
    border-color: color-mix(in srgb, #DC2626 25%, var(--border)); color: #DC2626;
}
.calendar-lookup-actions .btn-danger:hover { background: #DC2626; border-color: #DC2626; color: #fff; }
.calendar-lookup-actions .btn-locked { opacity: .45; cursor: not-allowed; pointer-events: auto; }
.calendar-lookup-actions .btn-locked:hover { transform: none; background: var(--surface); color: var(--text-muted); border-color: var(--border); }

/* Class-driven show/hide (robust against any global .btn display rule) */
.calendar-lookup-row .calendar-row-save,
.calendar-lookup-row .calendar-row-cancel { display: none !important; }
.calendar-lookup-row.is-editing .calendar-row-save,
.calendar-lookup-row.is-editing .calendar-row-cancel { display: inline-flex !important; }
.calendar-lookup-row.is-editing .calendar-row-edit,
.calendar-lookup-row.is-editing .row-delete-slot { display: none !important; }
.calendar-lookup-row .lookup-input[hidden] { display: none !important; }

/* ── 4. Edit-in-place row ───────────────────────────────────────── */
.calendar-lookup-row.is-editing {
    background: color-mix(in srgb, var(--primary) 6%, var(--surface));
    box-shadow: inset 3px 0 0 var(--primary);
}
.lookup-input[type="text"] {
    width: 100%; min-width: 140px; height: 38px; padding: 0 12px;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface); color: var(--text); font: inherit; font-size: .9rem;
    outline: 0; transition: border-color .15s, box-shadow .15s;
}
.lookup-input[type="text"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
.lookup-input[type="color"] {
    width: 46px; height: 38px; padding: 3px; border: 1px solid var(--border);
    border-radius: 10px; background: var(--surface); cursor: pointer;
}

/* ── 5. Footer / pagination ─────────────────────────────────────── */
.calendar-lookup-panel .hrms-table-shell > .hrms-table-footer,
.calendar-lookup-panel .hrms-table-shell > .table-footer {
    border-top: 0 !important; margin: 12px 0 0 !important; padding: 0 !important;
    font-size: .8rem; color: var(--text-muted);
}
.calendar-lookup-panel .pagination .btn,
.calendar-lookup-panel .table-footer .btn { border-radius: 8px; min-width: 34px; height: 32px; }

/* ── 6. Add popover + toggle button ─────────────────────────────── */
.calendar-lookup-head-actions .btn { height: 38px; border-radius: 10px; font-weight: 600; }
.calendar-lookup-toggle { min-width: 96px; }
.calendar-add-details[open] > summary {
    border-color: var(--primary); color: var(--primary);
    background: color-mix(in srgb, var(--primary) 8%, var(--surface));
}
.calendar-lookup-form { border-radius: 14px; padding: 16px; gap: 10px; }
.calendar-lookup-form input[type="text"] {
    height: 40px; border: 1px solid var(--border); border-radius: 10px; padding: 0 12px;
    background: var(--surface); flex: 1 1 200px;
}
.calendar-color-palette { display: flex; gap: 8px; flex-wrap: wrap; width: 100%; padding-top: 2px; }
.calendar-color-swatch {
    width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--surface); cursor: pointer;
    box-shadow: 0 0 0 1px var(--border); transition: transform .12s, box-shadow .12s;
}
.calendar-color-swatch:hover { transform: scale(1.12); }
.calendar-color-swatch.is-active { box-shadow: 0 0 0 2px var(--primary); transform: scale(1.12); }

/* ── 7. Dark mode touch-ups ─────────────────────────────────────── */
[data-theme="dark"] .calendar-lookup-table-wrap { box-shadow: none; }
[data-theme="dark"] .calendar-lookup-actions .btn-danger { background: color-mix(in srgb, #DC2626 14%, var(--surface)); }

/* ── 8. Phones ──────────────────────────────────────────────────── */
@media (max-width: 767.98px) {
    .calendar-lookup-card { padding: 16px 14px; }
    .calendar-lookup-title-wrap::before { display: none; }
    .calendar-lookup-table thead th, .calendar-lookup-table tbody td { padding: 10px 12px; }
    .calendar-lookup-actions .row-actions { min-width: 0; }
}
