/* ==========================================================================
   1. CORE CARD CONTAINERS
   ========================================================================== */

/* Card: visual container */
.card {
    /*border: 1px solid var(--border-card);*/
    border-radius: var(--radius-card);
    overflow: hidden;
    background-color: var(--bg-card);
    margin-bottom: 0.5rem;
    /*box-shadow: 0 2px 8px rgba(0,0,0,0.10);*/
    transition: box-shadow 0.15s ease;
}

.card:hover {
    /*box-shadow: 0 4px 14px rgba(0,0,0,0.13);*/
}

/* Grid: pure layout primitive — no visual styling */
.card-grid {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: subgrid;
    /*margin-bottom: 0;*/
}

/* ==========================================================================
   2. HEADERS & NAVIGATION
   ========================================================================== */

/* Main Interactive Header */
.card-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border);
    background-color: var(--bg-card-header);
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease-in-out;
}

.card-header:hover {
    background-color: var(--bg-card-header-hover);
}

/* Header Elements */
.card-header .card-accent {
    display: block;
    width: 3px;
    height: 1.1em;
    border-radius: 2px;
    background-color: var(--accent);
    flex-shrink: 0;
}

.card-header .card-name {
    font-weight: 600;
    font-size: var(--font-sm);
    color: var(--text-primary);
    flex: 1;
    letter-spacing: 0.02em;
}

.card-header .card-badge {
    font-size: var(--font-2xs);
    color: var(--text-secondary);
    background-color: var(--bg-badge);
    border: 1px solid var(--border-strong);
    border-radius: 0.75rem;
    padding: 1px 8px;
}

.card-header .card-updated {
    font-size: var(--font-2xs);
    color: var(--text-secondary);
    white-space: nowrap;
}

.card-header .collapse-icon {
    font-size: var(--font-2xs);
    color: var(--text-secondary);
    transition: color 0.2s;
    flex-shrink: 0;
}

.card-header:hover .collapse-icon { 
    color: var(--accent); 
}

/* ==========================================================================
   3. BODY & LAYOUT SECTIONS
   ========================================================================== */

.card-body {
    padding: 8px;
}

.card-controls {
    padding: 0.75rem;
}

/* Nested Feed Options Section */
.card .feed-options {
    border-top: 1px solid var(--border);
}

.card .feed-options .card {
    border-left: none;
    border-right: none;
    border-bottom: none;
    border-radius: 0;
    margin-bottom: 0;
    box-shadow: none;
}

.card .feed-options .card-header {
    border-radius: 0;
}

/* ==========================================================================
   4. INNER TABLES
   ========================================================================== */

.card table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.card table th {
    padding: 5px 12px;
    font-size: var(--font-2xs);
    font-weight: normal;
    color: var(--text-secondary);
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
    background-color: #eee;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card table td {
    padding: 9px 12px;
    color: var(--text-body);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    vertical-align: middle;
}

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

.card table tbody tr:hover td { 
    background-color: var(--accent-row-hover); 
}

/* Column Variants & Alignment */
.card table td.col-secondary { color: var(--text-secondary); }
.card table td.col-primary   { color: var(--text-primary); font-weight: 500; }

.card table td.col-chip span {
    display: inline-block;
    font-size: var(--font-2xs);
    color: var(--text-secondary);
    background-color: var(--bg-card-row-hover);
    border: 1px solid var(--border-strong);
    border-radius: 0.75rem;
    padding: 1px 8px;
}

.card table td.col-mono,
.card table td.col-mono-truncate {
    font-family: monospace;
    color: var(--text-secondary);
}

.card table td.col-mono { font-size: var(--font-xs); }
.card table td.col-mono-truncate {
    font-size: var(--font-2xs);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card table th.col-updated,
.card table td.col-updated { text-align: right; white-space: nowrap; }

.card table th.col-action,
.card table td.col-action  { width: 24px; text-align: center; padding: 9px 6px; }

/* Table Column Sizing */
.card table col.col-w-label  { width: 200px; }
.card table col.col-w-action { width: 32px; }
.card table col.col-w-btn    { width: 130px; }

/* ==========================================================================
   5. GRID & FEED LISTS (NODE SYSTEM)
   ========================================================================== */

.card-list-grid {
    display: grid;
    width: 100%;
    box-sizing: border-box;
    contain: layout style;
    gap: 0;
}

.grid-row {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: subgrid;
    align-items: center;
    min-height: 44px;
    cursor: default;
    position: relative; /* supports ::before accent strip used by .grid-row-item */
}

/* Adjustments for headers inside grids */
.grid-row.card-header {
    padding: 0;
    gap: 0;
}
.grid-row.card-header > .grid-cell {
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
}
.grid-row.card-header > .grid-cell:first-child { padding-left: 1rem; }
.grid-row.card-header > .grid-cell:last-child  { padding-right: 1rem; }

/* Feed Rows — use as .grid-row.grid-row-item; extends .grid-row with interactive states */
.grid-row-item {
    border-top: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-body);
    transition: background-color 0.1s ease;
    cursor: pointer;
    /*border-right: 4px solid var(--status-color);*/
}
.grid-row-item:hover { background-color: var(--bg-card-row-hover); }
.grid-row-item:last-of-type { border-bottom-width: 0; }

/* Left accent strip */
.grid-row-item::before {
    content: '';
    width: 0;
    background: var(--accent);
    height: 100%;
    display: block;
    position: absolute;
    left: 0;
    top: 0;
    transition: width .2s ease-out;
}
.grid-row-item:hover::before { width: 2px; }

.grid-row-item.selected         { background-color: var(--accent-bg); }
.grid-row-item.selected::before { width: 4px; background: var(--accent); }
.grid-row-item.selected:hover   { background-color: var(--accent-bg-hover); }


.card-indicator {
    display: inline-block;
    width: 4px;
    height: 1.8em;
    background-color: var(--status-color);
    flex-shrink: 0;
    margin-right:1px;
    vertical-align: middle;
}

.row-value {
    align-items: center;
    font-size: 0.85rem;
    font-weight: 600;
}

/* ==========================================================================
   6. INTERACTIVE ELEMENTS (ACTIONS & COLLAPSE)
   ========================================================================== */

/* Row Action Icons */
.row-action {
    cursor: pointer;
    color: transparent;
    transition: color 0.15s;
}
.grid-row-item:hover .row-action,
.card table tbody tr:hover .row-action { color: var(--text-secondary); }
.row-action:hover { color: var(--accent) !important; }

/* Collapse Indicators */
.collapse-icon {
    transition: transform 0.3s ease;
    color: var(--status-color);
    opacity: 0.7;
}

.grid-collapsible {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease-in-out;
}
.grid-collapsible.is-expanded { max-height: 2000px; }

/* ==========================================================================
   7. RESPONSIVE OVERRIDES
   ========================================================================== */

@media (max-width: 576px) {
    .card table col.col-w-label { 
        width: 90px; 
    }
}