/* ==============================================================================
 * Mentifyll: családi / motivációs widgetek (Ma fül, jutalom-bolt, szülői panel)
 * Minden szín a tokens.css változóiból; a tintázott felületeken a másodlagos szöveg
 * a --color-card-text (nem a halvány --color-text-muted), így mindkét témában AA kontraszt.
 * ============================================================================== */

/* ---------- Közös alapok ---------- */
.fm-card.card {
    padding: 14px 16px;
    margin: 0;
    min-width: 0;
}

.fm-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.3;
    color: var(--color-heading);
}

.fm-subh {
    margin: 16px 0 8px;
    font-size: 0.92rem;
    font-weight: 800;
    color: var(--color-heading);
}

.fm-sub {
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--fm-sub, var(--color-text-muted));
}

.fm-tint {
    background: var(--color-surface-variant);
    --fm-sub: var(--color-card-text);
}

.fm-hint {
    margin: 8px 0;
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--color-text-muted);
}

.fm-pad {
    margin: 8px 0 0;
}

.fm-status {
    margin: 6px 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-text-main);
    overflow-wrap: anywhere;
}

.fm-status:empty {
    display: none;
}

.fm-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.fm-card-head .fm-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.fm-card .btn.btn-sm,
.fm-parent .btn.btn-sm {
    min-height: 44px;
}

.fm-card .btn:disabled,
.fm-parent .btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.fm-card .btn.is-busy,
.fm-parent .btn.is-busy {
    opacity: 0.7;
    cursor: progress;
}

.fm-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 6px;
    background: none;
    border: 0;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-primary-dark);
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

/* ---------- Jelvények ---------- */
.fm-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.3;
    white-space: nowrap;
}

.fm-badge-ok { background: var(--success-bg); color: var(--success-fg); border-color: var(--success-border); }
.fm-badge-warn { background: var(--warning-bg); color: var(--warning-fg); border-color: var(--warning-border); }
.fm-badge-bad { background: var(--danger-bg); color: var(--danger-fg); border-color: var(--danger-border); }
.fm-badge-info { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-border); }
.fm-badge-neutral { background: var(--color-neutral-subtle); color: var(--color-card-text); border-color: var(--color-border); }

/* ---------- Üres és hibaállapotok ---------- */
.fm-empty {
    padding: 18px 12px;
    text-align: center;
}

.fm-empty-ico {
    display: block;
    font-size: 2rem;
    line-height: 1.2;
}

.fm-empty-title {
    margin: 6px 0 2px;
    font-weight: 800;
    color: var(--color-heading);
    overflow-wrap: anywhere;
}

.fm-empty-text {
    max-width: 38ch;
    margin: 0 auto;
    font-size: 0.86rem;
    line-height: 1.5;
    color: var(--color-text-muted);
}

.fm-error {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 12px;
    border: 1px solid var(--danger-border);
    border-radius: var(--radius-md);
    background: var(--danger-bg);
}

.fm-error p {
    margin: 0;
    flex: 1 1 200px;
    font-size: 0.88rem;
    color: var(--color-text-main);
    overflow-wrap: anywhere;
}

/* ---------- „Ma” fül: szeletek és rács ---------- */
#today-widgets-root:empty,
#rewards-shop-root:empty {
    display: none;
}

#today-widgets-root:has(> .fm-today.fm-all-empty) {
    display: none;
}

.fm-today,
.fm-group,
.fm-more,
.fm-more-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.fm-more-body {
    display: none;
}

.fm-more.is-open .fm-more-body {
    display: flex;
}

.fm-more.fm-more-empty {
    display: none;
}

.fm-more-toggle {
    width: 100%;
}

.fm-slot {
    min-width: 0;
}

.fm-slot.fm-slot-empty {
    display: none;
}

.fm-today .card {
    margin: 0;
}

.fm-today .fm-slot.fm-autocard {
    padding: 14px 16px;
}

@media (min-width: 768px) {
    .fm-today {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
        gap: 16px;
        align-items: start;
    }

    .fm-today .fm-group,
    .fm-today .fm-more,
    .fm-today .fm-more-body {
        display: contents;
    }

    .fm-today .fm-more-toggle {
        display: none;
    }

    .fm-today #tw-mood {
        grid-column: 1 / -1;
    }

    .fm-mood-row {
        max-width: 460px;
    }
}

/* ---------- Üzenetek (gyerek) ---------- */
.fm-msg-list,
.fm-claim-list,
.fm-myclaims,
.fm-rw-list,
.fm-claims,
.fm-hlist,
.fm-thread {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.fm-msg-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.fm-msg-item.is-unread {
    border-left: 4px solid var(--color-primary);
    cursor: pointer;
}

.fm-msg-text {
    font-size: 0.95rem;
    line-height: 1.45;
    color: var(--color-text-main);
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.fm-msg-from {
    color: var(--color-heading);
}

.fm-msg-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---------- Hangulat (gyerek) ---------- */
.fm-mood-row {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    margin: 10px 0 8px;
}

.fm-mood-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 64px;
    padding: 6px 2px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface-variant);
    color: var(--color-text-main);
    font: inherit;
    cursor: pointer;
    transition: transform 0.12s ease, border-color 0.12s ease;
}

.fm-mood-btn:hover {
    border-color: var(--color-primary);
}

.fm-mood-btn:active {
    transform: scale(0.96);
}

.fm-mood-btn[aria-pressed="true"] {
    border-color: var(--color-primary);
    background: var(--color-primary-container);
    color: var(--color-on-primary-container);
}

.fm-mood-emoji {
    font-size: 1.7rem;
    line-height: 1.1;
}

.fm-mood-lbl {
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
}

.fm-mood-status {
    margin: 6px 0 0;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.fm-trend {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--color-border);
}

.fm-trend-chart {
    flex: 0 0 130px;
    max-width: 45%;
    min-width: 0;
}

.fm-trend-cap {
    margin: 0;
}

/* ---------- Igénylések (Ma fül: szülő) ---------- */
.fm-claim-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-yellow-dark);
    border-radius: var(--radius-md);
}

.fm-claim-info {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
    color: var(--color-text-main);
    overflow-wrap: anywhere;
}

.fm-ico {
    flex: 0 0 auto;
    font-size: 1.5rem;
    line-height: 1.1;
}

.fm-claim-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

@media (min-width: 560px) {
    .fm-claim-row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

/* ---------- Jutalom-bolt ---------- */
.fm-balance {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px 18px;
    flex-wrap: wrap;
    margin: 10px 0 6px;
    padding: 12px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.fm-bal-main {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.fm-bal-num {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    color: var(--color-primary-dark);
}

.fm-bal-unit {
    font-weight: 700;
    color: var(--color-text-main);
}

.fm-bal-stats {
    display: flex;
    gap: 6px 16px;
    flex-wrap: wrap;
    margin: 0;
}

.fm-bal-stats > div {
    display: flex;
    flex-direction: column;
}

.fm-bal-stats dt {
    font-size: 0.72rem;
    color: var(--color-card-text);
}

.fm-bal-stats dd {
    margin: 0;
    font-weight: 800;
    color: var(--color-text-main);
}

.fm-reward-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 10px;
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
}

.fm-reward {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.fm-reward.is-ready {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary);
}

.fm-reward-ico {
    font-size: 2rem;
    line-height: 1.1;
}

.fm-reward-title {
    margin: 2px 0 0;
    font-size: 0.95rem;
    font-weight: 800;
    line-height: 1.3;
    color: var(--color-heading);
    overflow-wrap: anywhere;
}

.fm-reward-desc {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    margin: 0;
    overflow: hidden;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--color-card-text);
    overflow-wrap: anywhere;
}

.fm-reward-cost {
    margin: 2px 0 0;
    font-weight: 800;
    color: var(--color-text-main);
}

.fm-prog {
    height: 6px;
    overflow: hidden;
    border-radius: 3px;
    background: var(--color-border);
}

.fm-prog > i {
    display: block;
    height: 100%;
    border-radius: 3px;
    background: var(--color-primary);
}

.fm-reward-hint {
    min-height: 1.1em;
    margin: 0;
    font-size: 0.75rem;
    line-height: 1.3;
    color: var(--color-card-text);
}

.fm-reward .fm-reward-btn {
    width: 100%;
    margin-top: auto;
}

.fm-myclaim,
.fm-hrow {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.fm-myclaim-main {
    flex: 1;
    min-width: 0;
    color: var(--color-text-main);
    overflow-wrap: anywhere;
}

.fm-myclaim .btn {
    flex: 0 0 auto;
    align-self: center;
}

.fm-note {
    margin: 4px 0 0;
    font-size: 0.85rem;
    color: var(--color-text-main);
    overflow-wrap: anywhere;
}

/* ---------- Szülői / admin panel ---------- */
.fm-parent {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.fm-childbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 0;
    color: var(--color-text-main);
}

.fm-childbar label {
    font-weight: 700;
    color: var(--color-heading);
}

.fm-childbar select {
    flex: 1 1 180px;
    width: auto;
    max-width: 320px;
    min-height: 44px;
}

.fm-sec {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    min-width: 0;
}

.fm-sec[hidden] {
    display: none;
}

.fm-sec > summary {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 14px;
    font-weight: 800;
    color: var(--color-heading);
    list-style: none;
    cursor: pointer;
}

.fm-sec > summary::-webkit-details-marker {
    display: none;
}

.fm-sec > summary::after {
    content: '▾';
    margin-left: auto;
    color: var(--color-text-muted);
    transition: transform 0.15s ease;
}

.fm-sec[open] > summary::after {
    transform: rotate(180deg);
}

.fm-sec-body {
    min-width: 0;
    padding: 2px 14px 14px;
}

.fm-sec-body > :first-child {
    margin-top: 0;
}

.fm-toolbar {
    margin: 10px 0;
}

.fm-balance-sm {
    display: flex;
    align-items: center;
    gap: 4px 14px;
    flex-wrap: wrap;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    color: var(--color-text-main);
}

.fm-balance-sm b {
    color: var(--color-primary-dark);
}

.fm-claim {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-yellow-dark);
    border-radius: var(--radius-md);
}

.fm-rw {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.fm-rw.is-off {
    border-style: dashed;
}

.fm-rw-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.fm-rw-head .fm-reward-ico {
    font-size: 1.6rem;
}

.fm-rw-main {
    flex: 1;
    min-width: 0;
    color: var(--color-text-main);
    overflow-wrap: anywhere;
}

.fm-rw-cost {
    font-weight: 800;
    white-space: nowrap;
    color: var(--color-text-main);
}

.fm-rw-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.fm-confirm {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--danger-border);
    border-radius: var(--radius-sm);
    background: var(--danger-bg);
}

.fm-confirm p {
    flex: 1 1 100%;
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.45;
    color: var(--color-text-main);
}

.fm-danger {
    color: var(--danger-fg);
    border-color: var(--danger-border);
}

.fm-hist {
    margin-top: 12px;
}

.fm-hist > summary {
    display: flex;
    align-items: center;
    min-height: 44px;
    font-weight: 700;
    color: var(--color-heading);
    cursor: pointer;
}

/* ---------- Űrlapok ---------- */
.fm-form {
    margin: 10px 0;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.fm-form .fm-subh {
    margin-top: 0;
}

.fm-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

.fm-field label,
.fm-msgform label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-heading);
}

.fm-field .form-input,
.fm-msgform .form-input {
    min-height: 44px;
}

.fm-emoji-in {
    max-width: 8rem;
    font-size: 1.3rem;
    text-align: center;
}

.fm-pal {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.fm-pal-btn {
    width: 44px;
    height: 44px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    font-size: 1.3rem;
    cursor: pointer;
}

.fm-pal-btn:hover {
    border-color: var(--color-primary);
}

.fm-form-err {
    margin: 0 0 10px;
    padding: 8px 10px;
    border: 1px solid var(--danger-border);
    border-radius: var(--radius-sm);
    background: var(--danger-bg);
    font-size: 0.85rem;
    color: var(--danger-fg);
    overflow-wrap: anywhere;
}

.fm-form-err[hidden] {
    display: none;
}

.fm-form-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.fm-msgform {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.fm-msgform textarea {
    resize: vertical;
}

.fm-msgform-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.fm-count.is-near {
    font-weight: 700;
    color: var(--warning-fg);
}

/* ---------- Üzenet-szál (szülő) ---------- */
.fm-thread-item {
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.fm-thread-body {
    margin: 0 0 6px;
    color: var(--color-text-main);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.fm-thread-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px 10px;
    flex-wrap: wrap;
    font-size: 0.8rem;
}

.fm-seen {
    font-weight: 700;
    color: var(--color-card-text);
}

.fm-seen.is-read {
    color: var(--success-fg);
}

/* ---------- Hangulat-összegzés (szülő) ---------- */
.fm-seg {
    display: inline-flex;
    margin: 4px 0 12px;
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
}

.fm-seg-btn {
    min-width: 64px;
    min-height: 44px;
    padding: 0 14px;
    border: 0;
    background: var(--color-surface-variant);
    color: var(--color-text-main);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.fm-seg-btn[aria-pressed="true"] {
    background: var(--color-primary-container);
    color: var(--color-on-primary-container);
}

.fm-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.fm-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 6px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    text-align: center;
}

.fm-stat-num {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.2;
    color: var(--color-text-main);
}

.fm-stat-num small {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-card-text);
}

.fm-trend-text {
    margin: 10px 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--color-text-main);
}

.fm-chart {
    max-width: 380px;
    margin: 8px 0;
}

/* ---------- Mobil ---------- */
@media (max-width: 400px) {
    .fm-card.card {
        padding: 12px 14px;
    }

    .fm-mood-lbl {
        font-size: 0.66rem;
    }

    .fm-bal-num {
        font-size: 1.7rem;
    }
}

@media (max-width: 767px) {
    .fm-card .btn,
    .fm-parent .btn {
        min-height: 44px;
    }

    .fm-sec-body {
        padding: 2px 12px 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .fm-mood-btn,
    .fm-sec > summary::after {
        transition: none;
    }
}
