/**
 * Card Layout Fix - Comprehensive Override
 * This file ensures hadith cards display full text without clipping
 */

/* UNIFORM CARD HEIGHT - All cards same size */
.hcd-wrapper .topic-card,
.hcd-wrapper .hadith-card,
.topic-card,
.hadith-card {
    height: 420px !important;
    min-height: 420px !important;
    max-height: 420px !important;
    overflow: hidden !important;
}

/* Fixed height for content area with text truncation */
.hcd-wrapper .hadith-content,
.hadith-content,
.topic-card .hadith-content,
.hadith-card .hadith-content {
    height: 240px !important;
    min-height: 240px !important;
    max-height: 240px !important;
    overflow: hidden !important;
    flex: 0 0 240px !important;
}

/* Text container with line clamping */
.hcd-wrapper .hadith-text-container,
.hadith-text-container,
.topic-card .hadith-text-container {
    height: 180px !important;
    max-height: 180px !important;
    overflow: hidden !important;
    display: block !important;
}

/* Text content with ellipsis for long text */
.hcd-wrapper .hadith-text-content,
.hadith-text-content,
.topic-card .hadith-text-content,
.topic-card .hadith-text-container p,
.topic-card .hadith-text-container div {
    display: -webkit-box !important;
    -webkit-line-clamp: 7 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-height: 180px !important;
    line-height: 1.6 !important;
    font-size: 0.95rem !important;
}

/* Fixed height for metadata section */
.hcd-wrapper .topic-meta,
.topic-meta,
.topic-card .topic-meta {
    height: 180px !important;
    min-height: 180px !important;
    max-height: 180px !important;
    flex: 0 0 180px !important;
    overflow: hidden !important;
}

/* Ensure proper text wrapping */
.hadith-text-content,
.topic-card .hadith-text-content,
.topic-card .hadith-text-container p {
    word-wrap: break-word !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    hyphens: auto !important;
}

/* Grid layout adjustments */
.hcd-wrapper .hadiths-grid,
.hadiths-grid {
    grid-auto-rows: auto !important;
    align-items: start !important;
}

/* Card flex layout */
.topic-card,
.hadith-card {
    display: flex !important;
    flex-direction: column !important;
}

.topic-card .hadith-content,
.hadith-card .hadith-content {
    flex: 1 1 auto !important;
}

.topic-card .topic-meta,
.hadith-card .topic-meta {
    flex: 0 0 auto !important;
    margin-top: auto !important;
    gap: 6px !important;
    padding: 12px 20px 15px !important;
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    border-left: 4px solid #23DE00 !important;
    border-top: none !important;
    transition: all 0.3s ease !important;
}

.topic-card:hover .topic-meta,
.hadith-card:hover .topic-meta {
    background-color: rgba(35, 222, 0, 0.08) !important;
    border-left-width: 6px !important;
}

/* Improved spacing and readability */
.topic-card .hadith-text-content {
    font-size: 1.05rem !important;
    line-height: 1.7 !important;
    padding-bottom: 10px !important;
}

/* Button container improvements */
.topic-card .button-container {
    display: flex !important;
    gap: 10px !important;
    width: 100% !important;
    margin-top: 0 !important;
}

.topic-card .read-more-btn,
.topic-card .full-view-btn {
    flex: 1 !important;
    min-width: 0 !important;
}

/* Narrator row improvements */
.topic-card .topic-narrator-row {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 12px !important;
    width: 100% !important;
}

.topic-card .topic-narrator {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

.topic-card .authenticity-tag {
    flex: 0 0 auto !important;
    white-space: nowrap !important;
}

/* Reference styling */
.topic-card .hadith-reference {
    width: 100% !important;
    text-align: center !important;
}

/* Tablet optimizations */
@media (max-width: 768px) {
    .hcd-wrapper .hadiths-grid,
    .hadiths-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }

    .hcd-wrapper .topic-card,
    .topic-card,
    .hadith-card {
        height: 420px !important;
        min-height: 420px !important;
        max-height: 420px !important;
    }
}

/* Mobile optimizations */
@media (max-width: 480px) {
    .hcd-wrapper .topic-card,
    .topic-card,
    .hadith-card {
        height: 400px !important;
        min-height: 400px !important;
        max-height: 400px !important;
    }

    .hcd-wrapper .hadith-content,
    .topic-card .hadith-content {
        height: 220px !important;
        min-height: 220px !important;
        max-height: 220px !important;
        flex: 0 0 220px !important;
    }

    .hcd-wrapper .hadith-text-container,
    .topic-card .hadith-text-container {
        height: 160px !important;
        max-height: 160px !important;
    }

    .hcd-wrapper .hadith-text-content,
    .topic-card .hadith-text-content,
    .topic-card .hadith-text-container p {
        font-size: 0.9rem !important;
        line-height: 1.5 !important;
        -webkit-line-clamp: 7 !important;
        max-height: 160px !important;
    }

    .hcd-wrapper .topic-meta,
    .topic-card .topic-meta {
        height: 180px !important;
        min-height: 180px !important;
        max-height: 180px !important;
    }

    .topic-card .button-container {
        flex-direction: column !important;
        gap: 6px !important;
    }

    .topic-card .read-more-btn,
    .topic-card .full-view-btn {
        width: 100% !important;
        padding: 7px 12px !important;
        font-size: 0.8rem !important;
    }

    .topic-card .topic-narrator {
        font-size: 0.8rem !important;
        padding: 5px 10px !important;
    }

    .topic-card .authenticity-tag {
        font-size: 0.8rem !important;
        padding: 5px 10px !important;
        min-width: 70px !important;
    }
}

/* Ensure no external styles override these */
.topic-card *,
.hadith-card * {
    box-sizing: border-box !important;
}

/* Remove any max-height constraints from parent containers */
.hcd-wrapper .topics-container,
.topics-container,
.hcd-wrapper .main-content,
.main-content {
    max-height: none !important;
    overflow: visible !important;
}

/* Hide pagination when showing all hadiths */
.hcd-wrapper .pagination[style*="display: none"],
.pagination[style*="display: none"] {
    display: none !important;
}

/* Ensure smooth scrolling for long lists */
html {
    scroll-behavior: smooth;
}

/* Add scroll-to-top button visibility */
.scroll-top-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: var(--primary-color, #23DE00);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    z-index: 1000;
}

.scroll-top-btn:hover {
    background: var(--primary-dark, #1db100);
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.scroll-top-btn.show {
    display: flex !important;
}
