/* ============================================================================
   Generic data table (.dc-table) — the default table style for the app.

   Server-rendered via django-tables2 (template tables/_render.html), swapped in
   place via HTMX. Provides: a card wrapper, a fixed-height scroll area with a
   sticky header, sort indicators, zebra striping, hover, an empty state and an
   AG-Grid-style footer (page size + record range + pagination).

   Cells render plain text by default. Per-table specifics (avatars, badges,
   status dots, custom widths) belong in a feature stylesheet — see users.css
   for the user-management example. Colours use the --dc-* tokens from
   dc-theme.css.
   ============================================================================ */

/* --dc-dark-blue, --dc-blue and --dc-primary-rgb come from dc-theme.css;
   --color-border is only used by this table system, so define it here. */
:root {
    --color-border: #e5e7eb;
}

/* --- Toolbar / search ---------------------------------------------------- */
.dc-table-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
}

.dc-table-search {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 100%;
    max-width: 320px;
}

.dc-table-search-icon {
    position: absolute;
    left: 14px;
    color: #9ca3af;
    font-size: 0.8125rem;
    pointer-events: none;
}

.dc-table-search-input {
    width: 100%;
    padding: 10px 14px 10px 36px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    font-size: 0.875rem;
    background: white;
    color: var(--dc-dark-blue);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dc-table-search-input:focus {
    outline: none;
    border-color: var(--dc-blue);
    box-shadow: 0 0 0 3px rgba(var(--dc-primary-rgb), 0.1);
}

.dc-table-search-input::placeholder {
    color: #9ca3af;
}

/* --- Wrapper (card: scroll area + footer) -------------------------------- */
.dc-table-wrapper {
    background-color: white;
    border-radius: 14px;
    overflow: hidden;            /* clip rounded corners */
    box-shadow:
        0 0 0 1px rgba(15, 23, 42, 0.05),
        0 1px 2px rgba(15, 23, 42, 0.03),
        0 10px 28px -12px rgba(15, 23, 42, 0.10);
    transition: opacity 0.2s ease;
}

.dc-table-wrapper.htmx-request {
    opacity: 0.5;
    pointer-events: none;
}

/* Fixed-height, scrollable body. Header stays pinned via sticky <th>.
   The 20rem offset reserves room for the navbar, page header, search bar
   and footer — tune if your chrome height changes. */
.dc-table-scroll {
    height: calc(100vh - 20rem);
    min-height: 240px;
    overflow: auto;
    /* Subtle, always-present scrollbar. The reserved gutter is filled by a
       faint rounded thumb (darkens on hover) so it reads as a scrollbar
       instead of leaving a bare white lane against the zebra rows. A truly
       disappearing/overlay scrollbar needs a JS overlay lib — browsers on
       Windows/Linux always reserve gutter space, which shows as white when
       the thumb is transparent. */
    scrollbar-width: thin;                                /* Firefox */
    scrollbar-color: rgba(15, 23, 42, 0.09) transparent;  /* thumb, track */
    transition: scrollbar-color 0.2s ease;
}
.dc-table-scroll:hover,
.dc-table-scroll:focus-within {
    scrollbar-color: rgba(15, 23, 42, 0.28) transparent;  /* Firefox */
}

/* WebKit/Blink (Chrome, Edge, Safari): a floating rounded thumb — the 3px
   transparent border (with background-clip) insets it so the reserved lane
   reads as padding around the thumb, not a hard white edge. */
.dc-table-scroll::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}
.dc-table-scroll::-webkit-scrollbar-track {
    background: transparent;
}
.dc-table-scroll::-webkit-scrollbar-thumb {
    background-color: rgba(15, 23, 42, 0.09);
    border-radius: 10px;
    border: 3px solid transparent;
    background-clip: content-box;
    transition: background-color 0.2s ease;
}
.dc-table-scroll:hover::-webkit-scrollbar-thumb {
    background-color: rgba(15, 23, 42, 0.28);
}
.dc-table-scroll::-webkit-scrollbar-thumb:hover {
    background-color: rgba(15, 23, 42, 0.45);
}
.dc-table-scroll::-webkit-scrollbar-corner {
    background: transparent;
}

/* --- Table root ---------------------------------------------------------- */
.dc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    color: var(--dc-dark-blue);
    font-feature-settings: "tnum" on, "lnum" on;
}

/* --- Header -------------------------------------------------------------- */
.dc-table thead th {
    text-align: left;
    padding: 16px 18px 13px;
    font-weight: 600;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #64748b;
    background: linear-gradient(to bottom, #fbfbfd 0%, #f5f6f9 100%);
    border-bottom: 1px solid rgba(15, 23, 42, 0.07);
    white-space: nowrap;
    /* Pin the header while the body scrolls. box-shadow keeps the divider
       visible (border-collapse drops borders on sticky cells when scrolled). */
    position: sticky;
    top: 0;
    z-index: 2;
    box-shadow: inset 0 -1px 0 rgba(15, 23, 42, 0.07);
}

/* Sort links (django-tables2 renders <a> in sortable headers) */
.dc-table thead th a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    user-select: none;
    transition: color 0.15s ease;
}

.dc-table thead th a:hover { color: var(--dc-dark-blue); }

/* Sort indicator triangle on orderable columns */
.dc-table thead th.orderable a::after {
    content: "";
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid currentColor;
    opacity: 0.3;
    transition: opacity 0.15s ease;
}

.dc-table thead th.orderable a:hover::after { opacity: 0.6; }

.dc-table thead th.asc a::after {
    border-top: none;
    border-bottom: 4px solid var(--dc-blue);
    opacity: 1;
}

.dc-table thead th.desc a::after {
    border-top: 4px solid var(--dc-blue);
    opacity: 1;
}

.dc-table thead th.asc a,
.dc-table thead th.desc a { color: var(--dc-dark-blue); }

/* --- Body rows ----------------------------------------------------------- */
.dc-table tbody td {
    padding: 14px 18px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.045);
    vertical-align: middle;
    white-space: nowrap;
    transition: background-color 0.12s ease, box-shadow 0.18s ease;
}

.dc-table tbody tr:last-child td { border-bottom: none; }

/* Zebra striping — light grey on every other row. */
.dc-table tbody tr:nth-child(even) td { background-color: #f6f8fa; }

/* Hover sits above the zebra colour (declared after so it wins on equal specificity). */
.dc-table tbody tr:hover td { background-color: #eef2f7; }

/* Rows that open a detail view (opt in via row_attrs class). */
.dc-row-link { cursor: pointer; }

/* Blue accent ribbon on the first cell when hovered. */
.dc-table tbody tr:hover td:first-child {
    box-shadow: inset 3px 0 0 0 var(--dc-blue);
}

/* --- Empty state --------------------------------------------------------- */
.dc-table tbody td[colspan] {
    text-align: center;
    padding: 48px 24px;
    color: #6b7280;
    white-space: normal;
}

/* --- Footer (page size + record range + navigation) ---------------------- */
.dc-table-footer {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 12px 18px;
    border-top: 1px solid rgba(15, 23, 42, 0.07);
    background: #f9fafb;
    font-size: 0.8125rem;
    color: #64748b;
}

.dc-pager-size {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: auto;   /* push range + nav to the right */
}

.dc-pager-select {
    padding: 6px 30px 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background-color: white;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    color: var(--dc-dark-blue);
    font-size: 0.8125rem;
    cursor: pointer;
    appearance: none;
}

.dc-pager-select:focus {
    outline: none;
    border-color: var(--dc-blue);
    box-shadow: 0 0 0 3px rgba(var(--dc-primary-rgb), 0.1);
}

.dc-pager-info {
    white-space: nowrap;
}

.dc-pager-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.dc-pager-current {
    padding: 0 10px;
    white-space: nowrap;
    color: var(--dc-dark-blue);
    font-weight: 500;
}

.dc-pager-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: white;
    color: var(--dc-dark-blue);
    text-decoration: none;
    font-size: 0.95rem;
    line-height: 1;
    transition: all 0.15s ease;
}

a.dc-pager-btn:hover {
    background: #f3f4f6;
    border-color: var(--dc-blue);
    color: var(--dc-blue);
}

.dc-pager-btn.disabled {
    opacity: 0.45;
    cursor: default;
}

/* --- Responsive ---------------------------------------------------------- */
@media (max-width: 900px) {
    .dc-table thead th,
    .dc-table tbody td {
        padding: 10px 12px;
        font-size: 0.8125rem;
    }
    .dc-table-search { max-width: none; }
}

/* ============================================================================
   Generic single-button filter dropdown (used by DC-table pages that filter on
   several fields at once — a "Filters" button opening a panel of selects).
   ============================================================================ */
.dc-filter-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.dc-filter-dropdown { position: relative; }
.dc-filter-btn {
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 10px;
    background: white;
    color: var(--dc-dark-blue);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.dc-filter-btn::-webkit-details-marker { display: none; }
.dc-filter-btn::marker { content: ""; }
.dc-filter-btn:hover { border-color: var(--dc-blue); }
.dc-filter-dropdown[open] .dc-filter-btn {
    border-color: var(--dc-blue);
    box-shadow: 0 0 0 3px rgba(var(--dc-primary-rgb), 0.1);
}
.dc-filter-caret { font-size: 0.7rem; color: #94a3b8; transition: transform 0.15s ease; }
.dc-filter-dropdown[open] .dc-filter-caret { transform: rotate(180deg); }
.dc-filter-count {
    background: var(--dc-blue);
    color: white;
    border-radius: 20px;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 1px 7px;
}
.dc-filter-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 30;
    min-width: 260px;
    background: white;
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 12px;
    box-shadow: 0 12px 30px -8px rgba(15, 23, 42, 0.22);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.dc-filter-group { display: flex; flex-direction: column; gap: 6px; }
.dc-filter-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}
.dc-filter-select {
    appearance: none;
    width: 100%;
    padding: 10px 34px 10px 14px;
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 10px;
    background-color: white;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    color: var(--dc-dark-blue);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.dc-filter-select:focus {
    outline: none;
    border-color: var(--dc-blue);
    box-shadow: 0 0 0 3px rgba(var(--dc-primary-rgb), 0.1);
}

/* --- Searchable select (dc-searchselect): a text input that filters an inline
   list of options; the chosen value lives in a hidden input carried by the
   filter form. For long option lists (e.g. leidinggevenden). ------------- */
.dc-searchselect { position: relative; }
.dc-searchselect-input {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    padding: 10px 14px;
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 10px;
    background: white;
    color: var(--dc-dark-blue);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: text;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.dc-searchselect-input:focus {
    outline: none;
    border-color: var(--dc-blue);
    box-shadow: 0 0 0 3px rgba(var(--dc-primary-rgb), 0.1);
}
.dc-searchselect-list {
    display: none;
    list-style: none;
    margin: 4px 0 0;
    padding: 4px;
    max-height: 200px;
    overflow-y: auto;
    background: white;
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 10px;
}
.dc-searchselect.open .dc-searchselect-list { display: block; }
.dc-searchselect-list li {
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--dc-dark-blue);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dc-searchselect-list li:hover { background: #f1f5f9; }
.dc-searchselect-list li.selected {
    background: rgba(var(--dc-primary-rgb), 0.08);
    font-weight: 600;
}
