/* lists.css — the list pages (plants, strains, sensors, activities): the
 * controls bar, filters and tables they share as .list-*, and what each adds.
 */

/* ===== Shared List View Base (Strains, Sensors, Plants, Activities) ===== */
.list-controls {
    margin-bottom: 1.5rem;
}
.list-controls-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}
.list-controls-row .btn-group .view-button,
.list-controls-row .btn-group .layout-toggle {
    border: 1px solid var(--color-view-btn-border);
    background: transparent;
    color: var(--color-fg);
    font-weight: 500;
    font-size: 0.85rem;
    padding: 0.35rem 0.9rem;
    transition: all 0.15s;
}
.list-controls-row .btn-group .layout-toggle {
    padding: 0.35rem 0.65rem;
}
.list-controls-row .btn-group .view-button:hover,
.list-controls-row .btn-group .layout-toggle:hover {
    background: var(--color-view-btn-hover-bg);
    color: var(--color-view-btn-hover-fg);
}
.list-controls-row .btn-group .view-button.active,
.list-controls-row .btn-group .layout-toggle.active {
    background: var(--color-view-btn-active-bg);
    color: var(--color-view-btn-active-fg);
    border-color: var(--color-view-btn-active-border);
}
.list-search-wrap {
    position: relative;
    flex: 1;
    min-width: 180px;
    max-width: 320px;
}
.list-search-icon {
    position: absolute;
    left: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-muted);
    font-size: 0.8rem;
    pointer-events: none;
}
.list-search-wrap .form-control {
    padding-left: 2rem;
    background: var(--color-input-bg);
    color: var(--color-input-fg);
    border-color: var(--color-input-border);
}
.list-filters-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.list-filter-group {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.list-filter-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.list-filter-group .form-select,
.activities-filter-group .form-control {
    min-width: 120px;
    font-size: 0.85rem;
    background: var(--color-input-bg);
    color: var(--color-input-fg);
    border-color: var(--color-input-border);
}
.list-result-count {
    font-size: 0.82rem;
}

.list-table-wrap {
    border-radius: var(--radius-lg);
    overflow: hidden;
    overflow-x: auto;
}
.list-table {
    font-size: 0.9rem;
    margin-bottom: 0;
}
.strains-table,
.sensors-table,
.plants-table {
    background: var(--color-table-bg);
}
.list-table thead th {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-muted);
    white-space: nowrap;
    padding: 0.6rem 0.75rem;
}
.list-table td {
    padding: 0.6rem 0.75rem;
    vertical-align: middle;
    border-color: var(--color-card-border);
}
.strains-table thead th,
.sensors-table thead th,
.plants-table thead th {
    background: var(--color-table-th);
    border-bottom: 2px solid var(--color-card-border);
}
.st-row:hover,
.sn-row:hover,
.pt-row:hover {
    background: var(--color-row-hover);
}

.st-sortable,
.sn-sortable,
.pt-sortable,
.al-sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.st-sortable:hover,
.sn-sortable:hover,
.pt-sortable:hover,
.al-sortable:hover {
    color: var(--color-accent);
}

/* ===== Sensors Listing Page ===== */
.sensors-action-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.sn-sensor-name {
    font-weight: 600;
    color: var(--color-accent);
}
.sn-th-name { min-width: 160px; }
.sn-th-zone { min-width: 100px; }
.sn-th-source { min-width: 100px; }
.sn-th-device { min-width: 100px; }
.sn-th-type { min-width: 80px; }
.sn-th-unit { min-width: 60px; }
.sn-th-visibility { min-width: 100px; }
.sensors-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
}

/* ===== Activity Log page ===== */
/* Activity table */
.activities-table {
    font-size: 0.95rem;
}
.activities-table thead th {
    background: transparent;
    border-color: var(--color-border);
}
.activities-table tbody tr {
    transition: background-color 0.15s;
}
.activities-table tbody tr:hover {
    background-color: var(--color-row-hover);
}
.al-th-date {
    width: 12rem;
}
.al-th-plant {
    width: 12%;
}
.al-th-strain {
    width: 12%;
}
.al-th-zone {
    width: 10%;
}
.al-th-activity {
    width: 12%;
}
.al-th-note {
    flex-grow: 1;
}
.al-cell-date {
    white-space: nowrap;
    font-size: 0.9rem;
}
.al-cell-plant {
    white-space: nowrap;
}
.al-cell-strain {
    white-space: nowrap;
}
.al-cell-zone {
    white-space: nowrap;
}
.al-cell-activity {
    white-space: nowrap;
}
.al-cell-note {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.45;
    font-size: 0.9rem;
}
.activities-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    color: var(--color-muted);
}

@media (max-width: 575.98px) {
    .sensor-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Rows that open something when clicked */
.st-row,
.sn-row,
.pt-row,
.al-row {
    cursor: pointer;
}

/* ===== Filters on small screens ===== */
/* From md up the filters row is always there. Below it, the row folds away
   behind the Filters button, which Bootstrap's collapse opens. */
.list-filters-toggle {
    display: none;
    white-space: nowrap;
}
.list-filters-count {
    color: var(--color-on-primary);
    background: var(--color-primary);
}
@media (min-width: 768px) {
    .list-filters-row.collapse {
        display: flex !important;
        height: auto !important;
    }
}
@media (max-width: 767.98px) {
    .list-filters-toggle {
        display: inline-flex;
        align-items: center;
    }
    .list-search-wrap {
        flex: 1 1 100%;
    }
}

/* ===== Pager ===== */
.list-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1rem;
}
.list-pager[hidden] {
    display: none;
}
.list-pager .btn {
    min-width: 2.5rem;
    min-height: 2.5rem;
}
.list-pager-status {
    font-size: 0.85rem;
    color: var(--color-muted);
}

/* ===== Activity log on small screens ===== */
/* Six columns do not fit a phone. Each activity becomes a small block:
   plant and activity on the first line, then when and where, then the
   note. The column headers, and sorting by them, are for wider screens.
   Tablets get this too: at their width the note column was squeezed to a
   word per line. */
@media (max-width: 991.98px) {
    .activities-table thead {
        display: none;
    }
    .activities-table,
    .activities-table tbody {
        display: block;
    }
    .activities-table tr.al-row {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 0.15rem 0.75rem;
        padding: 0.65rem 0.75rem;
        border-bottom: 1px solid var(--color-card-border);
    }
    .activities-table tr.al-row > td {
        display: block;
        padding: 0;
        border: 0;
        white-space: normal;
    }
    .activities-table .al-cell-plant {
        grid-column: 1;
        grid-row: 1;
        font-weight: 600;
    }
    .activities-table .al-cell-activity {
        grid-column: 2;
        grid-row: 1;
        font-weight: 600;
        text-align: right;
    }
    .activities-table .al-cell-date,
    .activities-table .al-cell-strain,
    .activities-table .al-cell-zone {
        font-size: 0.8rem;
        color: var(--color-muted);
    }
    .activities-table .al-cell-date {
        grid-column: 1;
        grid-row: 2;
    }
    .activities-table .al-cell-zone {
        grid-column: 2;
        grid-row: 2;
        text-align: right;
    }
    .activities-table .al-cell-strain {
        display: none !important;
    }
    .activities-table .al-cell-note {
        grid-column: 1 / -1;
        grid-row: 3;
    }
    .activities-table .al-cell-note:empty {
        display: none !important;
    }
}

/* Touch: the controls bar */
@media (pointer: coarse) {
    .list-controls .btn-sm,
    .list-controls .form-control-sm,
    .list-controls .form-select-sm {
        min-height: 38px;
    }
}
