/*
 * AFA Activities – Public timetable grid
 * v1.1 — CSS Grid layout, direct inline-style filter via JS
 */

/* ══ WRAP ═══════════════════════════════════════════════════ */
.afa-tt-wrap {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: .9rem;
    color: #111;
    max-width: 100%;
    box-sizing: border-box;
}
.afa-tt-wrap *, .afa-tt-wrap *::before, .afa-tt-wrap *::after {
    box-sizing: border-box;
}

/* ══ FILTER BAR ══════════════════════════════════════════════ */
.afa-filter-bar {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    padding: 10px 14px;
    margin-bottom: 14px;
    background: #f9f9f9;
    border: 1px solid #e4e0da;
    border-radius: 6px;
}
.afa-filter-label {
    font-size: .78rem;
    font-weight: 700;
    color: #636363;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}
.afa-chips {
    display: flex !important;
    flex-wrap: wrap;
    gap: 5px;
}
.afa-chip {
    display: inline-flex !important;
    align-items: center;
    padding: 4px 12px;
    border: 1.5px solid #e4e0da;
    border-radius: 20px;
    cursor: pointer;
    font-size: .8rem;
    user-select: none;
    background: #fff;
    color: #111;
    transition: border-color .12s, background .12s, color .12s;
    margin: 0;
}
.afa-chip input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}
.afa-chip:hover { border-color: #d8613c; color: #d8613c; }
.afa-chip.afa-chip--active {
    background: #d8613c !important;
    border-color: #d8613c !important;
    color: #fff !important;
}
.afa-chip-reset {
    padding: 4px 12px;
    border: 1.5px solid #e4e0da;
    border-radius: 20px;
    background: #fff;
    font-size: .78rem;
    cursor: pointer;
    color: #636363;
    font-family: inherit;
    line-height: 1.4;
}
.afa-chip-reset:hover { background: #f0f0f0; border-color: #ccc; }

/* ══ MOBILE DAY NAV (hidden on desktop ≥701px) ═══════════════ */
.afa-day-nav {
    display: none !important; /* JS overrides on mobile via media query */
}

/* ══ TIMETABLE SCROLL SHELL ══════════════════════════════════ */
.afa-tt-scroll {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #e4e0da;
    border-radius: 6px;
    background: #fff;
}

/* ══ TIMETABLE GRID ══════════════════════════════════════════ */
/* grid-template-columns is set via inline style in PHP */
.afa-tt {
    display: grid !important;
    min-width: 500px; /* ensure at least some minimum even on mobile */
    width: 100%;
}

/* ── Time axis cell ─────────────────────────────────────────── */
.afa-tt-timecol {
    /* column sizing handled by grid-template-columns in PHP */
    border-right: 1px solid #e4e0da;
    background: #fafafa;
}

/* ── Day column cell ────────────────────────────────────────── */
.afa-tt-day {
    border-right: 1px solid #d0ccc5;
    /* ALL day columns are visible on desktop — JS only toggles .afa-day--active on mobile */
}
.afa-tt-day:last-child {
    border-right: none;
}

/* ── Column headers (sticky) ────────────────────────────────── */
.afa-tt-header {
    height: 38px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    background: #d8613c;
    color: #fff;
    border-bottom: 2px solid #b84d2a;
    position: sticky;
    top: 0;
    z-index: 4;
}
.afa-tt-timecol .afa-tt-header {
    background: #fafafa;
    border-bottom: 2px solid #e4e0da;
    color: transparent; /* placeholder, no label */
}

/* ── Column bodies (positioned parent for rules + blocks) ──── */
.afa-tt-body {
    position: relative !important;
    overflow: hidden;
}

/* ── Time labels in the time axis ──────────────────────────── */
.afa-time-label {
    position: absolute;
    right: 6px;
    transform: translateY(-50%);
    font-size: .67rem;
    color: #888;
    white-space: nowrap;
    pointer-events: none;
    line-height: 1;
    z-index: 1;
}

/* ── Horizontal time rules ──────────────────────────────────── */
.afa-rule {
    position: absolute !important;
    left: 0;
    right: 0;
    height: 1px;
    background: #e8e4de;
    pointer-events: none;
    z-index: 1;
}
.afa-rule--hour {
    height: 2px !important;
    background: #b8b0a8 !important;
}

/* ══ ACTIVITY BLOCKS ═════════════════════════════════════════ */
.afa-block {
    position: absolute !important;
    left: 3px;
    right: 3px;
    /* right is overridden to 'auto' by JS when overlap layout is applied */
    border-radius: 4px;
    padding: 3px 6px;
    overflow: hidden;
    cursor: pointer;
    z-index: 2;
    min-height: 20px;
    box-sizing: border-box;
    transition: box-shadow .12s;
    /* background-color, border-left, color set inline */
}
.afa-block:hover, .afa-block:focus {
    box-shadow: 0 3px 12px rgba(0,0,0,.25);
    z-index: 10;
    outline: none;
}
.afa-block-name {
    display: block;
    font-size: .72rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}
.afa-block-time {
    display: block;
    font-size: .65rem;
    opacity: .9;
    line-height: 1.3;
}
.afa-block-loc {
    display: block;
    font-size: .62rem;
    opacity: .75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ══ POPUP ═══════════════════════════════════════════════════ */
.afa-popup {
    position: fixed !important;
    z-index: 999999 !important;
    background: #fff;
    border: 1px solid #d8d2cc;
    border-radius: 8px;
    padding: 14px 16px 12px;
    width: 240px;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
    font-size: .82rem;
    line-height: 1.5;
    pointer-events: all;
}
.afa-popup-close {
    position: absolute;
    top: 8px; right: 10px;
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    color: #888;
    padding: 2px 4px;
    border-radius: 3px;
    line-height: 1;
}
.afa-popup-close:hover { background: #f0f0f0; }
.afa-popup-name {
    margin: 0 20px 8px 0;
    font-size: .92rem;
    font-weight: 700;
    color: #111;
}
.afa-popup-dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 8px;
    margin: 0 0 4px;
    font-size: .78rem;
}
.afa-popup-dl dt { color: #636363; font-weight: 600; white-space: nowrap; }
.afa-popup-dl dd { margin: 0; color: #111; }
.afa-popup-desc {
    margin: 6px 0 0;
    font-size: .78rem;
    color: #636363;
    border-top: 1px solid #e4e0da;
    padding-top: 5px;
    line-height: 1.4;
}
.afa-popup-desc:empty { display: none; }

/* ══ MOBILE ≤ 700px ══════════════════════════════════════════ */
@media (max-width: 700px) {

    /* Show nav bars */
    .afa-day-nav {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 8px 12px;
        background: #d8613c;
        border-radius: 6px;
        color: #fff;
        margin-bottom: 8px;
    }
    .afa-day-nav--bottom { margin-top: 8px; margin-bottom: 0; }

    .afa-nav-day-label {
        font-weight: 700;
        font-size: 1rem;
        text-align: center;
        flex: 1;
        color: #fff;
    }
    .afa-nav-btn {
        background: rgba(255,255,255,.2);
        border: none;
        color: #fff;
        font-size: 1.6rem;
        line-height: 1;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .afa-nav-btn:disabled { opacity: .4; }

    /* Single-column: hide all day cols; JS shows .afa-day--active */
    .afa-tt-scroll { overflow-x: hidden; border-left: none; border-right: none; border-radius: 0; }
    .afa-tt { display: flex !important; min-width: 0; }
    .afa-tt-timecol { flex: 0 0 44px; }
    .afa-tt-day { display: none !important; flex: 1 1 auto; min-width: 0; }
    .afa-tt-day.afa-day--active { display: block !important; flex: 1 1 auto; }

    .afa-block-loc { display: none; }
    .afa-tt-day .afa-tt-header { display: none !important; }
}

/* ══ POPUP PROVIDER SECTION ═════════════════════════════════ */
.afa-popup-provider {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e4e0da;
}
.afa-popup-provider-title {
    margin: 0 0 8px 0;
    font-size: .85rem;
    font-weight: 700;
    color: #636363;
}
.afa-popup-provider-logo {
    text-align: center;
    margin-bottom: 6px;
}
.afa-popup-provider-logo img {
    max-width: 60px;
    max-height: 60px;
    width: auto;
    height: auto;
}
.afa-popup-provider-name {
    margin: 4px 0;
    font-size: .9rem;
    font-weight: 600;
    color: #222;
}
.afa-popup-provider-contact {
    font-size: .8rem;
    line-height: 1.5;
    color: #555;
}
.afa-popup-provider-contact a {
    display: block;
    color: #2980b9;
    text-decoration: none;
    word-break: break-word;
}
.afa-popup-provider-contact a:hover {
    text-decoration: underline;
}
.afa-popup-more-info {
    display: inline-block;
    margin-top: 8px;
    color: #2980b9;
    text-decoration: none;
    font-size: .85rem;
    font-weight: 600;
}
.afa-popup-more-info:hover {
    text-decoration: underline;
}
.afa-popup-provider-inscription {
    margin-top: 8px;
}
.afa-inscription-link {
    display: inline-block;
    padding: 6px 14px;
    background: #2980b9;
    color: #fff !important;
    border-radius: 4px;
    text-decoration: none;
    font-size: .85rem;
    font-weight: 600;
}
.afa-inscription-link:hover {
    background: #1a5f8a;
    text-decoration: none;
}

/* ══ ACTIVITY LIST (CARD GRID) ══════════════════════════════ */
.afa-activity-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    padding: 20px 10px;
}

.afa-activity-card {
    border: 1px solid #e4e0da;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,.05);
    transition: box-shadow .2s, transform .2s;
    display: flex;
    flex-direction: column;
}
.afa-activity-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
    transform: translateY(-2px);
}

.afa-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    color: #111;
}
.afa-card-logo {
    max-width: 80px;
    max-height: 60px;
    width: auto;
    height: auto;
    object-fit: contain;
    flex-shrink: 0;
}
.afa-card-title-group {
    flex: 1;
    min-width: 0;
}
.afa-card-activity-name {
    margin: 0 0 4px 0;
    font-size: 1.1rem;
    font-weight: 700;
    word-wrap: break-word;
}
.afa-card-provider-name {
    margin: 0;
    font-size: .85rem;
    font-weight: 500;
    opacity: .7;
}

.afa-card-description {
    padding: 0 16px;
    margin: 12px 0;
    font-size: .9rem;
    line-height: 1.5;
    color: #555;
}

.afa-card-provider-contact {
    padding: 12px 16px;
    background: #fafafa;
    border-top: 1px solid #e4e0da;
    border-bottom: 1px solid #e4e0da;
}
.afa-contact-email,
.afa-contact-phone,
.afa-contact-web {
    display: block;
    font-size: .85rem;
    color: #2980b9;
    text-decoration: none;
    margin-bottom: 4px;
    word-break: break-word;
}
.afa-contact-email:last-child,
.afa-contact-phone:last-child,
.afa-contact-web:last-child {
    margin-bottom: 0;
}
.afa-contact-email:hover,
.afa-contact-phone:hover,
.afa-contact-web:hover {
    text-decoration: underline;
}

.afa-card-schedules {
    padding: 16px;
    flex: 1;
}
.afa-card-schedules h4 {
    margin: 0 0 12px 0;
    font-size: .95rem;
    font-weight: 700;
}
.afa-schedules-table {
    width: 100%;
    font-size: .85rem;
    border-collapse: collapse;
}
.afa-schedules-table thead {
    background: #f0f0f0;
    font-weight: 600;
}
.afa-schedules-table th,
.afa-schedules-table td {
    padding: 8px 6px;
    text-align: left;
    border-bottom: 1px solid #e4e0da;
}
.afa-schedules-table tbody tr:last-child td {
    border-bottom: none;
}

.afa-card-inscription {
    padding: 0 16px 16px 16px;
}
.afa-card-inscription .button {
    width: 100%;
    display: block;
    text-align: center;
    text-decoration: none;
    padding: 10px 12px;
    font-size: .9rem;
    border-radius: 4px;
}
.afa-card-inscription .button-primary {
    background: #2980b9;
    color: #fff;
    border: none;
}
.afa-card-inscription .button-primary:hover {
    background: #1a5a96;
}

/* Responsive card grid for mobile */
@media (max-width: 600px) {
    .afa-activity-list {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 12px;
    }
    .afa-card-header {
        padding: 12px;
    }
    .afa-card-logo {
        max-width: 64px;
        max-height: 50px;
        width: auto;
        height: auto;
    }
    .afa-card-activity-name {
        font-size: 1rem;
    }
    .afa-schedules-table {
        font-size: .8rem;
    }
    .afa-schedules-table th,
    .afa-schedules-table td {
        padding: 6px 4px;
    }
}

/* ── Providers List [afa_providers_list] ───────────────────────────────── */

.afa-providers-list {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding: 1rem 0;
}

.afa-provider-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,.07);
}

/* Header */
.afa-provider-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    flex-wrap: wrap;
}

.afa-provider-logo {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 6px;
    padding: 4px;
}
.afa-provider-logo img {
    max-width: 120px;
    max-height: 72px;
    width: auto;
    height: auto;
    display: block;
}

.afa-provider-header-info {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.afa-provider-name {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
    color: #2c3e50;
    flex: 1;
    min-width: 0;
}

/* Tríptic button */
.afa-triptic-btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .4rem .85rem;
    background: #2980b9;
    color: #fff !important;
    border-radius: 4px;
    font-size: .85rem;
    font-weight: 600;
    text-decoration: none !important;
    white-space: nowrap;
    transition: background .15s;
}
.afa-triptic-btn:hover {
    background: #1f6391;
}
.afa-triptic-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    line-height: 1;
}

/* Description */
.afa-provider-description {
    margin: 0;
    padding: .9rem 1.5rem;
    color: #555;
    font-size: .95rem;
    line-height: 1.6;
    border-bottom: 1px solid #f0f0f0;
}

/* Contact row */
.afa-provider-contact {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    padding: .7rem 1.5rem;
    background: #fafafa;
    border-bottom: 1px solid #ececec;
}
.afa-provider-contact .afa-contact-item {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .88rem;
    color: #555 !important;
    text-decoration: none !important;
}
.afa-provider-contact .afa-contact-item:hover {
    color: #2980b9 !important;
}
.afa-provider-contact .dashicons {
    font-size: 15px;
    width: 15px;
    height: 15px;
    color: #888;
}

/* Activities section */
.afa-provider-activities {
    padding: 1rem 1.5rem 1.5rem;
}
.afa-provider-activities-title {
    margin: 0 0 .85rem;
    font-size: 1rem;
    font-weight: 600;
    color: #444;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.afa-activity-mini-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: .75rem;
}

.afa-activity-mini-card {
    border: 2px solid transparent;
    border-radius: 6px;
    padding: .75rem 1rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: .5rem;
}

.afa-activity-mini-body {
    flex: 1;
}
.afa-activity-mini-name {
    display: block;
    font-size: .95rem;
    font-weight: 700;
    margin-bottom: .2rem;
}
.afa-activity-mini-desc {
    margin: 0;
    font-size: .82rem;
    line-height: 1.45;
    opacity: .85;
}
.afa-activity-mini-grades {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
    margin-top: .5rem;
}
.afa-grade-tag {
    display: inline-block;
    padding: .2rem .5rem;
    border-radius: 3px;
    font-size: .75rem;
    font-weight: 600;
    background: rgba(0,0,0,.1);
    white-space: nowrap;
}

.afa-activity-mini-footer {
    margin-top: .4rem;
}
.afa-inscription-btn {
    display: inline-block;
    padding: .3rem .75rem;
    border-radius: 4px;
    font-size: .82rem;
    font-weight: 600;
    background: rgba(0,0,0,.12);
    color: inherit !important;
    text-decoration: none !important;
    transition: background .15s;
}
.afa-inscription-btn:hover {
    background: rgba(0,0,0,.22);
}

/* Responsive */
@media (max-width: 600px) {
    .afa-provider-header {
        padding: 1rem;
    }
    .afa-provider-description,
    .afa-provider-contact,
    .afa-provider-activities {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    .afa-provider-logo img {
        max-width: 90px;
        max-height: 56px;
        width: auto;
        height: auto;
    }
    .afa-activity-mini-list {
        grid-template-columns: 1fr;
    }
}
