/* ─── Design Tokens ───────────────────────────────────── */
:root {
    --primary-green:     #00e600;
    --primary-green-h:   #00cc00;
    --primary-green-txt: #003300;
    --bg-page:           #eeeef4;
    --bg-card:           #f8f8fc;
    --bg-input:          #ffffff;
    --border-input:      #d8d8e4;
    --border-focus:      #00aa00;
    --text-dark:         #1a1a1a;
    --text-gray:         #595959;
    --text-muted:        #696978; /* war #828295, ~3.6:1 → jetzt ~5.1:1 WCAG AA */
    --text-link:         #007700;
    --error-color:       #c0392b;
    --error-bg:          #fdf0ef;
    --radius-card:       20px;
    --radius-input:      50px;
    --radius-btn:        50px;
    --shadow-card:       0 4px 32px rgba(0,0,0,.08), 0 1px 6px rgba(0,0,0,.04);
    --transition:        160ms ease-out;
}

/* Dark mode – via Systemeinstellung ODER manueller Klasse */
@media (prefers-color-scheme: dark) {
    :root:not(.light-mode) {
        --bg-page:       #001800;
        --bg-card:       #002800;
        --bg-input:      #003800;
        --border-input:  #005500;
        --border-focus:  #00cc00;
        --text-dark:     #e8ffe8;
        --text-gray:     #a8c8a8;
        --text-muted:    #78a878;
        --text-link:     #44dd44;
        --error-color:   #ff7766;
        --error-bg:      #330000;
        --shadow-card:   0 4px 32px rgba(0,0,0,.4);
    }
}

/* Manuell auf Dark umschalten */
html.dark-mode {
    --bg-page:       #001800;
    --bg-card:       #002800;
    --bg-input:      #003800;
    --border-input:  #005500;
    --border-focus:  #00cc00;
    --text-dark:     #e8ffe8;
    --text-gray:     #a8c8a8;
    --text-muted:    #78a878;
    --text-link:     #44dd44;
    --error-color:   #ff7766;
    --error-bg:      #330000;
    --shadow-card:   0 4px 32px rgba(0,0,0,.4);
}

/* Theme-Toggle Button */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--border-input);
    background: var(--bg-card);
    color: var(--text-dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
    z-index: 100;
}
.theme-toggle:hover {
    border-color: var(--border-focus);
    box-shadow: 0 2px 12px rgba(0,180,0,.2);
}
.theme-toggle:focus-visible {
    outline: 3px solid var(--border-focus);
    outline-offset: 3px;
}
.theme-toggle .icon-moon { display: block; }
.theme-toggle .icon-sun  { display: none; }
html.dark-mode .theme-toggle .icon-moon { display: none; }
html.dark-mode .theme-toggle .icon-sun  { display: block; }
@media (prefers-color-scheme: dark) {
    html:not(.light-mode) .theme-toggle .icon-moon { display: none; }
    html:not(.light-mode) .theme-toggle .icon-sun  { display: block; }
}

/* ─── Reset & Base ────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
    font-family: 'Atkinson Hyperlegible', -apple-system, BlinkMacSystemFont,
                 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-dark);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

:focus-visible {
    outline: 3px solid var(--border-focus);
    outline-offset: 3px;
}

/* Skip-Link */
.skip-link {
    position: absolute;
    top: -100%;
    left: 16px;
    background: var(--primary-green);
    color: var(--primary-green-txt);
    padding: 8px 16px;
    border-radius: 0 0 8px 8px;
    font-weight: 700;
    z-index: 1000;
    transition: top var(--transition);
}
.skip-link:focus { top: 0; }

/* ─── Login Card ──────────────────────────────────────── */
.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    width: 100%;
    max-width: 520px;
    padding: 48px 40px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

/* ─── Logo ────────────────────────────────────────────── */
.logo-wrap {
    margin-bottom: 28px;
}

.logo-svg {
    width: 56px;
    height: 56px;
    display: block;
}

/* ─── Heading ─────────────────────────────────────────── */
.login-title {
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 700;
    color: var(--text-dark);
    text-align: center;
    line-height: 1.25;
    margin-bottom: 36px;
    letter-spacing: -.02em;
}

/* ─── Form ────────────────────────────────────────────── */
.login-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-label {
    font-size: .875rem;
    font-weight: 700;
    color: var(--text-gray);
    padding-left: 18px;
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 18px;
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    pointer-events: none;
    flex-shrink: 0;
}

.field-input {
    width: 100%;
    height: 52px;
    background: var(--bg-input);
    border: 1.5px solid var(--border-input);
    border-radius: var(--radius-input);
    padding: 0 48px 0 50px;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-dark);
    transition: border-color var(--transition), box-shadow var(--transition);
    -webkit-appearance: none;
    appearance: none;
}

.field-input::placeholder {
    color: var(--text-muted);
}

.field-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(0,170,0,.18);
}

.field-input[aria-invalid="true"] {
    border-color: var(--error-color);
    background: var(--error-bg);
}
.field-input[aria-invalid="true"]:focus {
    box-shadow: 0 0 0 3px rgba(192,57,43,.2);
}

.field-error {
    display: none;
    font-size: .8125rem;
    color: var(--error-color);
    padding-left: 18px;
    font-weight: 700;
}
.field-error[aria-live] { display: block; }

/* Passwort-Toggle */
.pwd-toggle {
    position: absolute;
    right: 16px;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    border-radius: 50%;
    transition: color var(--transition), background var(--transition);
}
.pwd-toggle:hover { color: var(--text-gray); background: rgba(0,0,0,.06); }
.pwd-toggle:focus-visible { outline: 3px solid var(--border-focus); }

/* ─── Checkbox + Passwort-Link Zeile ──────────────────── */
.options-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
    flex-wrap: wrap;
    gap: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .875rem;
    color: var(--text-gray);
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-green-h);
    cursor: pointer;
    flex-shrink: 0;
}

.forgot-link {
    font-size: .875rem;
    color: var(--text-link);
    text-decoration: none;
    font-weight: 700;
}
.forgot-link:hover, .forgot-link:focus-visible {
    text-decoration: underline;
}

/* ─── Anmelden-Button ─────────────────────────────────── */
.btn-submit {
    margin-top: 8px;
    width: 100%;
    height: 56px;
    background: var(--primary-green);
    color: var(--primary-green-txt);
    border: none;
    border-radius: var(--radius-btn);
    font-family: inherit;
    font-size: 1.125rem;
    font-weight: 700;
    font-style: italic;
    cursor: pointer;
    letter-spacing: .01em;
    transition: background var(--transition), transform 80ms ease, box-shadow var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
}

.btn-submit:hover:not(:disabled) {
    background: var(--primary-green-h);
    box-shadow: 0 4px 16px rgba(0,200,0,.35);
}

.btn-submit:active:not(:disabled) {
    transform: scale(.98);
}

.btn-submit:disabled {
    opacity: .55;
    cursor: not-allowed;
}

/* Spinner */
.btn-spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(0,51,0,.3);
    border-top-color: var(--primary-green-txt);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
.btn-submit.loading .btn-spinner { display: block; }
.btn-submit.loading .btn-text   { opacity: .6; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Shop-Hinweis ────────────────────────────────────── */
.shop-hint {
    margin-top: 20px;
    font-size: .8125rem;
    color: var(--text-muted);
    text-align: center;
}

.shop-hint a {
    color: var(--text-link);
    font-weight: 700;
    text-decoration: none;
}
.shop-hint a:hover { text-decoration: underline; }

/* ─── Allgemeiner Fehler-Alert ────────────────────────── */
.alert-error {
    display: none;
    width: 100%;
    background: var(--error-bg);
    border: 1.5px solid var(--error-color);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: .875rem;
    color: var(--error-color);
    font-weight: 700;
    margin-bottom: 4px;
}
.alert-error.visible { display: flex; gap: 8px; align-items: flex-start; }

/* ─── Footer ──────────────────────────────────────────── */
.page-footer {
    margin-top: 32px;
    font-size: .75rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.6;
}

.page-footer a { color: var(--text-link); text-decoration: none; }
.page-footer a:hover { text-decoration: underline; }

/* ─── Responsive ──────────────────────────────────────── */
@media (max-width: 480px) {
    .login-card { padding: 36px 24px 32px; }
    .login-title { margin-bottom: 28px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}
