/* ==============================================================================
 * Mentifyll: élő szülői nézet („📡 Gyerekeim most”), részletek ablak,
 * valamint a gyerek oldali figyelmeztetés-ablak és átláthatósági megjegyzés.
 * Minden szín a tokens.css változóiból (sötét és világos téma is).
 * ============================================================================== */

.live-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Panel ---------- */
#today-live-root[hidden] {
    display: none;
}

.live-panel.card {
    padding: 14px 16px;
    border-left: 5px solid var(--color-teal);
    min-width: 0;
}

.live-panel-head {
    display: flex;
    align-items: center;
    gap: 6px 12px;
    flex-wrap: wrap;
}

.live-panel-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--color-heading);
}

.live-panel-meta {
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

.live-panel-meta.is-error {
    color: var(--warning-fg);
}

.live-collapse {
    margin-left: auto;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--color-text-main);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
}

.live-collapse:hover {
    background: var(--color-surface-hover);
}

.live-panel-summary {
    margin: 8px 0 0;
    font-size: 0.88rem;
    color: var(--color-card-text);
    overflow-wrap: anywhere;
}

.live-panel-body[hidden],
.live-panel-summary[hidden] {
    display: none;
}

.live-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
    gap: 12px;
    margin-top: 12px;
}

/* ---------- Gyerek-kártya ---------- */
.live-child {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface-variant);
}

.live-child.is-online {
    border-color: var(--success-border);
}

.live-child-head {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.live-avatar {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--color-indigo-dark);
    color: #ffffff;
    font-weight: 800;
    font-size: 1.1rem;
}

.live-child-id {
    flex: 1 1 auto;
    min-width: 0;
}

.live-name {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    color: var(--color-heading);
    overflow-wrap: anywhere;
}

.live-name small,
.live-detail-head small {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-card-text);
}

.live-detail-btn.btn {
    flex: 0 0 auto;
}

.live-status {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 8px;
    margin-top: 3px;
}

.live-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    background: var(--color-neutral-subtle);
    color: var(--color-card-text);
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-text-muted);
}

.live-st-practising,
.live-st-studying,
.live-st-in_app {
    background: var(--success-bg);
    border-color: var(--success-border);
    color: var(--success-fg);
}

.live-st-practising .live-dot,
.live-st-studying .live-dot,
.live-st-in_app .live-dot {
    background: var(--success-fg);
}

.live-st-practising .live-dot {
    animation: live-pulse 1.6s ease-in-out infinite;
}

.live-st-background,
.live-st-away {
    background: var(--warning-bg);
    border-color: var(--warning-border);
    color: var(--warning-fg);
}

.live-st-background .live-dot,
.live-st-away .live-dot {
    background: var(--warning-fg);
}

.live-st-disabled {
    background: var(--info-bg);
    border-color: var(--info-border);
    color: var(--info-fg);
}

.live-st-disabled .live-dot {
    display: none;
}

.live-where {
    font-size: 0.78rem;
    color: var(--color-card-text);
}

.live-where.is-error {
    color: var(--warning-fg);
}

@keyframes live-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.35; transform: scale(0.75); }
}

/* ---------- Folyó gyakorlás ---------- */
.live-session {
    padding: 10px;
    border: 1px solid var(--success-border);
    border-radius: var(--radius-sm);
    background: var(--success-bg);
}

.live-session-head,
.live-session-meta {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 2px 10px;
    font-size: 0.82rem;
    color: var(--color-text-main);
}

.live-session-head strong {
    font-size: 0.92rem;
    color: var(--color-heading);
}

.live-session-meta {
    margin-top: 6px;
    font-size: 0.76rem;
    color: var(--color-card-text);
}

.live-progress {
    height: 8px;
    margin-top: 8px;
    border-radius: var(--radius-full);
    background: var(--color-neutral-subtle);
    overflow: hidden;
}

.live-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--color-teal);
    transition: width 0.4s ease;
}

/* ---------- Mai mutatók és házi feladat ---------- */
.live-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}

.live-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 4px;
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    text-align: center;
    min-width: 0;
}

.live-stat strong {
    font-size: 1.05rem;
    color: var(--color-heading);
}

.live-stat span {
    font-size: 0.68rem;
    line-height: 1.2;
    color: var(--color-card-text);
}

.live-hw {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.live-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    background: var(--color-surface);
    color: var(--color-card-text);
    font-size: 0.74rem;
    font-weight: 700;
}

.live-chip.is-ok {
    background: var(--success-bg);
    border-color: var(--success-border);
    color: var(--success-fg);
}

.live-chip.is-warn {
    background: var(--warning-bg);
    border-color: var(--warning-border);
    color: var(--warning-fg);
}

.live-chip.is-bad {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger-fg);
}

/* ---------- Elküldött figyelmeztetések ---------- */
.live-nudges {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.live-nudge {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 2px 8px;
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    font-size: 0.78rem;
}

.live-nudge-body {
    color: var(--color-text-main);
    min-width: 0;
    overflow-wrap: anywhere;
}

.live-nudge-state {
    color: var(--color-card-text);
    white-space: nowrap;
    font-weight: 700;
}

.live-nudge.is-seen .live-nudge-state {
    color: var(--success-fg);
}

.live-nudge.is-expired .live-nudge-state {
    color: var(--warning-fg);
}

/* ---------- Küldés ---------- */
.live-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.live-presets {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}

.live-preset.btn {
    width: 100%;
    padding: 0 6px;
    white-space: nowrap;
}

.live-custom {
    display: flex;
    gap: 6px;
    min-width: 0;
}

.live-custom input {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-full);
    background: var(--input-bg);
    color: var(--input-text);
    font: inherit;
    font-size: 0.85rem;
}

.live-custom input:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
}

.live-custom .btn {
    flex: 0 0 auto;
}

.live-actions .btn:disabled {
    opacity: 0.55;
    cursor: wait;
}

/* ---------- Részletek ablak ---------- */
.live-detail-backdrop,
.live-alert-backdrop {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(2, 6, 23, 0.62);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.live-detail-card {
    display: flex;
    flex-direction: column;
    width: min(560px, 100%);
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    box-shadow: var(--shadow-lg);
    outline: none;
}

.live-detail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border);
}

.live-detail-head h3 {
    margin: 0;
    font-size: 1.05rem;
    color: var(--color-heading);
    overflow-wrap: anywhere;
}

.live-detail-close {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    background: transparent;
    color: var(--color-text-main);
    font-size: 1rem;
    cursor: pointer;
}

.live-detail-close:hover {
    background: var(--color-surface-hover);
}

.live-detail-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px 18px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.live-subh {
    margin: 6px 0 0;
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--color-heading);
}

.live-feed {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.live-feed li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    background: var(--color-surface-variant);
    font-size: 0.8rem;
    color: var(--color-text-main);
}

.live-feed-where {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

.live-feed time {
    flex: 0 0 auto;
    color: var(--color-card-text);
    font-variant-numeric: tabular-nums;
}

.live-hint,
.live-empty {
    margin: 0;
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

.live-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 12px;
}

.live-toggle-row p {
    flex: 1 1 240px;
    margin: 0;
    font-size: 0.82rem;
    color: var(--color-card-text);
}

/* ---------- Gyerek: figyelmeztetés-ablak ---------- */
.live-alert-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: min(440px, 100%);
    padding: 26px 22px 20px;
    border: 3px solid var(--color-yellow);
    border-radius: var(--radius-xl);
    background: var(--color-surface);
    box-shadow: var(--shadow-lg);
    text-align: center;
    outline: none;
    animation: live-pop 0.28s ease-out;
}

.live-alert-praise {
    border-color: var(--color-teal);
}

.live-alert-break {
    border-color: var(--color-indigo);
}

.live-alert-icon {
    font-size: 3rem;
    line-height: 1;
}

.live-alert-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--color-heading);
}

.live-alert-text {
    margin: 0;
    font-size: 1.15rem;
    line-height: 1.45;
    color: var(--color-text-main);
    overflow-wrap: anywhere;
}

.live-alert-meta,
.live-alert-more {
    margin: 0;
    font-size: 0.8rem;
    color: var(--color-card-text);
}

.live-alert-meta[hidden],
.live-alert-more[hidden] {
    display: none;
}

.live-alert-ok.btn {
    margin-top: 6px;
    font-size: 1.05rem;
}

.live-alert-card.is-shake {
    animation: live-shake 0.4s ease;
}

@keyframes live-pop {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes live-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

/* ---------- Gyerek: átláthatósági megjegyzés az „Én” fülön ---------- */
.live-child-note {
    margin: 8px 0 12px;
    padding: 8px 12px;
    border: 1px solid var(--info-border);
    border-radius: var(--radius-md);
    background: var(--info-bg);
    color: var(--info-fg);
    font-size: 0.82rem;
    line-height: 1.45;
}

/* ---------- Mobil ---------- */
@media (max-width: 480px) {
    .live-panel.card {
        padding: 12px;
    }

    .live-presets {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .live-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .live-detail-backdrop {
        align-items: flex-end;
        padding: 0;
    }

    .live-detail-card {
        width: 100%;
        max-height: 92vh;
        max-height: 92dvh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .live-st-practising .live-dot,
    .live-alert-card,
    .live-alert-card.is-shake {
        animation: none;
    }

    .live-progress span {
        transition: none;
    }
}

@media print {
    #today-live-root {
        display: none !important;
    }
}
