/* ========================================
   GROUPS GRID
   ======================================== */
.groups-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding: 0 1rem;
    max-width: 1280px;
    margin: 0 auto;
}

@media (min-width: 768px) {
    .groups-grid {
        grid-template-columns: repeat(2, 1fr);
        padding: 0 1.5rem;
    }
}

@media (min-width: 1024px) {
    .groups-grid {
        grid-template-columns: repeat(3, 1fr);
        padding: 0 2rem;
    }
}

/* ========================================
   GROUP TILE - WITH IMAGE (MAIN STYLE)
   ======================================== */
.group-tile-with-image {
    background-color: #ffffff;
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
    border: 1px solid #e5e7eb;
    animation: fadeIn 0.3s ease-out;
    display: flex;
    flex-direction: column;
    height: 30rem;
}

.group-tile-with-image:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(249, 115, 22, 0.2), 0 4px 6px -2px rgba(249, 115, 22, 0.1);
    border-color: #f97316;
}

.group-tile-image {
    width: 100%;
    height: 12rem;

    object-fit: fill;
    flex-shrink: 0;
}

.group-tile-placeholder {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.group-placeholder-initials {
    font-size: 3rem;
    font-weight: 700;
    color: #ffffff;
    text-align: center;
}

.group-tile-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* ========================================
   GROUP TILE - COMPACT
   ======================================== */
.group-tile-compact {
    background-color: #ffffff;
    padding: 1rem;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border: 1px solid #e5e7eb;
    animation: fadeIn 0.3s ease-out;
}

.group-tile-compact:hover {
    box-shadow: 0 4px 6px -1px rgba(249, 115, 22, 0.2);
    border-color: #f97316;
}

/* ========================================
   GROUP HEADER (COMPACT ONLY)
   ======================================== */
.group-header-compact {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

/* ========================================
   GROUP AVATAR (COMPACT ONLY)
   ======================================== */
.group-avatar-compact {
    width: 3rem;
    height: 3rem;
    border-radius: 9999px;
    object-fit: cover;
    flex-shrink: 0;
}

.group-avatar-initials-compact {
    width: 3rem;
    height: 3rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* Avatar Colors */
.avatar-orange { background-color: #f97316; }
.avatar-blue { background-color: #3b82f6; }
.avatar-green { background-color: #10b981; }
.avatar-purple { background-color: #a855f7; }
.avatar-pink { background-color: #ec4899; }
.avatar-red { background-color: #ef4444; }
.avatar-yellow { background-color: #f59e0b; }
.avatar-teal { background-color: #14b8a6; }
.avatar-indigo { background-color: #6366f1; }

/* ========================================
   GROUP INFO
   ======================================== */
.group-info {
    flex: 1;
}

.group-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: #9a3412;
    margin-bottom: 0.5rem;
    transition: color 0.2s;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.group-tile-with-image:hover .group-name,
.group-tile-compact:hover .group-name {
    color: #f97316;
}

.group-name-compact {
    font-size: 1.125rem;
    font-weight: 600;
    color: #9a3412;
    margin-bottom: 0.25rem;
    transition: color 0.2s;
}

.group-members {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #6b7280;
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.group-members-compact {
    color: #6b7280;
    font-size: 0.8125rem;
}

/* ========================================
   GROUP DESCRIPTION
   ======================================== */
.group-description {
    color: #4b5563;
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    /* Reserve exactly 2 lines of height so short descriptions and long
       ones occupy the same vertical slot — keeps tags + footer aligned. */
    min-height: calc(0.875rem * 1.5 * 2);
}

.group-description-link {
    color: inherit;
    text-decoration: none;
}

.group-description-more {
    color: #f97316;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.group-description-more:hover {
    text-decoration: underline;
}

/* ========================================
   GROUP TAGS
   ======================================== */
.group-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    /* Reserve the height of a single tag row even when empty, so a
       category-less group doesn't pull the footer upward. */
    min-height: 1.75rem;
}

.group-tags-compact {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
}

.group-tag {
    background-color: #ffedd5;
    color: #9a3412;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid #fed7aa;
}

.group-tag-xs {
    background-color: #ffedd5;
    color: #9a3412;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid #fed7aa;
}

/* ========================================
   GROUP FOOTER
   ======================================== */
.group-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
    /* Pin to the bottom of the flex column so Join Group is at the same
       Y position on every card, no matter how much description/tag
       content sits above it. */
    margin-top: auto;
}

.group-events-count {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #6b7280;
}

.group-events-count-compact {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: #6b7280;
}

/* ========================================
   GROUP BUTTONS
   ======================================== */
.group-btn {
    background-color: #f97316;
    color: #ffffff;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
    border: 2px solid #f97316;
    display: inline-block;
}

.group-btn:hover {
    background-color: #ffffff;
    color: #f97316;
}

.group-btn:focus {
    outline: 2px solid #f97316;
    outline-offset: 2px;
}

.group-btn-compact {
    background-color: #f97316;
    color: #ffffff;
    padding: 0.25rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
    border: 2px solid #f97316;
    display: inline-block;
}

.group-btn-compact:hover {
    background-color: #ffffff;
    color: #f97316;
}

.group-btn-compact:focus {
    outline: 2px solid #f97316;
    outline-offset: 2px;
}

/* ========================================
   LOADING STATE
   ======================================== */
.group-tile-with-image.loading,
.group-tile-compact.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
    .group-tile-with-image,
    .group-tile-compact {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #e5e7eb;
    }
}