/* ============================================================
   Mobile pass for the volunteer-facing pages.

   Volunteers use the platform mostly on phones — when they're
   walking out of a session, when they're checking the calendar
   between classes, etc. This file consolidates the mobile-only
   tweaks so the experience stays calm and thumb-friendly on
   small screens without polluting the desktop styles.

   Loaded LAST in base.html so its declarations win against any
   earlier media-less or larger-breakpoint rules.

   Breakpoints used here:
   - 760px  : tablet portrait / small landscape phone
   - 540px  : standard phone portrait
   - 380px  : iPhone SE-size devices
   ============================================================ */

/* === iOS-safe form inputs ====================================
   iOS auto-zooms the page when a form input has font-size < 16px.
   Bumping the minimum to 16px on phones avoids the jarring zoom
   without changing desktop typography. */
@media (max-width: 760px) {
    input[type="text"],
    input[type="email"],
    input[type="number"],
    input[type="tel"],
    input[type="date"],
    input[type="time"],
    input[type="password"],
    input[type="search"],
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* === Universal mobile container tighten ====================== */
@media (max-width: 760px) {
    .container,
    .pf-container,
    .ssm-container,
    .eval-container,
    .volunteer-calendar-container,
    .vol-dash-container,
    .admin-classroom-planning-container,
    .admin-evaluations-container {
        padding-left: 14px;
        padding-right: 14px;
    }

    /* Roster + main grid uses `1fr` on tablets, which is implicitly
       `minmax(auto, 1fr)`. When the roster contains a horizontally-
       scrolling strip of fixed-width cards, `auto` makes the grid track
       at least as wide as those cards combined — pushing the whole page
       past the viewport. `minmax(0, 1fr)` lets the track shrink and lets
       the inner overflow:auto handle the scroll. */
    .admin-with-roster {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ============================================================
   Volunteer dashboard
   ============================================================ */
@media (max-width: 760px) {
    .vol-dash-page-section { padding: 18px 0 48px; }

    .vol-dash-hero { padding: 18px; border-radius: 22px; }
    .vol-dash-hero h1 { font-size: 1.6rem; }
    .vol-dash-hero p { font-size: 0.95rem; }
    .vol-dash-hero-actions { flex-wrap: wrap; gap: 8px; }
    .vol-dash-hero-actions a,
    .vol-dash-hero-actions button {
        flex: 1 1 auto;
        min-height: 44px;
        justify-content: center;
        text-align: center;
    }

    .vol-dash-hero-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
    .vol-dash-stat { padding: 12px 14px; }
    .vol-dash-stat strong { font-size: 1.3rem; }

    /* Schools sidebar — collapse to top, horizontal scroll on phones.
       The flex+grid combo here is fragile: without `min-width: 0` on the
       scrolling strip (which is a flex item AND a grid container), the
       strip sizes to fit all cards and shoves the whole page wider than
       the viewport. Clip the outer container too so a stray child can't
       leak past the page edge. */
    .vol-roster {
        position: static;
        max-height: none;
        overflow: hidden;
        max-width: 100%;
        min-width: 0;
        padding: 14px;
        border-radius: 18px;
    }
    .vol-roster-list {
        grid-auto-flow: column;
        grid-auto-columns: 180px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        min-width: 0;
        max-width: 100%;
        padding-bottom: 8px;
        gap: 8px;
    }
    /* The "All schools" card sits OUTSIDE the scroll strip, so it would
       otherwise inherit the full-width feel. Keep it 100% wide so it
       reads as a separate full-row toggle above the scroll strip. */
    .vol-roster-card-all { max-width: 100%; }
    .vol-roster-card { padding: 10px 12px; }
    .vol-roster-card-avatar { width: 36px; height: 36px; flex: 0 0 36px; }
    .vol-roster-help { display: none; }

    /* School + class cards */
    .vol-dash-school-card { border-radius: 20px; }
    .vol-dash-school-header { padding: 16px; flex-direction: column; align-items: stretch; gap: 12px; }
    .vol-dash-school-header > div { width: 100%; }
    .vol-dash-school-stats { justify-content: flex-start; flex-wrap: wrap; }

    .vol-dash-class-grid {
        grid-template-columns: 1fr;
        padding: 14px;
        gap: 12px;
    }
    .vol-dash-class-card { padding: 14px; }
    .vol-dash-class-tags { gap: 5px; }
    .vol-dash-tag { font-size: 0.72rem; padding: 3px 9px; }

    /* Recent evaluations cards on dashboard */
    .evx-body { padding: 16px; }
    .evx-header { flex-direction: column; align-items: stretch; gap: 8px; }
    .evx-create-btn { text-align: center; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
    .evx-item { padding: 14px; gap: 10px; }
    .evx-item-head { flex-direction: column; align-items: flex-start; gap: 6px; }
    .evx-item-date { font-size: 0.78rem; }

    /* Score row: allow the average pill to break to its own line below
       the 4 emoji faces so nothing overflows on narrow viewports. */
    .evx-scores {
        gap: 8px;
        padding: 8px 0;
    }
    .evx-score { min-width: 52px; }
    .evx-score-face { font-size: 1.25rem; }
    .evx-score-label { font-size: 0.66rem; }
    .evx-score-avg {
        margin-left: 0;
        flex-basis: 100%;
        justify-content: center;
        padding: 5px 14px;
    }
}

@media (max-width: 380px) {
    .vol-dash-hero h1 { font-size: 1.45rem; }
    .vol-dash-hero-stats { grid-template-columns: 1fr 1fr; }
    .vol-roster-list { grid-auto-columns: 158px; }
}

/* ============================================================
   Volunteer calendar — compact week + month view
   ============================================================ */
@media (max-width: 760px) {
    /* Header / toolbar */
    .volunteer-calendar-header h1 { font-size: 1.7rem; }
    .volunteer-calendar-top-actions { flex-wrap: wrap; gap: 8px; }
    .cal-fullscreen-link { width: 100%; justify-content: center; }

    .volunteer-calendar-toolbar { border-radius: 18px; }
    .volunteer-calendar-toolbar-body {
        flex-direction: column;
        gap: 12px;
        padding: 14px;
    }
    .volunteer-calendar-toolbar-nav,
    .volunteer-calendar-toolbar-actions {
        display: flex;
        gap: 8px;
        width: 100%;
        justify-content: space-between;
    }
    .volunteer-calendar-nav-button {
        flex: 1 1 auto;
        min-height: 44px;
        justify-content: center;
        text-align: center;
    }
    .volunteer-calendar-toolbar-center {
        order: -1;  /* range above the prev/next buttons */
        text-align: center;
    }
    .volunteer-calendar-view-tabs { justify-content: center; }
    .volunteer-calendar-view-tab { padding: 8px 18px; min-height: 36px; }

    /* Week grid → single column on phones */
    .volunteer-calendar-grid {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }
    .volunteer-calendar-day-card { border-radius: 16px; }
    .volunteer-calendar-day-body { padding: 12px 14px; gap: 8px; }
    .volunteer-calendar-day-header h2 { font-size: 1.05rem; }
    .volunteer-calendar-day-header p { font-size: 0.82rem; }

    /* Month grid stays as 7 cols but tighter */
    .volunteer-calendar-month-day { min-height: 60px; padding: 4px; }
    .volunteer-calendar-month-day-date { font-size: 0.75rem; }
    .volunteer-calendar-month-events { gap: 2px; }
    .volunteer-calendar-month-event { font-size: 0.62rem; padding: 1px 4px; }
    .volunteer-calendar-month-header span { font-size: 0.68rem; padding: 4px 2px; }
}

/* === Fullscreen timeline on mobile ===
   The hour axis + 7 day columns just doesn't fit on a phone. Below
   760px we drop the axis column and let each day column become a
   scrollable strip; below 540px we hide the day columns entirely
   and steer the volunteer to the compact day-card layout instead
   (which IS phone-friendly). */
@media (max-width: 760px) {
    .cal-fullscreen-container { padding: 16px; }

    .cal-timeline {
        --cal-axis-width: 44px;
        --cal-row-height: 48px;
    }
    .cal-timeline-axis-hour span { font-size: 0.66rem; right: 4px; }
    .cal-timeline-day-header { height: 38px; }
    .cal-timeline-day-header strong { font-size: 0.7rem; }
    .cal-timeline-day-header span { font-size: 0.78rem; }
    .cal-timeline-event { padding: 4px 6px; }
    .cal-timeline-event-title { font-size: 0.74rem; }
    .cal-timeline-event-sub { font-size: 0.66rem; }
}

@media (max-width: 540px) {
    /* Make the whole timeline horizontally scrollable so users can
       swipe between days instead of cramming 7 columns into 320 px. */
    .cal-timeline {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .cal-timeline-days {
        grid-template-columns: repeat(7, minmax(110px, 1fr));
        min-width: 770px;
    }
}

/* ============================================================
   Evaluation form
   ============================================================ */
@media (max-width: 760px) {
    .eval-page { padding: 18px 0 140px; }
    .eval-hero h1 { font-size: 1.7rem; }
    .eval-hero p { font-size: 0.95rem; }

    .eval-context-card { padding: 14px 16px; border-radius: 18px; }
    .eval-context-grid { gap: 10px; }
    .eval-context-label { font-size: 0.62rem; }
    .eval-context-item strong { font-size: 0.92rem; }

    .eval-form { border-radius: 18px; }
    .eval-step { padding: 16px; }
    .eval-step-body { padding-left: 0; gap: 12px; }
    .eval-step-num { width: 30px; height: 30px; font-size: 0.92rem; }
    .eval-step-head h2 { font-size: 1.02rem; }
    .eval-step-head p { font-size: 0.86rem; }

    /* Children stepper — bigger touch targets */
    .eval-stepper-btn { width: 48px; min-height: 48px; font-size: 1.5rem; }
    .eval-children-input input[type="number"] {
        width: 80px;
        padding: 12px 4px;
    }

    /* Textareas — generous min-height */
    .eval-field-textarea textarea { min-height: 130px; padding: 14px; }

    /* Sticky footer — respect iOS safe area & make submit dominant */
    .eval-footer {
        padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
        flex-wrap: wrap;
        gap: 8px;
    }
    .eval-cancel { flex: 0 0 auto; min-height: 44px; display: inline-flex; align-items: center; }
    .eval-submit {
        flex: 1 1 auto;
        min-height: 48px;
        justify-content: center;
        text-align: center;
        font-size: 0.98rem;
        padding: 13px 22px;
    }
}

@media (max-width: 460px) {
    /* Rating cards already collapse via existing CSS; just tighten
       gaps and ensure faces stay legible. */
    .eval-rating { gap: 4px; }
    .eval-rating-option { min-height: 64px; padding: 8px 2px; }
    .eval-rating-face { font-size: 1.5rem; }
}

/* ============================================================
   Profile + edit
   ============================================================ */
@media (max-width: 760px) {
    .pf-page { padding: 18px 0 120px; }
    .pf-hero h1 { font-size: 1.6rem; }
    .pf-hero p { font-size: 0.95rem; }

    .pf-layout { gap: 14px; }

    .pf-sidebar { position: static; border-radius: 22px; }
    .pf-sidebar-body { padding: 18px; gap: 12px; }
    .pf-avatar-wrap { width: 120px; height: 120px; }
    .pf-name { font-size: 1.2rem; }
    .pf-email { font-size: 0.82rem; }

    .pf-details-card { padding: 18px; border-radius: 22px; }
    .pf-details-head { flex-direction: column; align-items: stretch; gap: 10px; }
    .pf-details-head h2 { font-size: 1.18rem; }
    .pf-details-grid { grid-template-columns: 1fr; gap: 10px; }
    .pf-detail { padding: 12px 14px; }

    /* Edit form footer respects safe-area */
    .pf-form-footer {
        padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
        flex-wrap: wrap;
        gap: 8px;
    }
    .pf-cancel-btn { flex: 0 0 auto; min-height: 44px; display: inline-flex; align-items: center; }
    .pf-save-btn {
        flex: 1 1 auto;
        min-height: 48px;
        justify-content: center;
        font-size: 0.98rem;
        padding: 13px 22px;
    }

    /* Step body should already collapse via existing CSS */
    .pf-step { padding: 18px; }
    .pf-step-body { padding-left: 0; }
}

/* ============================================================
   Notification bell popover
   ============================================================ */
@media (max-width: 540px) {
    .notif-popover {
        position: fixed;
        top: 64px;
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
    }
    .notif-popover-head { padding: 14px 16px 10px; }
}

/* ============================================================
   Admin class planning hub
   ============================================================ */
@media (max-width: 760px) {
    .admin-classroom-planning-container { padding-left: 12px; padding-right: 12px; }

    /* Hero */
    .admin-classroom-planning-hero { margin-bottom: 18px; border-radius: 22px; }
    .admin-classroom-planning-hero-body { padding: 18px; gap: 16px; }
    .admin-classroom-planning-hero-copy h1 { font-size: 1.7rem; max-width: none; line-height: 1.1; }
    .admin-classroom-planning-hero-copy p { font-size: 0.95rem; line-height: 1.55; }
    .admin-classroom-planning-hero-actions { gap: 8px; }
    .admin-classroom-planning-hero-actions .button {
        width: 100%;
        justify-content: center;
        text-align: center;
    }
    .admin-classroom-planning-active-volunteer {
        margin-left: 0;
        width: 100%;
        flex-wrap: wrap;
    }

    /* 4 cramped stat tiles → 2 per row */
    .admin-classroom-planning-hero-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
    .admin-classroom-planning-stat { padding: 12px 14px; border-radius: 18px; }
    .admin-classroom-planning-stat span { font-size: 0.82rem; margin-bottom: 4px; }
    .admin-classroom-planning-stat strong { font-size: 1.15rem; }

    /* Filter / vacation card spacing */
    .admin-classroom-planning-filter-card,
    .admin-classroom-planning-vacations-card { margin-bottom: 16px; border-radius: 22px; }
    .admin-classroom-planning-filter-card .card-body { padding: 14px; }
    .admin-classroom-planning-vacations-summary { padding: 12px 14px; gap: 10px; }
    .admin-classroom-planning-vacations-card-body { padding: 14px; }

    /* Classroom row — collapse the two-column panel layout */
    .admin-classroom-planning-card { border-radius: 22px; }
    .admin-classroom-planning-details-body { padding: 12px 14px 18px; }
    .admin-classroom-planning-panels {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .admin-classroom-planning-panel {
        padding: 16px;
        border-radius: 20px;
    }
    .admin-classroom-planning-panel-heading {
        gap: 10px;
        margin-bottom: 12px;
        padding-bottom: 12px;
    }
    .admin-classroom-planning-panel-icon { width: 38px; height: 38px; border-radius: 12px; }
    .admin-classroom-planning-panel-heading h3 { font-size: 0.98rem; }
    .admin-classroom-planning-panel-heading p { font-size: 0.82rem; }

    /* Volunteer/teacher pickers — cap height so they don't dominate the form */
    .admin-classroom-planning-teacher-picker { max-height: 220px; }
    .admin-classroom-planning-volunteer-picker { max-height: 240px; }
    .admin-classroom-planning-teacher-card,
    .admin-classroom-planning-volunteer-card { padding: 10px 12px; gap: 10px; }
    .admin-classroom-planning-teacher-avatar,
    .admin-classroom-planning-volunteer-avatar { width: 40px; height: 40px; font-size: 1rem; }

    /* Schedule slot cards */
    .acp-slot-card { padding: 14px; border-radius: 16px; }
    .acp-cadence-card { padding: 14px; border-radius: 16px; }

    /* Adjust panel + session rows */
    .admin-classroom-planning-adjust-summary { padding: 12px 14px; gap: 10px; }
    .admin-classroom-planning-adjust-body { padding: 14px; }
    .admin-classroom-planning-upcoming-item { padding: 12px; border-radius: 16px; }
    .admin-classroom-planning-upcoming-meta { gap: 8px; }
    .admin-classroom-planning-upcoming-seq { min-width: 32px; height: 32px; font-size: 0.78rem; }
    .admin-classroom-planning-upcoming-text strong { font-size: 0.92rem; }
    .admin-classroom-planning-upcoming-sub { font-size: 0.8rem; }

    /* Override rows: stack info above the remove button so the row never
       has to fight for horizontal space. */
    .admin-classroom-planning-override-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px;
    }
    .admin-classroom-planning-override-row .admin-classroom-planning-remove-button {
        align-self: flex-start;
    }

    /* Vacation pills — keep them readable in narrow viewports */
    .admin-classroom-planning-vacation-pills { gap: 6px; }
    .admin-classroom-planning-vacation-pill { padding: 6px 10px; font-size: 0.78rem; }

    /* Save button stretches edge-to-edge for an obvious tap target */
    .admin-classroom-planning-actions { justify-content: stretch; }
    .admin-classroom-planning-actions .button {
        width: 100%;
        min-height: 48px;
        justify-content: center;
        text-align: center;
    }
}

@media (max-width: 380px) {
    .admin-classroom-planning-hero-stats { grid-template-columns: 1fr 1fr; }
    .admin-classroom-planning-hero-copy h1 { font-size: 1.5rem; }
    .acp-classname { max-width: 160px; }
}

/* ============================================================
   Generic tap-target guarantees
   ============================================================ */
@media (max-width: 760px) {
    .button,
    .button-secondary,
    .button-tertiary,
    .button-danger {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Wider scrollable areas — ensure no horizontal overflow */
    html, body { overflow-x: hidden; }
}
