/* ── Fonts ────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

/* ── Design tokens ───────────────────────────────────────── */
:root {
    --brand:         #6c63ff;
    --brand-dark:    #5a51e0;
    --brand-light:   #ede9ff;
    --green:         #22c55e;
    --green-light:   #dcfce7;
    --orange:        #f97316;
    --orange-light:  #fff7ed;
    --red:           #ef4444;
    --red-light:     #fee2e2;
    --yellow:        #eab308;
    --yellow-light:  #fefce8;
    --blue:          #3b82f6;
    --blue-light:    #eff6ff;
    --surface:       #f8fafc;
    --surface-card:  #ffffff;
    --border:        #e2e8f0;
    --text:          #1e293b;
    --text-muted:    #64748b;
    --radius-sm:     8px;
    --radius:        12px;
    --radius-lg:     20px;
    --shadow-sm:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --shadow:        0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
    --shadow-lg:     0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.05);
}

/* ── Base ────────────────────────────────────────────────── */
html, body {
    font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--surface);
    color: var(--text);
    font-size: 15px;
}

a, .btn-link { color: var(--brand); }

/* ── Cards ───────────────────────────────────────────────── */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-header {
    border-radius: var(--radius) var(--radius) 0 0 !important;
    border-bottom: 1px solid var(--border);
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 600;
    transition: all .15s ease;
}
.btn-primary {
    background-color: var(--brand);
    border-color: var(--brand);
    color: #fff;
}
.btn-primary:hover { background-color: var(--brand-dark); border-color: var(--brand-dark); }
.btn:focus, .btn:active:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(108,99,255,.25);
    outline: none;
}

/* ── Tables ──────────────────────────────────────────────── */
.table { --bs-table-border-color: var(--border); }
.table thead th {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    background: var(--surface);
}

/* ── Forms ───────────────────────────────────────────────── */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border);
}

/* ── App Header (top nav) ────────────────────────────────── */
.app-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}
.app-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    min-height: 60px;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap;
    align-items: center;
    gap: 1.5rem;
}
.app-nav {
    flex: 0 1 auto;
}
.app-brand {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 1.3rem;
    color: var(--brand) !important;
    text-decoration: none !important;
    white-space: nowrap;
}
.app-brand:hover { color: var(--brand-dark) !important; }

/* ── Nav links ───────────────────────────────────────────── */
.app-nav { display: flex !important; flex-direction: row !important; align-items: center; gap: .2rem; }
.app-nav-link {
    padding: .4rem .85rem;
    border-radius: var(--radius-sm);
    text-decoration: none !important;
    font-weight: 600;
    font-size: .9rem;
    color: var(--text-muted);
    transition: all .15s ease;
    white-space: nowrap;
}
.app-nav-link:hover { color: var(--brand); background: var(--brand-light); }
.app-nav-link.active { color: var(--brand); background: var(--brand-light); }

/* ── Login display ───────────────────────────────────────── */
.login-display {
    display: flex;
    align-items: center;
    gap: .75rem;
    font-size: .875rem;
    color: var(--text-muted);
}
.login-display a {
    color: var(--brand);
    font-weight: 600;
    text-decoration: none;
}
.login-display a:hover { text-decoration: underline; }

/* ── Content area ────────────────────────────────────────── */
.app-main { background: var(--surface); min-height: calc(100vh - 60px); }
.app-content { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; }

/* ────────────────────────────────────────────────────────── */
/* KID-FRIENDLY THEME  (.kid-theme on root wrapper)          */
/* ────────────────────────────────────────────────────────── */
.kid-theme {
    font-family: 'Nunito', 'Helvetica Neue', Arial, sans-serif !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 0;
}

/* Kid page wrapper */
.kid-page {
    max-width: 720px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

/* Points hero */
.kid-points-hero {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border-radius: 24px;
    color: #fff;
    padding: 1.5rem 2rem;
    text-align: center;
    margin-bottom: 1.5rem;
    box-shadow: 0 8px 24px rgba(240,147,251,.45);
}
.kid-points-hero .kid-name    { font-size: 1.5rem; font-weight: 800; margin-bottom: .2rem; }
.kid-points-hero .points-row  { display: flex; align-items: baseline; justify-content: center; gap: .4rem; }
.kid-points-hero .points-num  { font-size: 3.5rem; font-weight: 800; line-height: 1; }
.kid-points-hero .points-label{ font-size: 1.1rem; font-weight: 600; opacity: .9; }

/* Section panels */
.kid-section {
    background: rgba(255,255,255,.14);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 20px;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    border: 1px solid rgba(255,255,255,.25);
}
.kid-section-heading {
    font-size: 1.2rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* Card grid for chores/rewards */
.kid-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: .75rem;
}
.kid-card {
    background: #fff;
    border-radius: 18px;
    padding: 1rem .75rem;
    text-align: center;
    box-shadow: 0 4px 14px rgba(0,0,0,.1);
    transition: transform .15s ease, box-shadow .15s ease;
    border: 3px solid transparent;
}
.kid-card:hover { transform: translateY(-3px); box-shadow: 0 8px 22px rgba(0,0,0,.15); }
.kid-card-icon  { font-size: 2.2rem; margin-bottom: .4rem; }
.kid-card-name  { font-size: .9rem; font-weight: 700; color: var(--text); margin-bottom: .4rem; line-height: 1.2; }
.kid-card-pts   { font-size: .95rem; font-weight: 800; margin-bottom: .6rem; }
.kid-card .btn  { border-radius: 999px; font-size: .8rem; padding: .28rem .85rem; font-weight: 700; }
.kid-card.chore-card                { border-color: #a7f3d0; }
.kid-card.chore-card .kid-card-pts  { color: #16a34a; }
.kid-card.reward-card               { border-color: #fde68a; }
.kid-card.reward-card .kid-card-pts { color: #d97706; }
.kid-card.reward-card.cant-afford   { opacity: .5; filter: grayscale(.4); }

/* Pending items */
.kid-pending-item {
    background: rgba(255,255,255,.18);
    border-radius: 12px;
    padding: .65rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .5rem;
    color: #fff;
    gap: .5rem;
}
.kid-pending-item .pi-name { font-weight: 700; font-size: .9rem; }
.kid-pending-item .pi-pts  { font-size: .82rem; opacity: .85; white-space: nowrap; }
.kid-pending-item .btn     { border-radius: 999px; font-size: .78rem; padding: .2rem .65rem; font-weight: 700; }

/* Toast / success message */
.kid-toast {
    background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
    border-radius: 14px;
    padding: .7rem 1rem;
    font-weight: 700;
    color: #14532d;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* History table inside kid theme */
.kid-history-table { width: 100%; border-radius: 14px; overflow: hidden; font-size: .85rem; }
.kid-history-table thead th {
    background: rgba(255,255,255,.2) !important;
    color: #fff !important;
    font-weight: 700;
    text-transform: uppercase;
    font-size: .7rem;
    letter-spacing: .05em;
    border: none;
}
.kid-history-table tbody td { border-color: rgba(255,255,255,.1); }
.kid-history-table tbody tr.table-success td { background: #d1fae5 !important; color: #14532d; }
.kid-history-table tbody tr.table-warning td { background: #fef9c3 !important; color: #713f12; }
.kid-history-table tbody tr.table-danger  td { background: #fee2e2 !important; color: #7f1d1d; }

/* Kid header bar (inside kid page) */
.kid-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.kid-header-bar .btn { border-radius: 999px; font-size: .82rem; font-weight: 700; }

/* Password gate */
.kid-password-gate {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.kid-password-card {
    background: rgba(255,255,255,.97);
    border-radius: 28px;
    padding: 2.5rem 2rem;
    max-width: 380px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.kid-password-card .avatar-emoji { font-size: 4rem; margin-bottom: .75rem; display: block; }
.kid-password-card h2 { font-family: 'Nunito', sans-serif; font-weight: 800; margin-bottom: .25rem; }
.kid-password-card .subtitle { color: var(--text-muted); font-size: .9rem; margin-bottom: 1.5rem; }
.kid-password-card .form-control {
    border-radius: 999px;
    padding: .6rem 1.25rem;
    font-size: 1.1rem;
    text-align: center;
    letter-spacing: .2em;
    border: 2px solid var(--border);
    margin-bottom: .75rem;
}
.kid-password-card .form-control:focus { border-color: var(--brand); }
.kid-password-card .btn-unlock {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 999px;
    color: #fff;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 1rem;
    padding: .65rem 2rem;
    width: 100%;
    margin-bottom: .5rem;
}
.kid-password-card .btn-unlock:hover { opacity: .92; }
.kid-password-card .btn-back {
    background: none;
    border: 2px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    font-weight: 700;
    font-size: .9rem;
    padding: .5rem 1.5rem;
    width: 100%;
}

/* ── Validation ──────────────────────────────────────────── */
h1:focus { outline: none; }
.valid.modified:not([type=checkbox]) { outline: 1px solid var(--green); }
.invalid { outline: 1px solid var(--red); }
.validation-message { color: var(--red); }

/* ── Blazor errors ───────────────────────────────────────── */
.blazor-error-boundary {
    background: var(--red-light);
    border: 1px solid var(--red);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    color: #7f1d1d;
}
.blazor-error-boundary::after { content: "An error has occurred. Please refresh the page."; }

#blazor-error-ui {
    background: var(--yellow-light);
    border: 1px solid var(--yellow);
    border-radius: var(--radius);
    padding: .75rem 1rem;
    font-size: .875rem;
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 9999;
    box-shadow: var(--shadow);
}
#blazor-error-ui .dismiss { cursor: pointer; font-weight: 700; }

.darker-border-checkbox.form-check-input { border-color: #929292; }

/* ── Responsive layout ──────────────────────────────────── */
@media (max-width: 991.98px) {
    .app-header-inner {
        padding: .7rem 1rem;
        min-height: auto;
        flex-wrap: wrap !important;
        gap: .75rem;
    }

    .app-header .ms-auto {
        margin-left: auto !important;
    }

    .app-nav {
        order: 3;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: .2rem;
    }

    .app-nav-link {
        flex: 0 0 auto;
    }

    .app-content {
        padding: 1.25rem 1rem;
    }
}

@media (max-width: 767.98px) {
    .app-brand {
        font-size: 1.15rem;
    }

    .app-nav {
        gap: .35rem;
    }

    .app-nav-link {
        font-size: .85rem;
        padding: .4rem .65rem;
    }

    .login-display {
        font-size: .8rem;
        gap: .5rem;
    }

    .display-4 {
        font-size: 2rem;
    }

    .nav-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .nav-tabs .nav-link {
        white-space: nowrap;
    }

    .table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .kid-page {
        padding: 1rem .75rem;
    }

    .kid-header-bar {
        flex-wrap: wrap;
        gap: .5rem;
    }

    .kid-points-hero {
        padding: 1.2rem 1rem;
    }

    .kid-points-hero .kid-name {
        font-size: 1.25rem;
    }

    .kid-points-hero .points-num {
        font-size: 2.6rem;
    }

    .kid-card-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }

    .kid-pending-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .kid-pending-item .btn {
        align-self: flex-end;
    }
}
