/**
 * GiveWP Donor Carousel - Bootstrap Framework Integration
 * 
 * Minimal custom CSS - leverages Bootstrap 5.3.2 classes
 * 
 * @package GiveWP_Donor_Carousel
 * @since 1.0.0
 */

/* ======================================
   DONOR CARD ENHANCEMENTS
   ====================================== */

/* Company information styling */
.company-info {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    font-size: 0.875rem !important;
    color: #6c757d !important;
    margin-bottom: 0.5rem !important;
    font-style: italic !important;
}

.company-info i {
    margin-right: 4px;
    color: #28a745;
}

/* Donation date styling */
.donation-date {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    font-size: 0.75rem !important;
    color: #999 !important;
    margin-top: 0.5rem !important;
}

.donation-date i {
    margin-right: 4px;
    color: #17a2b8;
}

/* Ensure content sections are visible */
.content-section,
.footer-section {
    display: block !important;
    visibility: visible !important;
}

/* ======================================
   STICKY BOTTOM CONTROLS
   ====================================== */

/* Sticky bottom carousel controls */
.carousel-sticky-controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1050;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 8px 16px;
    transition: all 0.3s ease;
    display: none;
}

.carousel-sticky-controls:hover {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.sticky-controls-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.carousel-sticky-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--bs-primary, #0d6efd);
    background: white;
    color: var(--bs-primary, #0d6efd);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 14px;
}

.carousel-sticky-btn:hover {
    background: var(--bs-primary, #0d6efd);
    color: white;
    transform: scale(1.05);
}

.carousel-play-pause-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--bs-secondary, #6c757d);
    background: white;
    color: var(--bs-secondary, #6c757d);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s ease;
}

.carousel-play-pause-btn:hover {
    background: var(--bs-secondary, #6c757d);
    color: white;
}

.carousel-slide-counter {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--bs-dark, #333);
    min-width: 40px;
    text-align: center;
    white-space: nowrap;
}

/* Hide sticky controls on very small screens */
@media (max-width: 480px) {
    .carousel-sticky-controls {
        bottom: 10px;
        padding: 6px 12px;
    }
    
    .carousel-sticky-btn,
    .carousel-play-pause-btn {
        width: 32px;
        height: 32px;
    }
    
    .carousel-slide-counter {
        font-size: 0.75rem;
        min-width: 35px;
    }
}

/* Hide original carousel controls when sticky controls are shown */
.container-fluid:has(.carousel-sticky-controls) .carousel-control-prev,
.container-fluid:has(.carousel-sticky-controls) .carousel-control-next {
    display: none;
}

/* Alternative for browsers that don't support :has() */
.carousel-with-sticky-controls .carousel-control-prev,
.carousel-with-sticky-controls .carousel-control-next {
    display: none;
}

/* ======================================
   BOOTSTRAP CAROUSEL ENHANCEMENTS
   ====================================== */

/* Ensure proper Bootstrap grid behavior */
.carousel .row {
    --bs-gutter-x: 1.5rem;
    --bs-gutter-y: 1.5rem;
}

/* Carousel item transitions */
.carousel-item {
    transition: transform 0.6s ease-in-out;
}

/* Carousel controls styling */
.carousel-control-prev,
.carousel-control-next {
    width: 5%;
    color: var(--bs-primary, #0d6efd);
}

.carousel-control-prev:hover,
.carousel-control-next:hover {
    color: var(--bs-primary, #0d6efd);
    opacity: 0.8;
}

/* Carousel indicators */
.carousel-indicators {
    margin-bottom: 0;
}

.carousel-indicators [data-bs-target] {
    background-color: var(--bs-primary, #0d6efd);
}

/* ======================================
   AVATAR ENHANCEMENTS
   ====================================== */

/* Avatar container styling (uses Bootstrap utilities) */
.rounded-circle {
    overflow: hidden;
    position: relative;
}

.rounded-circle img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
}

/* Avatar hover effect */
.card:hover .rounded-circle {
    transform: scale(1.05);
    transition: transform 0.2s ease;
}

/* ======================================
   STICKY BOTTOM CONTROLS
   ====================================== */

/* Sticky bottom carousel controls */
.carousel-sticky-controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1050;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 8px 16px;
    transition: all 0.3s ease;
}

.carousel-sticky-controls:hover {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.sticky-controls-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.carousel-sticky-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--bs-primary, #0d6efd);
    background: white;
    color: var(--bs-primary, #0d6efd);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.carousel-sticky-btn:hover {
    background: var(--bs-primary, #0d6efd);
    color: white;
    transform: scale(1.05);
}

.carousel-play-pause-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--bs-secondary, #6c757d);
    background: white;
    color: var(--bs-secondary, #6c757d);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.carousel-play-pause-btn:hover {
    background: var(--bs-secondary, #6c757d);
    color: white;
}

.carousel-slide-counter {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--bs-dark, #333);
    min-width: 40px;
    text-align: center;
    white-space: nowrap;
}

/* Hide sticky controls on very small screens */
@media (max-width: 480px) {
    .carousel-sticky-controls {
        bottom: 10px;
        padding: 6px 12px;
    }
    
    .carousel-sticky-btn,
    .carousel-play-pause-btn {
        width: 32px;
        height: 32px;
    }
    
    .carousel-slide-counter {
        font-size: 0.75rem;
        min-width: 35px;
    }
}

/* Hide original carousel controls when sticky controls are shown */
.container-fluid:has(.carousel-sticky-controls) .carousel-control-prev,
.container-fluid:has(.carousel-sticky-controls) .carousel-control-next {
    display: none;
}

/* Alternative for browsers that don't support :has() */
.carousel-with-sticky-controls .carousel-control-prev,
.carousel-with-sticky-controls .carousel-control-next {
    display: none;
}

/* ======================================
   UNIFORM CARD GRID LAYOUT
   ====================================== */

/* Grid container for uniform card layout */
.carousel-grid-container {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 10px;
    max-width: 100%;
    min-height: 400px;
    flex-wrap: nowrap;
}

/* Grid items - force all cards to same size */
.carousel-grid-item {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 200px;
}

/* Uniform card dimensions - ALL CARDS SAME SIZE */
.narrow-card {
    width: 180px !important;
    height: 240px !important;
    max-width: 180px !important;
    min-width: 180px !important;
    max-height: 240px !important;
    min-height: 240px !important;
    margin: 0 auto !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden;
}

/* Force card body to fill available space */
.narrow-card .card-body {
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    flex: 1 !important;
    padding: 0.75rem 0.5rem !important;
    height: 100% !important;
    overflow: hidden;
}

/* Fixed avatar section */
.narrow-card .avatar-section {
    flex-shrink: 0;
    margin-bottom: 0.5rem;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Fixed name section */
.narrow-card .name-section {
    flex-shrink: 0;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.25rem;
    overflow: hidden;
}

.narrow-card .name-section .card-title {
    font-size: 0.85rem !important;
    line-height: 1.1 !important;
    margin: 0 !important;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    max-width: 100%;
}

/* Flexible content section */
.narrow-card .content-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    overflow: hidden;
    min-height: 60px;
}

.narrow-card .content-section h6 {
    font-size: 0.8rem !important;
    margin: 0.25rem 0 !important;
}

.narrow-card .content-section p {
    font-size: 0.7rem !important;
    margin: 0.2rem 0 !important;
    line-height: 1.2 !important;
}

.narrow-card .content-section blockquote {
    font-size: 0.65rem !important;
    margin: 0.2rem 0 !important;
    line-height: 1.2 !important;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Fixed footer section */
.narrow-card .footer-section {
    flex-shrink: 0;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: auto;
}

.narrow-card .footer-section small {
    font-size: 0.65rem !important;
    line-height: 1 !important;
}

/* Avatar sizing within cards */
.narrow-card .rounded-circle {
    width: 45px !important;
    height: 45px !important;
    font-size: 16px !important;
    flex-shrink: 0;
}

/* Responsive grid adjustments */
@media (max-width: 768px) {
    .carousel-grid-container {
        gap: 10px;
        min-height: 350px;
    }
    
    .narrow-card {
        width: 160px !important;
        height: 220px !important;
        max-width: 160px !important;
        min-width: 160px !important;
        max-height: 220px !important;
        min-height: 220px !important;
    }
    
    .narrow-card .avatar-section {
        height: 55px;
    }
    
    .narrow-card .rounded-circle {
        width: 40px !important;
        height: 40px !important;
        font-size: 14px !important;
    }
}

@media (max-width: 576px) {
    .carousel-grid-container {
        gap: 8px;
        min-height: 300px;
    }
    
    .narrow-card {
        width: 140px !important;
        height: 200px !important;
        max-width: 140px !important;
        min-width: 140px !important;
        max-height: 200px !important;
        min-height: 200px !important;
    }
    
    .narrow-card .card-body {
        padding: 0.5rem 0.25rem !important;
    }
    
    .narrow-card .avatar-section {
        height: 50px;
    }
    
    .narrow-card .name-section {
        height: 30px;
    }
    
    .narrow-card .name-section .card-title {
        font-size: 0.75rem !important;
    }
    
    .narrow-card .rounded-circle {
        width: 35px !important;
        height: 35px !important;
        font-size: 12px !important;
    }
    
    .narrow-card .content-section {
        min-height: 50px;
    }
}

/* ======================================
   NARROW CARD STYLING
   ====================================== */

/* ======================================
   RESPONSIVE ADJUSTMENTS
   ====================================== */

/* Mobile adjustments */
@media (max-width: 576px) {
    .carousel .row {
        --bs-gutter-x: 0.5rem;
        --bs-gutter-y: 0.75rem;
    }
    
    .carousel-control-prev,
    .carousel-control-next {
        width: 8%;
    }
}

/* ======================================
   THEME INTEGRATION
   ====================================== */

/* Support for custom color themes */
.carousel[data-color] {
    --bs-primary: attr(data-color);
}

/* Card hover effects using Bootstrap shadow utilities */
.card {
    transition: all 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
}

/* ======================================
   ACCESSIBILITY ENHANCEMENTS
   ====================================== */

.carousel-control-prev:focus,
.carousel-control-next:focus {
    outline: 2px solid var(--bs-primary, #0d6efd);
    outline-offset: 2px;
}

.carousel-indicators [data-bs-target]:focus {
    outline: 2px solid var(--bs-primary, #0d6efd);
    outline-offset: 2px;
}

/* Custom Column Class for 5 items */
.col-lg-2-5 {
    flex: 0 0 20%;
    max-width: 20%;
}

@media (max-width: 991.98px) {
    .col-lg-2-5 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* Bootstrap Carousel Controls */
.givewp-donor-carousel-bootstrap .carousel-control-prev,
.givewp-donor-carousel-bootstrap .carousel-control-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid var(--givewp-carousel-primary, #219653);
    border-radius: 50%;
    opacity: 1;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
    z-index: 10;
}

.givewp-donor-carousel-bootstrap .carousel-control-prev {
    left: -25px;
}

.givewp-donor-carousel-bootstrap .carousel-control-next {
    right: -25px;
}

.givewp-donor-carousel-bootstrap .carousel-control-prev:hover,
.givewp-donor-carousel-bootstrap .carousel-control-next:hover {
    background: var(--givewp-carousel-primary, #219653);
    transform: translateY(-50%) scale(1.1);
    opacity: 1;
}

.givewp-donor-carousel-bootstrap .carousel-control-prev-icon,
.givewp-donor-carousel-bootstrap .carousel-control-next-icon {
    width: 20px;
    height: 20px;
    background-size: 20px 20px;
}

.givewp-donor-carousel-bootstrap .carousel-control-prev:hover .carousel-control-prev-icon,
.givewp-donor-carousel-bootstrap .carousel-control-next:hover .carousel-control-next-icon {
    filter: brightness(0) invert(1);
}

/* Bootstrap Carousel Indicators */
.givewp-donor-carousel-bootstrap .carousel-indicators {
    position: static;
    margin: 1.5rem 0 0 0;
    justify-content: center;
}

.givewp-donor-carousel-bootstrap .carousel-indicators [data-bs-target] {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--givewp-carousel-primary, #219653);
    background-color: transparent;
    opacity: 0.5;
    transition: all 0.3s ease;
    margin: 0 4px;
}

.givewp-donor-carousel-bootstrap .carousel-indicators .active {
    background-color: var(--givewp-carousel-primary, #219653);
    opacity: 1;
    transform: scale(1.2);
}

/* Donor Card Enhancements for Bootstrap */
.bootstrap-carousel-wrapper .givewp-donor-card {
    border: 2px solid var(--givewp-carousel-border, #e2e8f0);
    border-radius: var(--givewp-carousel-radius, 8px);
    background: #fff;
    box-shadow: var(--givewp-carousel-shadow, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
    transition: all 0.3s ease;
    height: 100%; /* Ensure all cards in a row have equal height */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.bootstrap-carousel-wrapper .givewp-donor-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px -8px rgba(0, 0, 0, 0.2);
    border-color: var(--givewp-carousel-primary, #219653);
}

/* Responsive Adjustments for Bootstrap */
@media (max-width: 768px) {
    .bootstrap-carousel-wrapper {
        margin: 1rem 0;
    }
    
    .givewp-donor-carousel-bootstrap .carousel-inner {
        padding: 1rem 0;
    }
    
    .givewp-donor-carousel-bootstrap .carousel-control-prev,
    .givewp-donor-carousel-bootstrap .carousel-control-next {
        width: 40px;
        height: 40px;
    }
    
    .givewp-donor-carousel-bootstrap .carousel-control-prev {
        left: -20px;
    }
    
    .givewp-donor-carousel-bootstrap .carousel-control-next {
        right: -20px;
    }
    
    .givewp-donor-carousel-bootstrap .carousel-control-prev-icon,
    .givewp-donor-carousel-bootstrap .carousel-control-next-icon {
        width: 16px;
        height: 16px;
        background-size: 16px 16px;
    }
    
    .givewp-donor-carousel-bootstrap .carousel-indicators [data-bs-target] {
        width: 10px;
        height: 10px;
        margin: 0 3px;
    }
}

@media (max-width: 576px) {
    .givewp-donor-carousel-bootstrap .carousel-control-prev,
    .givewp-donor-carousel-bootstrap .carousel-control-next {
        width: 35px;
        height: 35px;
        border-width: 1px;
    }
    
    .givewp-donor-carousel-bootstrap .carousel-control-prev {
        left: -17px;
    }
    
    .givewp-donor-carousel-bootstrap .carousel-control-next {
        right: -17px;
    }
    
    .givewp-donor-carousel-bootstrap .carousel-indicators [data-bs-target] {
        width: 8px;
        height: 8px;
        margin: 0 2px;
    }
}

/* Color Theme Support */
.bootstrap-carousel-wrapper[data-color] {
    --givewp-carousel-primary: attr(data-color);
}

/* Accessibility Improvements */
.givewp-donor-carousel-bootstrap .carousel-control-prev:focus,
.givewp-donor-carousel-bootstrap .carousel-control-next:focus {
    outline: 2px solid var(--givewp-carousel-primary, #219653);
    outline-offset: 2px;
}

.givewp-donor-carousel-bootstrap .carousel-indicators [data-bs-target]:focus {
    outline: 2px solid var(--givewp-carousel-primary, #219653);
    outline-offset: 2px;
}

/* Critical: Donor Card Layout Fix */
.givewp-donor-card {
    background: #fff !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 8px !important;
    padding: 20px !important;
    text-align: center !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
}

.givewp-donor-card:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
}

.givewp-donor-card__header {
    margin-bottom: 15px !important;
}

.givewp-donor-card__avatar {
    /* Default size - can be overridden by inline styles */
    width: 75px !important;
    height: 75px !important;
    border-radius: 50% !important;
    margin: 0 auto 12px !important;
    background: #f8f9fa !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 26px !important;
    font-weight: bold !important;
    color: #495057 !important;
    border: 3px solid #e9ecef !important;
    transition: transform 0.2s ease !important;
    overflow: hidden !important; /* Ensure images don't overflow */
}

.givewp-donor-card__avatar img {
    max-width: 100% !important;
    max-height: 100% !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    display: block !important;
}

.givewp-donor-card__avatar:hover {
    transform: scale(1.05) !important;
}

/* Responsive avatar font size based on avatar size */
.givewp-donor-card__avatar[style*="width: 50px"] { font-size: 18px !important; }
.givewp-donor-card__avatar[style*="width: 60px"] { font-size: 22px !important; }
.givewp-donor-card__avatar[style*="width: 75px"] { font-size: 26px !important; }
.givewp-donor-card__avatar[style*="width: 80px"] { font-size: 28px !important; }
.givewp-donor-card__avatar[style*="width: 100px"] { font-size: 34px !important; }
.givewp-donor-card__avatar[style*="width: 120px"] { font-size: 40px !important; }

.givewp-donor-card__name {
    font-size: 18px !important;
    font-weight: 600 !important;
    margin: 0 0 15px 0 !important;
    color: #333 !important;
    line-height: 1.3 !important;
}

.givewp-donor-card__content {
    flex-grow: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
}

.givewp-donor-card__amount {
    font-size: 20px !important;
    font-weight: 700 !important;
    color: var(--givewp-carousel-primary, #28a745) !important;
    margin: 0 0 8px 0 !important;
}

.givewp-donor-card__company {
    font-size: 14px !important;
    color: #6c757d !important;
    margin: 0 0 8px 0 !important;
    font-style: italic !important;
}

.givewp-donor-card__date {
    font-size: 12px !important;
    color: #999 !important;
    margin: 0 !important;
}

.givewp-donor-card__comment {
    font-size: 14px !important;
    color: #495057 !important;
    margin: 8px 0 !important;
    font-style: italic !important;
    line-height: 1.4 !important;
}

/* Print Styles */
@media print {
    .bootstrap-carousel-wrapper .carousel-control-prev,
    .bootstrap-carousel-wrapper .carousel-control-next,
    .bootstrap-carousel-wrapper .carousel-indicators {
        display: none !important;
    }
    
    .bootstrap-carousel-wrapper .carousel-item {
        display: block !important;
        transform: none !important;
    }
    
    .bootstrap-carousel-wrapper .carousel-inner {
        overflow: visible !important;
    }
}

/* Animation Enhancements */
@media (prefers-reduced-motion: reduce) {
    .givewp-donor-carousel-bootstrap .carousel-item {
        transition: none;
    }
    
    .givewp-donor-carousel-bootstrap .carousel-control-prev,
    .givewp-donor-carousel-bootstrap .carousel-control-next {
        transition: none;
    }
    
    .bootstrap-carousel-wrapper .givewp-donor-card {
        transition: none;
    }
}