/*
 * EarthCoop responsive system
 *
 * Opt-in primitives only. This file deliberately avoids blanket .container,
 * heading, and table overrides so pages migrate to the responsive system
 * explicitly and without surprising unrelated screens.
 */

.ec-page-shell {
    width: 100%;
    margin-inline: auto;
    min-width: 0;
}

.ec-surface {
    min-width: 0;
}

.ec-page-title {
    margin: 0;
    font-size: clamp(2rem, 3vw, 2.25rem);
    line-height: 1.4;
    font-weight: 800;
    text-wrap: balance;
}

.ec-section-title {
    margin: 0;
    font-size: clamp(1.2rem, 2vw, 1.45rem);
    line-height: 1.5;
    font-weight: 750;
}

.ec-page-hero {
    min-width: 0;
    padding: 1.25rem 1.5rem;
    border-radius: 1.25rem;
}

.ec-entity-list {
    display: grid;
    gap: 0.625rem;
    min-width: 0;
    width: 100%;
}

.ec-entity-card {
    min-width: 0;
    width: 100%;
    display: grid;
    grid-template-columns: 3.25rem minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.96);
    color: var(--color-gentle-black, #1e293b);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
    text-align: start;
    text-decoration: none;
}

.ec-entity-card--interactive {
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
}

.ec-entity-card--interactive:hover,
.ec-entity-card--interactive:focus-visible {
    border-color: rgba(16, 185, 129, 0.48);
    background: #f8fffc;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
    transform: translateY(-1px);
    outline: none;
}

.ec-entity-card--muted {
    background: #f8fafc;
    color: #64748b;
}

.ec-entity-card__avatar {
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 0.9rem;
    overflow: hidden;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    background: #d1fae5;
    color: #047857;
    border: 1px solid #a7f3d0;
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1;
}

.ec-entity-card__avatar img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.ec-entity-card__body {
    min-width: 0;
    display: grid;
    gap: 0.35rem;
}

.ec-entity-card__title {
    min-width: 0;
    margin: 0;
    color: inherit;
    font-size: 0.98rem;
    font-weight: 750;
    line-height: 1.65;
    word-break: normal;
    overflow-wrap: normal;
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

.ec-entity-card__meta {
    min-width: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem 0.5rem;
    color: #64748b;
    font-size: 0.78rem;
    line-height: 1.6;
}

.ec-entity-card__meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
}

.ec-entity-card__meta-separator {
    color: #cbd5e1;
    user-select: none;
}

.ec-entity-card__status {
    display: inline-flex;
    align-items: center;
    min-height: 1.55rem;
    padding-inline: 0.5rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.ec-entity-card__status--active {
    color: #166534;
    background: #dcfce7;
}

.ec-entity-card__status--pending {
    color: #92400e;
    background: #fef3c7;
}

.ec-entity-card__status--inactive {
    color: #991b1b;
    background: #fee2e2;
}

.ec-entity-card__affordance {
    align-self: center;
    justify-self: end;
    display: inline-grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    color: #059669;
    background: #ecfdf5;
    flex: 0 0 auto;
}

.ec-entity-card__secondary-action {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    width: fit-content;
    margin-top: 0.15rem;
    color: #047857;
    font-size: 0.76rem;
    font-weight: 700;
    text-decoration: none;
}

.ec-empty-state {
    padding: 1rem;
    border-radius: 0.9rem;
    background: #f8fafc;
    color: #64748b;
    font-size: 0.85rem;
    text-align: center;
}

body.dark-mode .ec-entity-card {
    border-color: rgba(148, 163, 184, 0.24);
    background: rgba(30, 41, 59, 0.96);
    color: #f8fafc;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

body.dark-mode .ec-entity-card--interactive:hover,
body.dark-mode .ec-entity-card--interactive:focus-visible {
    border-color: rgba(52, 211, 153, 0.5);
    background: rgba(15, 23, 42, 0.98);
}

body.dark-mode .ec-entity-card--muted {
    background: rgba(15, 23, 42, 0.72);
    color: #94a3b8;
}

body.dark-mode .ec-entity-card__avatar {
    border-color: rgba(52, 211, 153, 0.35);
    background: rgba(6, 78, 59, 0.5);
    color: #a7f3d0;
}

body.dark-mode .ec-entity-card__meta {
    color: #cbd5e1;
}

body.dark-mode .ec-entity-card__affordance {
    color: #6ee7b7;
    background: rgba(6, 95, 70, 0.45);
}

body.dark-mode .ec-entity-card__secondary-action {
    color: #6ee7b7;
}

body.dark-mode .ec-empty-state {
    background: rgba(15, 23, 42, 0.7);
    color: #cbd5e1;
}

@media (max-width: 1023px) {
    .ec-page-shell {
        padding-inline: 1.25rem;
    }

    .ec-surface {
        padding: 1.25rem;
    }

    .ec-page-title {
        font-size: clamp(1.7rem, 4vw, 1.95rem);
    }

    .ec-page-hero {
        padding: 1rem 1.125rem;
    }
}

@media (max-width: 767px) {
    .ec-page-shell {
        padding-inline: 0.875rem;
    }

    .ec-surface {
        padding: 0.875rem;
        border-radius: 1rem;
    }

    .ec-page-title {
        font-size: clamp(1.45rem, 7vw, 1.7rem);
        line-height: 1.45;
    }

    .ec-section-title {
        font-size: 1.08rem;
        line-height: 1.55;
    }

    .ec-page-hero {
        min-height: auto;
        padding: 0.875rem 1rem;
        border-radius: 1rem;
    }

    .ec-entity-list {
        gap: 0.625rem;
    }

    .ec-entity-card {
        grid-template-columns: 3.25rem minmax(0, 1fr) auto;
        gap: 0.65rem;
        padding: 0.7rem;
        border-radius: 0.95rem;
    }

    .ec-entity-card__title {
        font-size: 0.94rem;
        line-height: 1.6;
    }

    .ec-entity-card__meta {
        font-size: 0.75rem;
    }
}

@media (max-width: 380px) {
    .ec-page-shell {
        padding-inline: 0.75rem;
    }

    .ec-surface {
        padding: 0.75rem;
    }

    .ec-entity-card {
        grid-template-columns: 3rem minmax(0, 1fr) auto;
        gap: 0.55rem;
        padding: 0.625rem;
    }

    .ec-entity-card__avatar {
        width: 3rem;
        height: 3rem;
    }
}

/* My Groups reference implementation: the existing semantic page root is the
 * explicit opt-in scope. Higher specificity is intentional because this
 * shared stylesheet loads before the page's legacy inline desktop styles. */
body .groups-page-shell {
    min-width: 0;
}

.groups-page-shell .dashboard-content {
    min-width: 0;
}

.groups-page-shell .groups-section,
.groups-page-shell .accordion-tabs,
.groups-page-shell .accordion-item,
.groups-page-shell .accordion-content,
.groups-page-shell .toggle-group,
.groups-page-shell .toggle-content {
    min-width: 0;
}

/* Do not rely on Tailwind utility order for the mutually exclusive group
 * representations: responsive-system.css loads after Vite and owns this
 * breakpoint explicitly. */
.groups-page-shell [data-mobile-group-list] {
    display: none;
}

.groups-page-shell [data-desktop-group-table] {
    display: block;
}

@media (max-width: 1023px) {
    .groups-page-shell [data-mobile-group-list] {
        display: grid;
    }

    .groups-page-shell [data-desktop-group-table] {
        display: none;
    }

    body .groups-page-shell {
        width: 100%;
        max-width: 100%;
        padding: 0.75rem 1.25rem 1.5rem;
    }

    .groups-page-shell .groups-page-layout {
        gap: 1rem;
    }

    .groups-page-shell .dashboard-content {
        padding: 1.25rem;
        min-height: auto;
    }

    .groups-page-shell .groups-section h2 {
        font-size: clamp(1.7rem, 4vw, 1.95rem);
        line-height: 1.45;
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
    }
}

@media (max-width: 767px) {
    body .groups-page-shell {
        padding: 0.75rem 0.875rem 1.25rem;
    }

    .groups-page-shell .groups-page-layout {
        gap: 0.75rem;
    }

    .groups-page-shell .dashboard-content {
        padding: 0.75rem;
        min-height: auto;
        border-radius: 1rem;
        box-shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
        font-size: 1rem;
    }

    .groups-page-shell .groups-section h2 {
        font-size: clamp(1.45rem, 7vw, 1.7rem);
        line-height: 1.45;
        margin-bottom: 0.875rem;
        padding-bottom: 0.625rem;
        border-bottom-width: 2px;
        text-shadow: none;
    }

    .groups-page-shell .groups-section h2::after {
        height: 2px;
        bottom: -2px;
        width: 3.25rem;
    }

    .groups-page-shell .accordion-tabs {
        gap: 0.625rem;
    }

    .groups-page-shell .accordion-item {
        border-radius: 0.9rem;
        box-shadow: 0 5px 16px rgba(15, 23, 42, 0.05);
    }

    .groups-page-shell .accordion-header {
        padding: 0.7rem 0.75rem;
        border-radius: 0.9rem;
        font-size: 0.9rem;
        gap: 0.5rem;
    }

    .groups-page-shell .accordion-item.is-open .accordion-header {
        border-radius: 0.9rem 0.9rem 0 0;
    }

    .groups-page-shell .accordion-label {
        min-width: 0;
        gap: 0.55rem;
    }

    .groups-page-shell .accordion-label > span:last-child {
        min-width: 0;
        line-height: 1.55;
    }

    .groups-page-shell .accordion-label-icon {
        width: 2.2rem;
        height: 2.2rem;
        border-radius: 0.7rem;
        font-size: 0.85rem;
    }

    .groups-page-shell .accordion-header > .toggle-icon {
        width: 1.8rem;
        height: 1.8rem;
        font-size: 0.72rem;
    }

    .groups-page-shell .accordion-content {
        padding: 0.65rem;
    }

    .groups-page-shell .toggle-group {
        margin-bottom: 0.65rem;
        border-radius: 0.75rem;
    }

    .groups-page-shell .toggle-group:last-child {
        margin-bottom: 0;
    }

    .groups-page-shell .toggle-header {
        padding: 0.7rem 0.75rem;
        font-size: 0.84rem;
        line-height: 1.55;
        gap: 0.5rem;
    }

    .groups-page-shell .toggle-content {
        padding: 0.65rem;
    }

    .groups-page-shell .filter-buttons {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 0.4rem;
        margin-bottom: 0.65rem;
        padding: 0;
    }

    .groups-page-shell .filter-button {
        flex: 0 1 auto;
        min-width: 0;
        padding: 0.45rem 0.65rem;
        border-radius: 999px;
        font-size: 0.75rem;
        line-height: 1.35;
        white-space: nowrap;
    }

    .groups-page-shell .ec-entity-list {
        width: 100%;
        min-width: 0;
    }

    .groups-page-shell .ec-entity-card {
        width: 100%;
        min-width: 0;
    }
}

@media (max-width: 380px) {
    body .groups-page-shell {
        padding-inline: 0.75rem;
    }

    .groups-page-shell .dashboard-content {
        padding: 0.625rem;
    }

    .groups-page-shell .accordion-content,
    .groups-page-shell .toggle-content {
        padding: 0.55rem;
    }
}

body.dark-mode .groups-page-shell .accordion-item,
body.dark-mode .groups-page-shell .accordion-content,
body.dark-mode .groups-page-shell .toggle-content {
    background: var(--card-dark, #1f2937);
    border-color: var(--border-dark, #374151);
}

body.dark-mode .groups-page-shell .accordion-header,
body.dark-mode .groups-page-shell .toggle-header {
    background: rgba(15, 23, 42, 0.72);
    color: var(--text-dark, #e5e7eb);
}

body.dark-mode .groups-page-shell .accordion-item.is-open .accordion-header {
    color: #a7f3d0;
    background: linear-gradient(135deg, rgba(6, 78, 59, 0.42), rgba(30, 64, 175, 0.16));
}
