/**
 * Ticket Tailor - Frontend Styles
 * Version: 4.0.0 - White background for image areas
 * This version fixes stretched/cut-off logos while maintaining layout
 */

/* ============================================
   CRITICAL OVERRIDES - FORCE 220px CARDS
   ============================================ */

/* Override ALL grid layouts with inline styles */
.tt-event-listing.tt-layout-grid,
.tt-event-listing.tt-layout-grid.tt-columns-3,
.tt-event-listing.tt-layout-grid[style*="grid-template-columns"],
.tt-event-listing.tt-columns-responsive {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, 220px) !important;
    gap: 3rem !important;
    justify-content: center !important;
    align-items: stretch !important;
    grid-auto-rows: 1fr !important;
    max-width: 100% !important;
}

/* Force specific column counts */
.tt-event-listing.tt-layout-grid.tt-columns-4 {
    grid-template-columns: repeat(4, 220px) !important;
}

.tt-event-listing.tt-layout-grid.tt-columns-3 {
    grid-template-columns: repeat(3, 220px) !important;
}

.tt-event-listing.tt-layout-grid.tt-columns-2 {
    grid-template-columns: repeat(2, 220px) !important;
}

/* Force card width */
.tt-event-card {
    width: 220px !important;
    max-width: 220px !important;
    min-width: 220px !important;
    display: flex !important;
    flex-direction: column !important;
    background: #ffffff !important;
    border: 1px solid #e1e1e1 !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08) !important;
    height: 100% !important;
}

.tt-event-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15) !important;
    transform: translateY(-2px) !important;
    border-color: #d1d1d1 !important;
}

/* Force image container width - with white background */
.tt-event-image {
    width: 220px !important;
    max-width: 220px !important;
    height: 147px !important;
    position: relative !important;
    overflow: hidden !important;
    background: #ffffff !important; /* White background for empty space */
    flex: 0 0 auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* FIXED: Use contain for thumbnails to prevent cropping */
.tt-event-image.tt-image-thumbnail img {
    width: auto !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important; /* Changed from cover to contain */
    object-position: center !important;
    display: block !important;
    transition: transform 0.3s ease !important;
    padding: 10px !important; /* Add breathing room for logos */
}

/* Keep cover for header/banner images */
.tt-event-image.tt-image-header img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important; /* Keep cover for banner images */
    object-position: center !important;
    display: block !important;
    transition: transform 0.3s ease !important;
    padding: 0 !important; /* No padding for banner images */
}

/* Default for images without specific class */
.tt-event-image img {
    width: auto !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important; /* Default to contain */
    object-position: center !important;
    display: block !important;
    transition: transform 0.3s ease !important;
    padding: 10px !important;
}

.tt-event-card:hover .tt-event-image img {
    transform: scale(1.05) !important;
}

/* Force content width */
.tt-event-content {
    width: 220px !important;
    max-width: 220px !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0.875rem !important;
    flex: 1 !important;
    box-sizing: border-box !important;
}

/* ============================================
   EVENT LISTING STYLES
   ============================================ */
.tt-event-listing {
    margin: 2rem auto;
    max-width: 100%;
}

/* Event Listing Wrapper */
.tt-event-listing-wrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

/* Full Width Wrapper */
.tt-full-width {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.tt-full-width .tt-event-listing {
    max-width: 100%;
    padding: 0 1rem;
}

/* List Layout */
.tt-event-listing.tt-layout-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 1.5rem !important;
    align-items: center !important;
}

.tt-event-listing.tt-layout-list .tt-event-card {
    display: grid !important;
    grid-template-columns: 220px 1fr !important;
    gap: 1.5rem !important;
    max-width: 900px !important;
    width: 100% !important;
}

/* List layout images should also use contain */
.tt-event-listing.tt-layout-list .tt-event-image img {
    object-fit: contain !important;
    padding: 10px !important;
}

/* ============================================
   EVENT CONTENT ELEMENTS
   ============================================ */

/* Event Title */
.tt-event-title {
    margin: 0 0 0.625rem 0 !important;
    font-size: 1rem !important;
    line-height: 1.3 !important;
    color: #2c3e50 !important;
    font-weight: 600 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
}

/* Date and Venue */
.tt-event-date,
.tt-event-venue {
    display: flex !important;
    align-items: flex-start !important;
    margin-bottom: 0.4rem !important;
    font-size: 0.85rem !important;
    color: #666 !important;
    line-height: 1.3 !important;
}

.tt-event-date .dashicons,
.tt-event-venue .dashicons {
    margin-right: 0.375rem !important;
    color: #2271b1 !important;
    flex-shrink: 0 !important;
    width: 14px !important;
    height: 14px !important;
    font-size: 14px !important;
    margin-top: 1px !important;
}

/* Spacer to push button down */
.tt-event-content::before {
    content: "" !important;
    flex: 1 !important;
    min-height: 0.25rem !important;
}

/* Hide PHP spacer */
.tt-event-spacer {
    display: none !important;
}

/* Button Container */
.tt-event-button-container {
    margin-top: auto !important;
    padding-top: 0.625rem !important;
    text-align: center !important; /* Center the button */
}

/* Event Button */
.tt-event-button,
a.tt-event-button {
    display: inline-block !important;
    width: auto !important; /* Auto width instead of 100% */
    padding: 0.75rem 1.5rem !important; /* Padding determines size */
    background: #2271b1 !important;
    color: #ffffff !important;
    text-decoration: none !important;
    text-align: center !important;
    border-radius: 6px !important;
    font-weight: 700 !important; /* Bold text */
    font-size: 1rem !important; /* Larger text */
    transition: all 0.3s ease !important;
    border: none !important;
    cursor: pointer !important;
    white-space: nowrap !important; /* Prevent text wrapping */
}

.tt-event-button:hover,
a.tt-event-button:hover {
    background: #135e96 !important;
    color: #ffffff !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 2px 8px rgba(34, 113, 177, 0.3) !important;
}

/* Event excerpt (list view only) */
.tt-event-excerpt {
    font-size: 0.875rem !important;
    color: #666 !important;
    line-height: 1.4 !important;
    margin-bottom: 0.75rem !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
}

/* ============================================
   SINGLE EVENT STYLES
   ============================================ */
.tt-single-event {
    background: #fff;
    border: 1px solid #e1e1e1;
    border-radius: 12px;
    overflow: hidden;
    margin: 2rem 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.tt-single-event-wrapper {
    margin: 2rem 0;
}

.tt-event-header-image {
    width: 100%;
    max-height: 400px;
    overflow: hidden;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Single event header images can use cover */
.tt-event-header-image img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover; /* Keep cover for single event headers */
}

.tt-event-details {
    padding: 2rem;
}

.tt-event-details .tt-event-title {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    color: #2c3e50;
}

.tt-event-meta {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.tt-meta-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    color: #666;
}

.tt-meta-item strong {
    font-weight: 600;
    color: #333;
}

.tt-event-description {
    font-size: 1rem;
    line-height: 1.6;
    color: #444;
    margin-bottom: 2rem;
}

.tt-event-description p {
    margin-bottom: 1rem;
}

.tt-event-cta {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid #e1e1e1;
    text-align: center;
}

.tt-button {
    display: inline-block;
    padding: 1rem 2rem;
    background: #971320;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 1.1rem;
    transition: all 0.3s ease;
}

.tt-button:hover {
    background: #dd1c3d;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 113, 177, 0.3);
}

/* ============================================
   WORDPRESS BLOCK SUPPORT
   ============================================ */
.wp-block-ticket-tailor-event-listing,
.wp-block-ticket-tailor-single-event,
.wp-block-ticket-tailor-category-events {
    margin: 2rem 0;
}

.alignfull .tt-event-listing {
    padding: 0 2rem;
}

/* ============================================
   STATUS, ERROR & WIDGET STYLES
   ============================================ */
.tt-status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
}

.tt-status-on_sale {
    background: #d4f4dd;
    color: #1e7e34;
}

.tt-status-sold_out {
    background: #f8d7da;
    color: #721c24;
}

.tt-status-cancelled {
    background: #e7e7e7;
    color: #666;
}

.tt-status-postponed {
    background: #fff3cd;
    color: #856404;
}

.tt-error,
.tt-no-events {
    padding: 2rem;
    text-align: center;
    background: #f8f9fa;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
    color: #666;
    margin: 2rem 0;
}

.tt-error {
    background: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

.tt-block-placeholder {
    padding: 2rem;
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    text-align: center;
    color: #6c757d;
    font-style: italic;
}

.tt-widget-block {
    margin: 2rem 0;
}

.tt-widget-error {
    padding: 1rem;
    background: #f8d7da;
    color: #721c24;
    border-radius: 4px;
    text-align: center;
}

/* ============================================
   CATEGORY EVENTS
   ============================================ */
.tt-category-events-wrapper {
    margin: 2rem 0;
}

.tt-category-header {
    text-align: center;
    margin-bottom: 2rem;
}

.tt-category-title {
    font-size: 2rem;
    color: #2c3e50;
    margin: 0;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 1200px) {
    .tt-event-listing.tt-layout-grid.tt-columns-5 {
        grid-template-columns: repeat(4, 220px) !important;
    }
}

@media (max-width: 1024px) {
    .tt-event-listing.tt-layout-grid.tt-columns-4,
    .tt-event-listing.tt-layout-grid.tt-columns-3 {
        grid-template-columns: repeat(3, 220px) !important;
    }
}

@media (max-width: 768px) {
    .tt-event-listing.tt-layout-grid.tt-columns-5,
    .tt-event-listing.tt-layout-grid.tt-columns-4,
    .tt-event-listing.tt-layout-grid.tt-columns-3 {
        grid-template-columns: repeat(2, 220px) !important;
    }

    .tt-event-listing.tt-layout-list .tt-event-card {
        grid-template-columns: 1fr !important;
        width: 100% !important;
    }
}

@media (max-width: 576px) {
    .tt-event-listing.tt-layout-grid {
        grid-template-columns: 220px !important;
        justify-content: center !important;
    }
}

@media (max-width: 400px) {
    .tt-event-title {
        font-size: 0.95rem !important;
    }

    .tt-event-date,
    .tt-event-venue {
        font-size: 0.8rem !important;
    }

    .tt-event-button {
        padding: 0.5rem 0.875rem !important;
        font-size: 0.85rem !important;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.tt-loading {
    text-align: center;
    padding: 3rem;
    color: #666;
}

.tt-loading::after {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-left: 0.5rem;
    border: 2px solid #ddd;
    border-top-color: #2271b1;
    border-radius: 50%;
    animation: tt-spin 0.8s linear infinite;
}

@keyframes tt-spin {
    to {
        transform: rotate(360deg);
    }
}

.tt-centered {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 1rem;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
.tt-event-button:focus,
.tt-button:focus,
.tt-event-card:focus-within {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

.screen-reader-text,
.tt-sr-only {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    word-wrap: normal !important;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .tt-event-button,
    .tt-button,
    .tt-widget-block {
        display: none;
    }

    .tt-event-listing.tt-layout-grid {
        grid-template-columns: repeat(3, 220px) !important;
    }

    .tt-event-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
