/* parent/components.css — UI components shared by more than one parent page.
   Load after parent.css. Rules here were previously duplicated across
   dashboard.html (inline), account.css and rewards.css; this file is the
   single definition. Page-specific variants (.modal-card--profile,
   .modal-card--shop-editor, …) stay with their page. */

/* ── Section heading ──
   Used by: dashboard, account */
.section-heading {
    width: 100%;
    text-align: left;
    font-size: 16px;
    font-weight: var(--fw-title);
    color: var(--primary-text);
    margin: 0 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--border);
}

/* ── Sub-page header ──
   Used by: account, rewards, guide. Title sits where Overview's
   greeting does. Right-slot controls: Overview = back to learning,
   Shop = Edit, Account = Sign out, Guide = language toggle. */
.sub-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 8px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
    gap: 10px;
}

body.has-shell .sub-page-header,
body.has-shell .dashboard-header {
    position: sticky;
    top: 0;
    z-index: 30;
    padding-top: 8px;
    background: var(--page-bg);
}

.sub-page-heading {
    min-width: 0;
    text-align: left;
}

.sub-page-header-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    margin-left: auto;
}

.sub-page-header-actions .btn-icon,
.dashboard-header-actions .btn-icon,
.sub-page-heading .btn-icon {
    box-sizing: border-box;
    min-height: 40px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: var(--fw-title);
    line-height: 1.2;
}

.sub-page-masthead {
    width: 100%;
    margin: 0 0 22px;
    text-align: left;
}

.sub-page-masthead-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.sub-page-title {
    margin: 0;
    font-size: 22px;
    font-weight: var(--fw-title);
    color: var(--text-main);
    text-align: left;
    letter-spacing: -0.03em;
    line-height: 1.25;
}

.sub-page-sub {
    margin: 0 0 22px;
    font-size: 14px;
    font-weight: var(--fw-body);
    color: var(--text-muted);
    text-align: left;
    line-height: 1.45;
}

@media (max-width: 640px) {
    .sub-page-title {
        font-size: 19px;
    }

    .sub-page-header-actions .btn-icon,
    .dashboard-header-actions .btn-icon,
    .sub-page-heading .btn-icon {
        min-height: 44px;
        padding: 10px 12px;
    }
}

.panel {
    width: 100%;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 20px 22px;
    text-align: left;
    box-shadow: var(--elev-card);
}

.panel-kicker {
    margin: 0 0 14px;
    font-size: 11px;
    font-weight: var(--fw-label);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.account-layout {
    display: grid;
    gap: 16px;
    width: 100%;
    margin-bottom: 16px;
}

@media (min-width: 900px) {
    .account-layout {
        grid-template-columns: 1fr 1fr;
        align-items: stretch;
    }
}

/* ── Toggle switch ──
   Used by: account preferences, shop exchange tiers. */
.toggle-switch {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.toggle-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch-track {
    position: relative;
    display: block;
    width: 46px;
    height: 26px;
    border-radius: 999px;
    background: var(--n-300);
    transition: background 0.15s ease;
}

.toggle-switch-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.15s ease;
}

.toggle-switch input:checked + .toggle-switch-track {
    background: var(--primary);
}

.toggle-switch input:checked + .toggle-switch-track::after {
    transform: translateX(20px);
}

.toggle-switch input:focus-visible + .toggle-switch-track {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.toggle-switch--sm .toggle-switch-track {
    width: 38px;
    height: 22px;
}

.toggle-switch--sm .toggle-switch-track::after {
    width: 16px;
    height: 16px;
}

.toggle-switch--sm input:checked + .toggle-switch-track::after {
    transform: translateX(16px);
}

/* ── Hub tiles ──
   Used by: dashboard. Kept here because the P3 sidebar reuses them. */
.hub-grid {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 8px;
}

.hub-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 14px 14px 12px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-tile);
    text-decoration: none;
    color: inherit;
    min-height: 108px;
    text-align: left;
    transition: border-color 0.15s, background 0.15s;
}

.hub-tile:hover,
.hub-tile:focus-visible {
    border-color: var(--primary-border);
    background: var(--primary-light);
    outline: none;
}

.hub-tile-icon {
    color: var(--primary-text);
    display: flex;
}

.hub-tile-title {
    font-size: 14px;
    font-weight: var(--fw-title);
    color: #0f172a;
    line-height: 1.25;
}

.hub-tile-sub {
    font-size: 12px;
    font-weight: var(--fw-label);
    color: #64748b;
    line-height: 1.3;
}

/* ── Modal ──
   Used by: dashboard, account, rewards.
   Open state is `.open` everywhere; `.visible` is not supported. */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
}

.modal-backdrop.open { display: flex; }

.modal-backdrop--front { z-index: 130; }

.modal-body {
    text-align: left;
    color: #64748b;
    font-weight: var(--fw-body);
    font-size: 14px;
    line-height: 1.55;
    margin: -8px 0 16px;
    white-space: pre-line;
}

.modal-card {
    background: white;
    border-radius: var(--radius-card);
    padding: 28px 24px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    animation: fadeUp 0.25s ease-out;
}

.modal-title {
    font-size: 22px;
    font-weight: var(--fw-title);
    color: #0f172a;
    margin: 0 0 20px;
}

/* Premium lapsed notice — shown on the dashboard when paid access has run out. */
.premium-lapsed-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 16px;
    padding: 14px 16px;
    background: var(--info-bg);
    border: var(--bw-hair) solid var(--info-border);
    border-radius: var(--radius-card);
}

.premium-lapsed-banner-text {
    flex: 1 1 260px;
    margin: 0;
    color: var(--n-700);
    font-size: 14px;
    line-height: 1.55;
}

.premium-lapsed-banner-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

@media (max-width: 480px) {
    .premium-lapsed-banner-actions { width: 100%; }
    .premium-lapsed-banner-actions > .btn-primary,
    .premium-lapsed-banner-actions > .btn-secondary { flex: 1 1 auto; }
}

/* Failed payment — urgent and fixable, so it has no dismiss control. */
.billing-past-due-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 16px;
    padding: 14px 16px;
    background: var(--danger-bg);
    border: var(--bw-hair) solid var(--danger-border);
    border-radius: var(--radius-card);
}

.billing-past-due-banner-text {
    flex: 1 1 260px;
    margin: 0;
    color: var(--danger-dark);
    font-size: 14px;
    line-height: 1.55;
}

@media (max-width: 480px) {
    .billing-past-due-banner-actions { width: 100%; }
    .billing-past-due-banner-actions > .btn-primary { width: 100%; }
}
