/*
 * Account, login and admin styles. Loaded after typography.css and before
 * emoji.css, matching the load order used by the game stylesheets.
 */

/* Without this, width:100% + padding + border overflows every card. */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Quiet account row at the bottom of the home card. The card centres text,
   so this row explicitly resets alignment. */
.account-slot {
    margin-top: 20px;
    padding-top: 12px;
    border-top: 1px solid #e5e1d8;
    text-align: left;
}

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

.account-chip,
.account-cta {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: var(--tap-min);
    padding: 0;
    font-size: var(--text-meta);
    font-weight: 600;
    text-decoration: none;
}

.account-chip {
    flex-wrap: nowrap;
    justify-content: space-between;
    color: #5a6b60;
}

.account-chip-id {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex: 1 1 auto;
    min-width: 0;
}

.account-chip-label {
    flex: 0 0 auto;
    color: #5a6b60;
    font-weight: 600;
}

.account-chip-email {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 700;
    color: #3b6b47;
    text-align: left;
}

.account-cta {
    flex-wrap: wrap;
    color: #7a5a12;
}

.account-link {
    flex: 0 0 auto;
    min-height: var(--tap-min);
    padding: 8px 14px;
    border: 1.5px solid #e2c7c0;
    border-radius: 999px;
    background: #fff;
    color: #8a2f1f;
    font: inherit;
    font-weight: 700;
    font-size: var(--text-meta);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.account-link:hover,
.account-link:focus-visible {
    background: #fdecea;
    border-color: #d9a99f;
}

/* ---------- Login / auth card ---------- */

.auth-page {
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f7f5ef;
    background-image: radial-gradient(#e5e1d8 1px, transparent 1px);
    background-size: 20px 20px;
    color: #2c3e35;
    font-family: var(--font-body);
}

.auth-card {
    width: 100%;
    max-width: 460px;
    background: #fff;
    border: 4px solid #e1ded4;
    border-radius: 28px;
    box-shadow: 0 15px 35px rgba(59, 107, 71, 0.12);
    padding: clamp(20px, 5vw, 34px);
}

.auth-card h1 {
    margin: 0 0 6px;
    font-family: var(--font-display);
    font-size: var(--text-title);
    line-height: var(--leading-tight);
    color: #3b6b47;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 2px 2px 0 #f4d06f;
}

.auth-sub {
    margin: 0 0 22px;
    font-size: var(--text-small);
    line-height: var(--leading-snug);
    font-weight: 600;
    color: #5a6b60;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.auth-field label {
    font-size: var(--text-small);
    font-weight: 700;
    color: #3b6b47;
}

.auth-field input {
    width: 100%;
    max-width: 100%;
    min-height: var(--tap-comfortable);
    padding: 10px 14px;
    border: 2px solid #d5e6db;
    border-radius: 14px;
    background: #f7f9f6;
    color: inherit;
    font-family: var(--font-body);
    font-size: var(--text-body);
}

.auth-field input:focus-visible {
    outline: 3px solid #9fd8b0;
    outline-offset: 1px;
    border-color: #67a379;
}

.auth-submit {
    width: 100%;
    min-height: var(--tap-comfortable);
    margin-top: 4px;
    padding: 12px 18px;
    border: 0;
    border-radius: 16px;
    background: #67a379;
    color: #fff;
    font-family: var(--font-display);
    font-size: var(--text-option);
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 5px 0 #3b6b47;
}

.auth-submit:hover:not(:disabled) {
    background: #5b9670;
}

.auth-submit:active:not(:disabled) {
    transform: translateY(3px);
    box-shadow: 0 2px 0 #3b6b47;
}

.auth-submit:disabled {
    opacity: 0.65;
    cursor: progress;
}

.auth-error {
    margin: 14px 0 0;
    padding: 10px 12px;
    border-radius: 12px;
    background: #fdecea;
    border: 2px solid #f3c4bd;
    color: #8a2f1f;
    font-size: var(--text-small);
    font-weight: 600;
    line-height: var(--leading-snug);
}

.auth-help {
    margin: 18px 0 0;
    font-size: var(--text-meta);
    line-height: var(--leading-snug);
    color: #5a6b60;
    text-align: center;
}

.auth-help a {
    color: #3b6b47;
    font-weight: 700;
}

.auth-note {
    padding: 10px 12px;
    border-radius: 12px;
    background: #fff8e2;
}

/* ---------- Admin ---------- */

.admin-page {
    min-height: 100vh;
    margin: 0;
    padding: 18px;
    background-color: #f7f5ef;
    background-image: radial-gradient(#e5e1d8 1px, transparent 1px);
    background-size: 20px 20px;
    color: #2c3e35;
    font-family: var(--font-body);
}

/* Logged-out admin mirrors the parent login: one centered card, no chrome. */
body.admin-login-mode {
    display: flex;
    align-items: center;
    justify-content: center;
}

body.admin-login-mode .admin-shell {
    width: 100%;
    max-width: 460px;
}

body.admin-login-mode .admin-head {
    display: none;
}

.admin-shell {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
}

.admin-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.admin-head h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: var(--text-title);
    line-height: var(--leading-tight);
    color: #3b6b47;
    text-shadow: 2px 2px 0 #f4d06f;
}

.admin-logout {
    min-height: var(--tap-min);
    padding: 10px 16px;
    border: 2px solid #d5b9b1;
    border-radius: 14px;
    background: #fff;
    color: #8a2f1f;
    font-family: var(--font-body);
    font-size: var(--text-small);
    font-weight: 700;
    cursor: pointer;
}

.admin-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    align-items: start;
}

@media (min-width: 900px) {
    .admin-grid {
        grid-template-columns: 340px minmax(0, 1fr);
    }

    .admin-panel-wide {
        grid-column: 1 / -1;
    }
}

.admin-panel {
    background: #fff;
    border: 3px solid #e1ded4;
    border-radius: 20px;
    padding: 18px;
    box-shadow: 0 8px 20px rgba(59, 107, 71, 0.08);
    min-width: 0;
    overflow: hidden;
}

.admin-panel form > *,
.admin-panel > * {
    min-width: 0;
}

.admin-panel h2 {
    margin: 0 0 14px;
    font-family: var(--font-display);
    font-size: var(--text-option);
    color: #3b6b47;
}

.admin-panel form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.admin-panel input[type='email'],
.admin-panel input[type='text'],
.admin-panel input[type='password'] {
    width: 100%;
    max-width: 100%;
    min-height: var(--tap-comfortable);
    padding: 10px 12px;
    border: 2px solid #d5e6db;
    border-radius: 12px;
    background: #f7f9f6;
    font-family: var(--font-body);
    font-size: var(--text-small);
    color: inherit;
}

.admin-panel button[type='submit'] {
    min-height: var(--tap-comfortable);
    border: 0;
    border-radius: 14px;
    background: #67a379;
    color: #fff;
    font-family: var(--font-display);
    font-size: var(--text-small);
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 0 #3b6b47;
}

.admin-hint {
    margin: 0;
    font-size: var(--text-meta);
    line-height: var(--leading-snug);
    color: #6a7a70;
}

.parent-list,
.purchase-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 60vh;
    overflow-y: auto;
}

.parent-card,
.purchase-card {
    border: 2px solid #e3ede6;
    border-radius: 14px;
    padding: 12px;
    background: #fbfdfb;
}

.parent-top {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.parent-email {
    font-weight: 700;
    font-size: var(--text-small);
    overflow-wrap: anywhere;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: var(--text-meta);
    font-weight: 700;
    background: #eef1ef;
    color: #4a5b51;
}

.badge-ok {
    background: #e2f2e6;
    color: #2f6b41;
}

.badge-warn {
    background: #fdecea;
    color: #8a2f1f;
}

.parent-meta,
.purchase-meta {
    margin: 6px 0 0;
    font-size: var(--text-meta);
    line-height: var(--leading-snug);
    color: #6a7a70;
}

.parent-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.parent-actions button {
    min-height: 44px;
    padding: 8px 12px;
    border: 2px solid #cfe3d3;
    border-radius: 12px;
    background: #fff;
    color: #3b6b47;
    font-family: var(--font-body);
    font-size: var(--text-meta);
    font-weight: 700;
    cursor: pointer;
}

.parent-actions button[data-action='delete'] {
    border-color: #e6c7c0;
    color: #8a2f1f;
}

.admin-empty {
    font-size: var(--text-small);
    color: #6a7a70;
}

@media (max-width: 420px) {
    .admin-page {
        padding: 12px;
    }

    .admin-panel {
        padding: 14px;
        border-radius: 16px;
    }
}
