/* ==========================================================================
   Shared Components
   ========================================================================== */

/* Page header — the one "title + actions" bar. `.page-header`/`.page-actions`
   are aliases so both naming conventions render identically. */
.header-actions,
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.header-buttons,
.page-actions {
    display: flex;
    gap: 0.5rem;
}

@media (max-width: 768px) {
    .header-actions,
    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .header-actions h2,
    .page-header h1,
    .page-header h2 {
        text-align: center;
    }

    .header-buttons,
    .page-actions {
        display: flex;
        width: 100%;
    }

    .header-buttons .btn,
    .page-actions .btn {
        flex: 1;
        text-align: center;
    }
}

/* Page intro — muted description paragraph under a page header.
   One canonical style so every page's lead text matches. */
.page-intro {
    color: var(--color-text-muted);
    max-width: 72ch;
    margin: -0.25rem 0 var(--space-lg);
    line-height: 1.55;
}

/* Info Tooltip (inline help marker used next to section titles) */
.info-tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.1em;
    height: 1.1em;
    border-radius: 50%;
    font-size: 0.85em;
    color: var(--color-primary, var(--primary-color));
    cursor: help;
    vertical-align: middle;
    margin-left: 0.25em;
}

.info-tooltip:hover,
.info-tooltip:focus {
    outline: 1px dashed currentColor;
    outline-offset: 2px;
}

/* Tooltip bubble from data-tip. Native title= never shows on touch;
   :focus (the element has tabindex) makes a tap reveal the text. */
.info-tooltip {
    position: relative;
}

.info-tooltip[data-tip]:hover::after,
.info-tooltip[data-tip]:focus::after {
    content: attr(data-tip);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-tooltip, 1500);
    width: max-content;
    max-width: min(320px, 80vw);
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-md);
    background: var(--dark-color);
    color: white;
    font-size: 0.8rem;
    font-weight: 400;
    line-height: 1.45;
    text-align: left;
    white-space: normal;
    box-shadow: var(--shadow-md);
    pointer-events: none;
}

@media (max-width: 480px) {
    /* Near screen edges, anchor the bubble to the viewport-ish left. */
    .info-tooltip[data-tip]:hover::after,
    .info-tooltip[data-tip]:focus::after {
        left: 0;
        transform: none;
    }
}

/* Filter Card */
.filter-card {
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.filter-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
    width: 100%;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 120px;
}

/* The `display: flex` above would otherwise defeat the [hidden] attribute
   (UA display:none loses to a class rule), leaving a JS-toggled filter group
   — e.g. the stats custom-date range — visible when it should be hidden. */
.filter-group[hidden] {
    display: none;
}

.filter-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.4rem;
    color: var(--secondary-color);
    font-size: 0.85rem;
}

.filter-group.filter-actions {
    flex-direction: row;
    gap: 0.5rem;
    margin-left: auto;
}

@media (max-width: 768px) {
    .filter-row {
        flex-direction: column;
    }

    .filter-group {
        width: 100%;
    }

    .filter-group.filter-actions {
        margin-left: 0;
        flex-direction: column;
    }

    .filter-group.filter-actions .btn {
        width: 100%;
    }
}

/* Empty State */
/* Empty state — flat by default (works inside cards/widgets without
   double-boxing). Add .empty-state--card for a standalone boxed version
   on list pages. Single source; page-level overrides were removed. */
.empty-state {
    text-align: center;
    padding: var(--space-xl) var(--space-md);
    color: var(--color-text-muted);
}

.empty-state--card {
    padding: var(--space-3xl) var(--space-xl);
    background: var(--color-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

.empty-state p {
    color: var(--color-text-muted);
    margin-bottom: 1rem;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}
.empty-state-icon svg { color: var(--color-text-faint); }

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.pagination-info {
    color: var(--secondary-color);
    font-size: 0.9rem;
}
