/* Prayer Warrior shared styles — used by both the PWA and the MAUI Blazor Hybrid host.
   Palette mirrors the original MAUI Resources/Styles/Colors.xaml. */

:root {
    --primary: #512BD4;
    --primary-text: #ffffff;
    --secondary: #DFD8F7;
    --secondary-text: #2B0B98;
    --surface: #FAF9FF;
    --card: #ffffff;
    --card-border: #E6E1F7;
    --text: #1f1f1f;
    --muted: #6E6E6E;
    --meta: #919191;
    --danger: #D62828;

    --priority-low: #8E9AAF;
    --priority-normal: #512BD4;
    --priority-high: #E8A33D;
    --priority-urgent: #E8623D;
    --priority-emergency: #D62828;

    --radius: 14px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Open Sans", sans-serif;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary: #ac99ea;
        --primary-text: #242424;
        --secondary: #2B0B98;
        --secondary-text: #ffffff;
        --surface: #1B1730;
        --card: #241f3d;
        --card-border: #3A3360;
        --text: #f2f0fa;
        --muted: #ACACAC;
        --meta: #919191;
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--surface);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--primary); }

h1 { font-size: 1.6rem; margin: 0.25rem 0 0.5rem; line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 0; }
h1:focus { outline: none; }

hr { border: 0; border-top: 1px solid var(--card-border); margin: 1rem 0; }

/* ---------- Shell ---------- */

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.top-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: calc(env(safe-area-inset-top, 0px) + 0.75rem) 1.25rem 0.75rem;
    background: var(--primary);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.5rem;
}

.top-bar .brand {
    color: var(--primary-text);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.top-bar-link {
    padding: 0.25rem 0;
    border: 0;
    background: none;
    color: var(--primary-text);
    font: inherit;
    font-size: 0.9rem;
    opacity: 0.85;
    cursor: pointer;
}

.top-bar-link:hover { opacity: 1; text-decoration: underline; }
.top-bar-links { display: flex; align-items: center; justify-content: flex-end; gap: 0.75rem; }
a.top-bar-link { text-decoration: none; }

/* Footer: always at the bottom edge of the window, over the scrolling page. */
.bottom-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    padding: 0.6rem 1.25rem calc(env(safe-area-inset-bottom, 0px) + 0.6rem);
    background: var(--primary);
    color: var(--primary-text);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    text-align: center;
    font-size: 0.9rem;
}

.bottom-bar span:first-child { text-align: left; }
.bottom-bar span:nth-child(3) { text-align: right; }

/* Version and publish date: their own line, right-justified under Answered. */
.bottom-bar .build-info { grid-column: 1 / -1; text-align: right; font-size: 0.7rem; opacity: 0.8; }

.page {
    width: 100%;
    max-width: 40rem;
    margin: 0 auto;
    /* Room at the end so the last item scrolls clear of the fixed footer. */
    padding: 1.25rem 1.25rem calc(env(safe-area-inset-bottom, 0px) + 5rem);
}

.page-header { margin-bottom: 1rem; }
.page-header h1 { font-size: 2rem; margin: 0; }

.back-link {
    display: inline-block;
    margin-bottom: 0.75rem;
    text-decoration: none;
    font-weight: 600;
}

/* ---------- Text helpers ---------- */

.muted { color: var(--muted); }
.meta { color: var(--meta); font-size: 0.8rem; margin: 0.25rem 0; }
.hint { color: var(--muted); font-size: 0.85rem; margin: -0.25rem 0 0; }
.body-text { font-size: 1.05rem; white-space: pre-wrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0.25rem 0;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    min-height: 3rem;
    padding: 0.6rem 1.25rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.btn:disabled { opacity: 0.6; cursor: default; }
.btn:focus-visible { outline: 3px solid var(--secondary); outline-offset: 2px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-secondary { background: var(--secondary); color: var(--secondary-text); }
.btn-ghost { background: transparent; color: var(--primary); border-color: var(--card-border); }

.stack { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.25rem; }

.button-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin: 0.75rem 0;
}

/* ---------- Cards & lists ---------- */

.card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 1rem;
}

.section { margin-top: 1.25rem; }
.section h2 { margin-bottom: 0.5rem; }

.request-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }

.request-card {
    display: flex;
    gap: 0.75rem;
    color: inherit;
    text-decoration: none;
}

.request-card:hover { border-color: var(--primary); }

.priority-bar { flex: 0 0 6px; border-radius: 3px; background: var(--c); }
.request-body { flex: 1; min-width: 0; }

.title-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }

.pill {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    background: var(--c);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.priority-low { --c: var(--priority-low); }
.priority-normal { --c: var(--priority-normal); }
.priority-high { --c: var(--priority-high); }
.priority-urgent { --c: var(--priority-urgent); }
.priority-emergency { --c: var(--priority-emergency); }

.pill-category { --c: var(--secondary); color: var(--secondary-text); }

.empty-state { text-align: center; padding: 2.5rem 1rem; }
.empty-state p { margin: 0.25rem 0; }
.empty-icon { font-size: 2.75rem; }

.flash {
    margin: 0.75rem 0;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    background: var(--secondary);
    color: var(--secondary-text);
    font-weight: 600;
}

.flash-error { background: var(--danger); color: #fff; }
a.flash { display: block; text-decoration: none; }
.switch-mode { margin-top: 0.75rem; }

/* ---------- Forms ---------- */

.form { display: flex; flex-direction: column; gap: 0.5rem; }
.form label { font-weight: 600; margin-top: 0.5rem; }

input:not([type=checkbox]), textarea, select {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    background: var(--card);
    color: var(--text);
    font: inherit;
}

input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 0; }

.form .checkbox { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; margin: 0.5rem 0; }
.checkbox input { width: 1.2rem; height: 1.2rem; accent-color: var(--primary); }
.form .btn { margin-top: 0.75rem; }
.form h2 { margin-bottom: 0; }
input.input-initial { width: 4rem; text-transform: uppercase; }

.validation-message { color: var(--danger); font-size: 0.85rem; }
.invalid { outline: 2px solid var(--danger); }

/* ---------- Prayer session ---------- */

.session { display: flex; flex-direction: column; gap: 0.75rem; }
.session-card { padding: 1.25rem; }
.session-card h1 { font-size: 1.6rem; }
.session-prompt { font-style: italic; color: var(--muted); }

/* Prayer session, Full list mode: every request on one page. */
.list-heading { font-size: 1.1rem; color: var(--muted); margin: 0.75rem 0 0; }
.session-card h2 { font-size: 1.3rem; margin: 0.5rem 0 0.25rem; }
.list-card-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin: 0.75rem 0 0;
    padding-top: 0.75rem;
    border-top: 1px solid var(--card-border);
}
.list-card-actions.form { display: block; }
.mark-prayed { font-weight: 700; margin: 0; }
.answered-note { font-weight: 600; }
.btn-compact { min-height: 2.5rem; padding: 0.35rem 0.9rem; }

/* Home: the big Start Prayer Session button (icon on top), with a smaller button below it. */
.btn-hero {
    flex-direction: column;
    gap: 0.6rem;
    min-height: 10rem;
    padding: 1.25rem;
    font-size: 1.35rem;
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.btn-hero img { width: 96px; height: 96px; border-radius: 22%; }
.btn-small { min-height: 2.5rem; padding: 0.35rem 1rem; font-size: 0.95rem; }
.install-on-signin { margin-top: 1.25rem; }
.install-steps ol { padding-left: 1.25rem; margin: 0.5rem 0 0.75rem; }
.install-steps li { margin-bottom: 0.4rem; }

/* Private notes: edited on the request's page, shown read-only while praying. */
.note-row { display: flex; gap: 0.5rem; align-items: center; }
.note-row input { flex: 1; min-width: 0; }
.private-note-line {
    margin: 0.25rem 0;
    padding: 0.35rem 0.6rem;
    border-left: 3px solid var(--primary);
    background: var(--surface);
    font-weight: 600;
    overflow-wrap: anywhere;
}

.progress-label { text-align: center; font-weight: 600; color: var(--muted); }
.progress { height: 6px; border-radius: 3px; background: var(--card-border); overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); transition: width 0.25s ease; }

/* ---------- Blazor framework UI ---------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto 0 0 0;
    z-index: 1000;
    padding: 0.75rem 1.25rem calc(env(safe-area-inset-bottom, 0px) + 0.75rem);
    background: #fff4d6;
    color: #1f1f1f;
    box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.2);
}

#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 1rem; top: 0.6rem; }

.loading-screen {
    display: grid;
    place-items: center;
    min-height: 100vh;
    color: var(--muted);
}

/* Sharing */
.share-people { display: flex; flex-direction: column; max-height: 14rem; overflow-y: auto; padding-left: 0.25rem; }
.form .share-consent { font-weight: 600; }
.share-list { list-style: none; margin: 0 0 0.5rem; padding: 0; }
.share-list li { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; padding: 0.35rem 0; border-bottom: 1px solid var(--card-border); }
.pill-shared { --c: var(--secondary); color: var(--secondary-text); }

/* My Prayer List filters */
.filters { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.5rem; }
.chip-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
    padding: 0.35rem 0.8rem;
    min-height: 2.25rem;
    border: 1px solid var(--card-border);
    border-radius: 999px;
    background: var(--card);
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
}
.chip:focus-visible { outline: 3px solid var(--secondary); outline-offset: 2px; }
.chip-on { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 600; }
.more-filters summary { cursor: pointer; color: var(--primary); font-weight: 600; padding: 0.25rem 0; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.5rem; align-items: center; margin-top: 0.5rem; }
.filter-grid .checkbox { display: flex; align-items: center; gap: 0.5rem; }
.filter-summary { margin: 0; font-size: 0.9rem; }
.link-button { background: none; border: none; padding: 0 0 0 0.5rem; color: var(--primary); font: inherit; text-decoration: underline; cursor: pointer; }

/* Delete prayers: a long checkbox list scrolls inside its card. */
.select-list { max-height: 24rem; overflow-y: auto; gap: 0; }
.select-list .checkbox { align-items: flex-start; margin: 0.35rem 0; }

/* Delete prayers: the three ways to choose, as large buttons; the picked one is filled in. */
.choice-list { display: flex; flex-direction: column; gap: 0.5rem; }
.choice {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--card-border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.choice span { color: var(--muted); font-size: 0.85rem; }
.choice.picked { border-color: var(--primary); background: var(--secondary); color: var(--secondary-text); }
.choice.picked span { color: var(--secondary-text); }
.choice:focus-visible { outline: 3px solid var(--secondary); outline-offset: 2px; }
.import-titles { margin: 0.25rem 0 0.5rem 1.75rem; padding-left: 1rem; font-size: 0.85rem; color: var(--muted); }
.link-button { background: none; border: none; padding: 0; color: var(--primary); font: inherit; font-size: 0.85rem; cursor: pointer; text-decoration: underline; }
.btn-danger { background: var(--danger); color: #fff; }
.filter-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.filter-row > * { flex: 1 1 10rem; }
