/*
 * Givebutter Events/Campaigns List Styles (v7.2)
 * Dark Mode Theme with Progress Support and Dynamic Image Display
 * 2-Column Layout
 */

#givebutter-events-container {
    /* Ensure proper mobile scaling and container width */
    width: 100% !important;
    max-width: none !important;
    margin: 20px 0;
    padding: 0 !important;
    box-sizing: border-box;
}

/* Override WordPress theme containers for full-width mobile/tablet */
@media (max-width: 1200px) {
    /* Override common WordPress container classes */
    .wp-content #givebutter-events-container,
    .entry-content #givebutter-events-container,
    .site-content #givebutter-events-container,
    .content-area #givebutter-events-container,
    .main-content #givebutter-events-container,
    .post-content #givebutter-events-container,
    .site-main #givebutter-events-container,
    .main #givebutter-events-container,
    .page-content #givebutter-events-container {
        margin-left: -30px !important;
        margin-right: -30px !important;
        width: calc(100% + 60px) !important;
        max-width: none !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* Fallback for any container parent with padding */
    #givebutter-events-container {
        transform: translateX(-30px) !important;
        width: calc(100% + 60px) !important;
    }
}

@media (max-width: 768px) {
    .wp-content #givebutter-events-container,
    .entry-content #givebutter-events-container,
    .site-content #givebutter-events-container,
    .content-area #givebutter-events-container,
    .main-content #givebutter-events-container,
    .post-content #givebutter-events-container,
    .site-main #givebutter-events-container,
    .main #givebutter-events-container,
    .page-content #givebutter-events-container {
        margin-left: -20px !important;
        margin-right: -20px !important;
        width: calc(100% + 40px) !important;
        max-width: none !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* Fallback for any container parent with padding */
    #givebutter-events-container {
        transform: translateX(-20px) !important;
        width: calc(100% + 40px) !important;
    }
}

/* Additional overrides for very common theme structures */
@media (max-width: 767px) {
    /* Override any theme wrapper that adds padding */
    #content #givebutter-events-container,
    #primary #givebutter-events-container,
    .container #givebutter-events-container,
    .row #givebutter-events-container {
        margin-left: -25px !important;
        margin-right: -25px !important;
        width: calc(100% + 50px) !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}

/* Most aggressive override for stubborn themes - applies to any container */
@media (max-width: 640px) {
    /* Target any immediate parent container that might have padding */
    div[class*="container"] #givebutter-events-container,
    div[class*="content"] #givebutter-events-container,
    div[class*="wrap"] #givebutter-events-container,
    div[class*="col"] #givebutter-events-container,
    div[class*="row"] #givebutter-events-container,
    div[class*="entry"] #givebutter-events-container,
    .has-padding #givebutter-events-container,
    [class*="padding"] #givebutter-events-container {
        margin-left: -15px !important;
        margin-right: -15px !important;
        width: calc(100% + 30px) !important;
        max-width: none !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
}

/* Section headers for upcoming/past events */
.gbe-events-section {
    margin-bottom: 30px;
}

.gbe-section-header {
    font-size: 1.8em;
    font-weight: bold;
    color: #ffffff;
    margin: 0 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #7dd3c0; /* Teal accent */
}

/* Event grids within sections */
.gbe-section-events {
    display: grid;
    gap: 25px;
    grid-template-columns: 1fr;
}

/* Responsive layouts for different screen sizes */
/* Tablet and larger - 2 columns */
@media (min-width: 640px) {
    .gbe-section-events {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Keep 2 columns even when images are hidden */
    .gbe-section-events.gbe-no-images {
        grid-template-columns: repeat(2, 1fr);
    }
}

.gbe-event-item {
    display: flex;
    flex-direction: column;
    background-color: #373c46; /* Event card background */
    border: 1px solid #505662;
    border-radius: 8px;
    text-decoration: none;
    color: #d1d5db; /* Default light text for cards */
    transition: box-shadow 0.2s ease-in-out, transform 0.2s ease-in-out;
    overflow: hidden;
    /* Set minimum width to prevent cards from shrinking too much */
    min-width: 280px;
    /* Ensure card takes full available width but never smaller than min-width */
    flex: 0 0 auto;
}

/* Style adjustments when images are hidden */
.gbe-event-item.gbe-no-image {
    min-height: auto;
    border-left: 4px solid #7dd3c0; /* Add accent border when no image */
}

.gbe-event-item.gbe-no-image .gbe-event-content {
    padding-top: 25px; /* Slightly more padding at top when no image */
}

.gbe-event-item:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
    transform: translateY(-4px);
}

.gbe-event-image {
    width: 100%;
    height: 220px; /* Increased height for wider cards */
    object-fit: cover; 
    display: block;
    border-bottom: 1px solid #505662;
    background-color: #2c313a; /* Placeholder bg color */
}

.gbe-event-content {
    padding: 25px; /* Increased padding for wider cards */
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Ensures footer is pushed to the bottom */
}

.gbe-event-title {
    margin: 0 0 12px 0;
    font-size: 1.4em; /* Larger title for wider cards */
    color: #ffffff; /* White title */
    line-height: 1.3;
}

.gbe-event-description {
    font-size: 0.95em; /* Slightly larger text */
    color: #a0a7b3; /* Lighter gray for description */
    line-height: 1.6; /* Better line spacing */
    margin-top: 0;
    flex-grow: 1; /* Takes up available space */
    /* Clamp description to 5 lines for wider cards */
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 5; /* Show more lines in wider format */
    -webkit-box-orient: vertical;
}

.gbe-event-details {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #505662;
}

.gbe-event-details p {
    margin: 5px 0 0 0;
    font-size: 0.9em;
    color: #b0b7c3; /* Lighter gray for details */
    line-height: 1.4;
    display: flex;
    align-items: flex-start;
    gap: 0.5em;
}

.gbe-icon {
    flex-shrink: 0;
    margin-top: 0.1em; /* Slight vertical alignment for emoji */
}

.gbe-text {
    flex: 1;
}

.gbe-event-progress {
    color: #7dd3c0 !important; /* Teal color for progress */
    font-weight: 500;
}

/* Loading and Error States */
.gbe-loading-message,
.gbe-no-events {
    color: #d1d5db;
    padding: 20px;
    text-align: center;
    grid-column: 1 / -1; /* Span full width in grid */
    background-color: #2c313a;
    border: 1px solid #505662;
    border-radius: 8px;
}

.gbe-error {
    color: #ffb8b8; /* Lighter red for dark mode errors */
    background-color: #5d2a2a;
    border: 1px solid #a13d3d;
    padding: 15px;
    border-radius: 4px;
    grid-column: 1 / -1; /* Span full width in grid */
}

/* Override theme styles that might interfere */
.gbe-event-item * {
    text-decoration: none !important;
}

.gbe-event-item:hover .gbe-event-title {
    color: #7dd3c0; /* Teal on hover */
}

/* Ensure images don't get distorted */
.gbe-event-image {
    max-width: 100%;
    height: 220px;
    object-fit: cover;
}

/* Comprehensive mobile responsiveness with multiple breakpoints */

/* Small desktops and large tablets (900px - 1200px) */
@media (min-width: 900px) and (max-width: 1200px) {
    .gbe-section-header {
        font-size: 1.6em;
    }
    .gbe-event-content {
        padding: 22px;
    }
    .gbe-event-image {
        height: 200px;
    }
}

/* Tablets (768px - 899px) */
@media (min-width: 768px) and (max-width: 899px) {
    .gbe-section-events {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    .gbe-section-header {
        font-size: 1.5em;
    }
    .gbe-event-content {
        padding: 20px;
    }
    .gbe-event-image {
        height: 190px;
    }
}

/* Small tablets and large phones (481px - 767px) */
@media (min-width: 481px) and (max-width: 767px) {
    .gbe-section-events {
        grid-template-columns: 1fr;
        gap: 18px;
    }
    .gbe-section-header {
        font-size: 1.4em;
    }
    .gbe-event-content {
        padding: 18px;
    }
    .gbe-event-title {
        font-size: 1.2em;
    }
    .gbe-event-description {
        font-size: 0.9em;
        -webkit-line-clamp: 4;
    }
    .gbe-event-details p {
        font-size: 0.85em;
    }
    .gbe-event-image {
        height: 170px;
    }
}

/* Standard phones (361px - 480px) */
@media (max-width: 480px) {
    /* Switch to flexbox column layout for very narrow screens */
    .gbe-section-events {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }

    .gbe-section-header {
        font-size: 1.3em;
        margin-bottom: 12px;
        padding-bottom: 6px;
    }

    .gbe-event-item {
        width: 100%;
    }

    .gbe-event-content {
        padding: 16px;
    }

    .gbe-event-title {
        font-size: 1.1em;
    }

    .gbe-event-description {
        font-size: 0.85em;
        -webkit-line-clamp: 3;
        line-height: 1.5;
    }

    .gbe-event-details p {
        font-size: 0.8em;
        gap: 0.4em;
    }

    .gbe-event-image {
        height: 160px;
    }

    .gbe-events-section {
        margin-bottom: 20px;
    }
}

/* Very narrow screens (≤360px) - phones in landscape or very small screens */
@media (max-width: 360px) {
    /* Ensure minimum readable sizes and proper scaling */
    .gbe-section-header {
        font-size: 1.2em;
        margin-bottom: 10px;
        padding-bottom: 5px;
    }

    .gbe-section-events {
        gap: 12px;
    }

    .gbe-event-content {
        padding: 14px;
    }

    .gbe-event-title {
        font-size: 1.0em;
        margin-bottom: 10px;
    }

    .gbe-event-description {
        font-size: 0.8em;
        -webkit-line-clamp: 3;
        line-height: 1.4;
    }

    .gbe-event-details {
        margin-top: 12px;
        padding-top: 12px;
    }

    .gbe-event-details p {
        font-size: 0.75em;
        gap: 0.4em;
        line-height: 1.3;
    }

    .gbe-event-image {
        height: 140px;
    }

    /* Container spacing adjustments */
    #givebutter-events-container {
        margin: 15px 0;
    }

    .gbe-events-section {
        margin-bottom: 18px;
    }

    /* Ensure cards never get too narrow */
    .gbe-event-item {
        min-width: 100%;
        width: 100%;
    }
}

/* Refresh button styling */
.gbe-refresh-controls {
    margin: 20px 0;
    text-align: center;
    grid-column: 1 / -1; /* Span full width in grid */
}

.gbe-refresh-btn {
    background: #007cba !important; /* WordPress blue */
    color: white !important;
    border: none !important;
    padding: 10px 20px !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    transition: background-color 0.2s ease, opacity 0.2s ease !important;
    text-decoration: none !important;
    display: inline-block;
}

.gbe-refresh-btn:hover:not(:disabled) {
    background: #005a87 !important; /* Darker blue on hover */
}

.gbe-refresh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Loading and error states mobile adjustments */
@media (max-width: 640px) {
    .gbe-loading-message,
    .gbe-no-events,
    .gbe-error {
        padding: 18px 15px;
        font-size: 0.9em;
    }

    .gbe-refresh-btn {
        font-size: 13px !important;
        padding: 8px 16px !important;
    }
}
