/*
 * Kids Avon – additions to the original design (style.css is left unchanged).
 * Flash messages, form errors, file preview, challenge states, unread dot, pagination.
 */

/* ---------- Flash messages ---------- */
.site-flash {
    max-width: 1200px;
    margin: 16px auto 0;
    padding: 0 var(--spacing-margin-mobile);
}

.site-flash .flash {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-radius: 16px;
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.4;
    font-weight: 700;
    border: 2px solid transparent;
}

.site-flash .flash .material-symbols-outlined { font-size: 24px; flex-shrink: 0; }
.site-flash .flash-success { background: #e8f8e6; color: var(--color-secondary); border-color: #b8e8b2; }
.site-flash .flash-error { background: #fff0ee; color: var(--color-primary); border-color: var(--color-primary-fixed); }

/* ---------- Form errors ---------- */
.field-error {
    display: block;
    margin-top: 6px;
    color: var(--color-primary);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.3;
    font-weight: 700;
}

.input-group.has-error .input-wrapper,
.input-group.has-error .file-upload-wrapper {
    border-color: var(--color-primary) !important;
    box-shadow: 0 0 0 3px rgba(188, 1, 0, 0.12);
}

.form-note {
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.4;
    color: var(--color-on-surface-variant);
    margin: 6px 0 0;
}

/* ---------- File upload preview ---------- */
.file-upload-wrapper .file-chosen {
    display: none;
    align-items: center;
    gap: 14px;
    padding: 12px;
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.3;
    font-weight: 700;
    color: var(--color-on-surface);
    text-align: left;
}

.file-upload-wrapper.has-file .file-chosen { display: flex; }
.file-upload-wrapper.has-file .upload-placeholder { display: none; }

.file-upload-wrapper .file-chosen img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 12px;
    flex-shrink: 0;
}

.file-upload-wrapper .file-chosen small {
    display: block;
    font-weight: 600;
    color: var(--color-on-surface-variant);
}

/* ---------- Challenge card states ---------- */
.challenges-page .challenge-card form { margin: 0; }

.challenges-page .challenge-card a.btn { text-decoration: none; box-sizing: border-box; }

.challenges-page .challenge-card .btn.btn-done {
    background-color: #e3f6e0 !important;
    color: var(--color-secondary) !important;
    border: 2px solid #9fdc98 !important;
    box-shadow: none !important;
    opacity: 1 !important;
    cursor: default;
    gap: 6px;
}

.challenges-page .challenge-card.completed .card-top::after {
    content: 'Completed';
    position: absolute;
    left: 16px;
    bottom: 12px;
    padding: 2px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--color-secondary);
    font-family: var(--font-body);
    font-size: 13px;
    line-height: 22px;
    font-weight: 800;
}

.challenges-page .challenge-card .card-top { position: relative; }

.challenge-dates {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: -4px 0 12px;
    font-family: var(--font-body);
    font-size: 13px;
    line-height: 1.3;
    font-weight: 700;
    color: var(--color-on-surface-variant);
}

.challenge-dates .material-symbols-outlined { font-size: 16px; }

.challenges-empty {
    text-align: center;
    font-family: var(--font-body);
    font-size: 18px;
    color: var(--color-on-surface-variant);
    grid-column: 1 / -1;
    padding: 40px 0;
}

/* ---------- Header: unread alerts dot ---------- */
.icon-btn { position: relative; }

.icon-btn .unread-count {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--color-primary-container);
    color: #fff;
    font-family: var(--font-body);
    font-size: 11px;
    line-height: 18px;
    font-weight: 800;
    text-align: center;
    box-sizing: border-box;
    border: 2px solid #fff;
}

/* ---------- Ride history pagination ---------- */
.history-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: var(--spacing-md);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.3;
    font-weight: 700;
    color: var(--color-on-surface-variant);
}

.history-pagination a,
.history-pagination span.disabled {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    border-radius: 999px;
    background: var(--color-surface-container-low);
    color: var(--color-tertiary);
    text-decoration: none;
}

.history-pagination span.disabled { opacity: 0.45; }
.history-pagination a:hover { background: var(--color-surface-container-high); }

.history-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: var(--spacing-md);
}

.history-filters a {
    padding: 6px 16px;
    border-radius: 999px;
    border: 2px solid var(--color-surface-container-high);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.4;
    font-weight: 700;
    color: var(--color-on-surface-variant);
    text-decoration: none;
}

.history-filters a.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.ride-reason {
    display: block;
    font-family: var(--font-body);
    font-size: 13px;
    line-height: 1.3;
    color: var(--color-primary);
    font-weight: 700;
}

/* ---------- Rider settings ---------- */
.settings-avatar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 8px;
}

.settings-avatar img,
.settings-avatar .initials {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--color-primary-fixed);
    color: var(--color-primary);
    display: grid;
    place-items: center;
    font-family: var(--font-headline);
    font-size: 26px;
    font-weight: 800;
    flex-shrink: 0;
}

.settings-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 8px;
}

.settings-stats span {
    padding: 4px 14px;
    border-radius: 999px;
    background: var(--color-surface-container-low);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.4;
    font-weight: 700;
    color: var(--color-on-surface-variant);
}

/* ---------- Mobile fix for the original home grid ----------
 * The 1fr column grew to the width of its widest child, so on phones the
 * leaderboard scores, progress % and banners were cut off on the right. */
.dashboard-content .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
.dashboard-content .dashboard-grid > * { min-width: 0; }

@media (min-width: 768px) {
    .dashboard-content .dashboard-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); }
}

/* Same fix for the Ride Verification box. */
.verification-section .verification-content { grid-template-columns: minmax(0, 1fr); }
.verification-section .verification-content > * { min-width: 0; }
.verification-section { overflow: hidden; }

@media (max-width: 767px) {
    .verification-section .example-area { padding: 22px; }
}

@media (min-width: 768px) {
    .verification-section .verification-content { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 767px) {
    .verification-section .info-area .section-title-left { font-size: 38px; min-width: 0; }
    .verification-section .info-area .header { flex-wrap: wrap; }
}

/* =====================================================================
 * Login, My Progress button, waiting-for-review progress, My Challenges
 * ===================================================================== */

/* ---------- Header buttons ---------- */
.header-progress-btn,
.header-login-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 999px;
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.2;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color .2s, transform .1s;
}

.header-progress-btn {
    background: var(--color-surface-container-low);
    color: var(--color-primary);
    border: 2px solid var(--color-primary-fixed);
}

.header-progress-btn:hover,
.header-progress-btn.active { background: var(--color-primary-fixed); }

.header-login-btn {
    background: var(--color-primary);
    color: #fff;
    box-shadow: 0 3px 0 #7a0000;
}

.header-login-btn:hover { background: var(--color-primary-container); }
.header-progress-btn:active, .header-login-btn:active { transform: translateY(2px); }
.header-progress-btn .material-symbols-outlined,
.header-login-btn .material-symbols-outlined { font-size: 20px; }

@media (max-width: 640px) {
    .header-progress-btn { padding: 8px; }
    .header-progress-btn .label { display: none; }
    .header-login-btn { padding: 8px 12px; font-size: 14px; }
}

/* ---------- Login / join ---------- */
.login-flash { margin: 0 0 16px; padding: 0; max-width: none; }
.login-flash .flash { font-size: 15px; }

.otp-status {
    min-height: 0;
    margin: 4px 0 10px;
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.35;
    font-weight: 700;
    color: var(--color-secondary);
}

.otp-status:empty { display: none; }
.otp-status.is-error { color: var(--color-primary); }
.is-sending { opacity: .6; pointer-events: none; }

.otp-test-note {
    margin: 4px 0 14px;
    padding: 8px 12px;
    border-radius: 12px;
    background: #fff7dc;
    color: #7a5200;
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.35;
    font-weight: 700;
    text-align: center;
}

.field-error a { color: inherit; text-decoration: underline; }

/* ---------- Upload form: logged-in rider ---------- */
.uploading-as {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 18px;
    background: var(--color-surface-container-low);
    border: 2px solid var(--color-surface-container-high);
    font-family: var(--font-body);
}

.uploading-as img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.uploading-as div { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.uploading-as small { font-size: 13px; font-weight: 700; color: var(--color-on-surface-variant); text-transform: uppercase; letter-spacing: .04em; }
.uploading-as strong { font-family: var(--font-headline); font-size: 20px; color: var(--color-on-surface); }
.uploading-as span { font-size: 15px; font-weight: 600; color: var(--color-on-surface-variant); }
.uploading-as a { margin-left: auto; font-size: 14px; font-weight: 700; color: var(--color-tertiary); white-space: nowrap; }

/* ---------- Waiting-for-review part of progress bars ---------- */
.progress-split { display: flex; overflow: hidden; }
.progress-split .progress-bar-fill { flex-shrink: 0; border-radius: 0; }
.progress-split .progress-bar-fill:first-child { border-radius: 999px 0 0 999px; }

.progress-pending {
    flex-shrink: 0;
    height: 100%;
    opacity: .45;
    background-image: repeating-linear-gradient(135deg, rgba(255, 255, 255, .55) 0 6px, transparent 6px 12px);
}

.pending-primary { background-color: var(--color-primary); }
.pending-secondary { background-color: var(--color-secondary); }
.pending-tertiary { background-color: var(--color-tertiary); }

.pending-note {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 8px 0 0;
    font-family: var(--font-body);
    font-size: 13px;
    line-height: 1.3;
    font-weight: 700;
    color: #8a5a00;
}

.pending-note .material-symbols-outlined { font-size: 16px; }

.stat-pending, .stat-box-note {
    margin: 4px 0 0;
    font-family: var(--font-body);
    font-size: 13px;
    line-height: 1.3;
    font-weight: 700;
    color: #8a5a00;
}

/* ---------- Progress page: My Challenges ---------- */
.my-challenges { margin-bottom: var(--spacing-md); }

.my-challenge {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 16px 0;
    border-bottom: 1px solid var(--color-surface-container-high);
}

.my-challenge:last-child { border-bottom: 0; }

.my-challenge-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.bg-primary-soft { background: var(--color-primary-fixed); color: var(--color-primary); }
.bg-secondary-soft { background: #dcf8d8; color: var(--color-secondary); }
.bg-tertiary-soft { background: var(--color-tertiary-fixed); color: var(--color-tertiary); }

.my-challenge-body { flex: 1; min-width: 0; }

.my-challenge-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.my-challenge-top h4 { margin: 0; }

.my-challenge-count {
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 800;
    color: var(--color-on-surface-variant);
    white-space: nowrap;
}

.my-challenge-bar {
    height: 12px;
    border-radius: 999px;
    background: var(--color-surface-container-high);
}

.my-challenge-bar .progress-bar-fill { height: 100%; }
.my-challenge-bar .fill-primary { background: var(--color-primary); }
.my-challenge-bar .fill-secondary { background: var(--color-secondary); }
.my-challenge-bar .fill-tertiary { background: var(--color-tertiary); }

.my-challenge-empty { margin: 8px 0 0; }
.my-challenge-empty a, .rides-list a { color: var(--color-tertiary); font-weight: 700; }

/* ---------- Home: Your Progress card ---------- */
.see-progress-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: 16px;
    background: var(--color-primary);
    color: #fff;
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.2;
    font-weight: 800;
    text-decoration: none;
    box-shadow: 0 4px 0 #7a0000;
    transition: transform .1s, background-color .2s;
}

.see-progress-btn:hover { background: var(--color-primary-container); }
.see-progress-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #7a0000; }

.progress-guest {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 12px 4px;
}

.progress-guest > .material-symbols-outlined {
    font-size: 44px;
    width: 76px;
    height: 76px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--color-primary-fixed);
    color: var(--color-primary);
}

.progress-guest p { margin: 4px 0; }
.progress-guest-join { font-family: var(--font-body); font-size: 15px; font-weight: 700; color: var(--color-tertiary); margin-top: 4px; }

.milestone-empty {
    margin: 0;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 700;
    color: var(--color-on-surface-variant);
}

/* Original design had red text on a red button ("Log a Ride"): make it readable. */
.progress-page .add-ride-btn {
    color: #fff !important;
    background-color: var(--color-primary) !important;
    font-weight: 800;
    box-shadow: 0 3px 0 #7a0000;
}

.progress-page .add-ride-btn:hover { background-color: var(--color-primary-container) !important; }
.progress-page .add-ride-btn .material-symbols-outlined { color: #fff; }

/* Progress page on phones: keep everything inside the screen width. */
.progress-page .progress-content { width: 100%; max-width: min(1200px, 100%); min-width: 0; box-sizing: border-box; }
.progress-page .progress-content > * { min-width: 0; max-width: 100%; box-sizing: border-box; }
.progress-page .section-top { flex-wrap: wrap; gap: 12px; }
.progress-page .section-top h3, .progress-page .progress-header h2 { overflow-wrap: anywhere; }

@media (max-width: 600px) {
    .progress-page .progress-header h2 { font-size: 40px; line-height: 1.1; }
    .progress-page .section-top h3 { font-size: 34px; line-height: 1.1; }
    .my-challenge { gap: 12px; }
    .my-challenge-icon { width: 40px; height: 40px; }
    .my-challenge-top { flex-wrap: wrap; gap: 4px 12px; }
}

/* ---------- Bot trap (hidden from people) + Cloudflare robot check ---------- */
.kv-trap { position: absolute !important; left: -10000px !important; top: auto; width: 1px; height: 1px; overflow: hidden; }
.turnstile-box { margin: 4px 0 16px; min-height: 0; }
.turnstile-box .cf-turnstile { width: 100%; }
.field-hint {
    display: block;
    margin-top: 6px;
    font-family: var(--font-body);
    font-size: 13px;
    line-height: 1.3;
    color: var(--color-on-surface-variant);
}
.is-waiting { opacity: .55; pointer-events: none; cursor: default; }

/* ---------- Upload page: rides allowed today ---------- */
.daily-limit {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #eef8ec;
    color: var(--color-secondary);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.35;
}
.daily-limit p { margin: 0; }
.daily-limit .material-symbols-outlined { flex-shrink: 0; }
.daily-limit.is-full { background: #fff0ee; color: var(--color-primary); font-weight: 700; }
.submit-btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; transform: none; }

/* ---------- Home: Next Badge ---------- */
.next-badge-bar { display: flex; }
.next-badge-bar .bar-fill { flex-shrink: 0; }
.next-badge-bar .progress-pending { border-radius: 0 999px 999px 0; }
.next-badge-goal {
    margin: 8px 0 0;
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.35;
    color: var(--color-on-surface-variant);
}
.next-badge-goal strong { color: var(--color-secondary); white-space: nowrap; }
.next-badge-done .title { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--color-secondary); }

/* ---------- Login / join card on phones: use the full width ---------- */
@media (max-width: 767px) {
    .login-page-design .login-card { width: 100%; }
    .login-page-design .form-side { padding: 24px 18px; }
    .login-page-design .form-header h1 { font-size: 30px; line-height: 1.15; overflow-wrap: anywhere; }
}
