/**
 * irfrank-pages.css
 * Dedicated styles for IRF Ranking & Business Award pages.
 * All classes use the irfrank- prefix to avoid collisions with existing styles.
 * Loaded via ranking-filter.php (for ranking pages) and $extraCss (for business pages).
 */

/* ================================================================
   MOBILE FILTER TRIGGER BUTTON
   Hidden on desktop, visible only on mobile (≤768px).
   Injected into the DOM by rankings.js → initMobileUI().
   ================================================================ */
.irfrank-mobile-filter-btn {
    display: none;
}

@media (max-width: 768px) {
    .irfrank-mobile-filter-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        padding: 12px 16px;
        background: #3b82f6;
        color: #fff;
        border: none;
        border-radius: 8px;
        font-size: 0.95rem;
        font-weight: 600;
        cursor: pointer;
        margin-bottom: 12px;
        box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
    }

    .irfrank-mobile-filter-btn:active {
        transform: scale(0.98);
        background: #2563eb;
    }
}

/* ================================================================
   MOBILE SEARCH BAR
   Hidden on desktop. Shown above .cards-container on mobile.
   Injected by rankings.js → initMobileUI() before #cardView.
   ================================================================ */
.irfrank-mobile-search {
    display: none;
}

@media (max-width: 768px) {
    .irfrank-mobile-search {
        display: block;
        margin-bottom: 12px;
    }

    .irfrank-mobile-search input {
        width: 100%;
        padding: 12px 16px 12px 44px;
        border: 1px solid #d1d5db;
        border-radius: 8px;
        font-size: 1rem; /* Prevent iOS zoom on focus */
        background: #fff url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%2364748b" stroke-width="2"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/></svg>') no-repeat 14px center;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
        box-sizing: border-box;
    }

    .irfrank-mobile-search input:focus {
        outline: none;
        border-color: #3b82f6;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    }
}

/* ================================================================
   FILTER SIDEBAR OVERLAY FIXES
   1. Make filter-title a flex row so the × close button right-aligns.
   2. Raise z-index above common navbar values on mobile.
   ================================================================ */
.filter-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

@media (max-width: 768px) {
    /* Ensure filter panel sits above the fixed navbar */
    .filter-sidebar {
        z-index: 1100 !important;
    }

    body.filter-open::before {
        z-index: 1099 !important;
    }
}

/* ================================================================
   RANKING CARDS  (irfrank-card-*)
   Used by rankings.js renderRankings() for the mobile card view.
   Layout: [rank badge] | [name + location] | [download icon]
   ================================================================ */
.irfrank-card {
    background: #fff;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
    border: 1px solid #e5e7eb;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    position: relative;
}

/* Rank number badge — left side */
.irfrank-card-rank {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Text content — centre */
.irfrank-card-body {
    flex: 1;
    min-width: 0;
    padding-right: 50px; /* clearance so text never overlaps the download button */
}

.irfrank-card-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 4px 0;
    line-height: 1.35;
}

.irfrank-card-meta {
    font-size: 0.82rem;
    color: #64748b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Download icon — absolute top-right, vertically aligned with rank badge */
.irfrank-card-download {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 40px;
    height: 40px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.irfrank-card-download:hover {
    background: #eff6ff;
    border-color: #3b82f6;
}

.irfrank-card-download:active {
    background: #3b82f6;
    border-color: #3b82f6;
    transform: scale(0.92);
}

.irfrank-card-download svg {
    width: 18px;
    height: 18px;
    stroke: #64748b;
    stroke-width: 2;
    transition: stroke 0.15s;
}

.irfrank-card-download:hover svg {
    stroke: #3b82f6;
}

.irfrank-card-download:active svg {
    stroke: #fff;
}

/* ================================================================
   BUSINESS AWARD MOBILE CARDS  (irfrank-biz-card-*)
   #irfrankBizCards is added statically in each business category PHP.
   Hidden on desktop; JS populates and CSS reveals it on mobile.
   ================================================================ */
#irfrankBizCards {
    display: none;
}

@media (max-width: 768px) {
    /* Show mobile card container */
    #irfrankBizCards {
        display: block;
    }

    /* Hide table on mobile for business pages */
    #tableView {
        display: none !important;
    }

    /* Hide desktop pagination container on business pages — mobile uses #irfrankBizPagination */
    .biz-desktop-pagination {
        display: none !important;
    }
}

.irfrank-biz-card {
    background: #fff;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
    border: 1px solid #e5e7eb;
}

.irfrank-biz-card-name {
    font-size: 1rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 4px 0;
    text-transform: capitalize;
}

.irfrank-biz-card-org {
    font-size: 0.875rem;
    color: #475569;
    font-weight: 500;
    margin: 0 0 6px 0;
    text-transform: capitalize;
}

.irfrank-biz-card-award {
    display: inline-block;
    font-size: 0.78rem;
    color: #1d4ed8;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 500;
    text-transform: capitalize;
}

/* Pagination wrapper for business mobile cards */
#irfrankBizPagination {
    display: none;
}

@media (max-width: 768px) {
    #irfrankBizPagination {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 1rem;
        margin-top: 16px;
        padding-top: 1rem;
        border-top: 2px solid #e5e7eb;
    }

    #irfrankBizPagination .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.4rem;
    }
}
