:root {
    --bg-color: #f2f2f7; 
    --card-bg: #ffffff;
    --text-color: #1c1c1e;
    --accent-color: #007aff;
    --accent-hover: #005bb5;
    --input-bg: #e5e5ea;
    --highlight-bg: #e8f2ff;
    --danger-color: #ff3b30;
    --success-color: #34c759;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    line-height: 1.5;
}

.container { max-width: 800px; margin: 0 auto; padding-bottom: 50px; }

h1 { text-align: center; margin-bottom: 10px; font-size: 2rem; }
.intro { text-align: center; color: #666; margin-bottom: 30px; }

.card {
    background-color: var(--card-bg);
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.input-section { border: 2px solid transparent; }
.output-section { transition: opacity 0.3s ease; }

h2 { margin-top: 0; border-bottom: 1px solid #eee; padding-bottom: 10px; margin-bottom: 20px; font-size: 1.4rem; }

.form-group { margin-bottom: 15px; }
.highlight { background-color: var(--highlight-bg); padding: 15px; border-radius: 12px; border: 1px solid #d0e3ff; }

label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 0.95rem; }

input[type="text"], input[type="password"], input[type="number"] {
    width: 100%;
    padding: 14px;
    border-radius: 10px;
    border: 2px solid transparent; /* Wichtig für Validierungs-Rand */
    background-color: var(--input-bg);
    font-size: 1.1rem;
    transition: background-color 0.2s, border-color 0.2s;
}

input:focus {
    outline: none;
    background-color: #fff;
    border-color: var(--accent-color);
}

small { display: block; margin-top: 5px; color: #666; font-size: 0.85rem; }

/* Layout Hilfen */
.row { display: flex; gap: 15px; }
.half { flex: 1; }
.third { flex: 1; }

/* Buttons */
.actions { display: flex; gap: 15px; margin-top: 25px; }
.btn {
    flex: 1;
    padding: 16px;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.primary { background-color: var(--accent-color); color: white; }
.primary:hover { background-color: var(--accent-hover); }
.secondary { background-color: #e5e5ea; color: var(--danger-color); }
.secondary:hover { background-color: #d1d1d6; }

/* --- Style für Ausgabe & Übung --- */

.result-block { margin-bottom: 25px; }

.result-row {
    display: flex;
    gap: 15px;
    align-items: center;
}

.password-display {
    display: flex;
    align-items: center;
    /* Damit es exakt wie das Input-Feld aussieht: */
    width: 100%;
    padding: 14px; /* gleiches Padding wie Input */
    border-radius: 10px;
    border: 1px solid #ddd;
    background-color: #fff;
    
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    font-size: 1.1rem;
    letter-spacing: 1px;
    
    overflow-x: auto; /* Falls es auf kleinen Handys zu breit wird */
    white-space: nowrap;
    cursor: text;
    user-select: all; /* Klick markiert alles zum Kopieren */
}

/* Passwort + Kopieren-Button */
.password-wrapper {
    flex: 1;
    min-width: 0;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
}

.password-wrapper .password-display {
    flex: 1;
    min-width: 0;
    width: auto;
}

.copy-btn {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid #ddd;
    border-radius: 10px;
    background-color: #fff;
    color: #007aff;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.copy-btn:hover  { background-color: #f2f2f7; }
.copy-btn:active { background-color: #e5e5ea; }

.copy-btn .icon-check { display: none; }
.copy-btn.copied { color: var(--success-color); border-color: var(--success-color); }
.copy-btn.copied .icon-copy  { display: none; }
.copy-btn.copied .icon-check { display: block; }

/* Die Farben für die Zeichen in der Passwortanzeige */
.char-upper {
    color: #ff9500; /* Apple Orange – Großbuchstaben */
}

.char-letter {
    color: #007aff; /* Apple Blue – Kleinbuchstaben */
}

.char-digit {
    color: #ff3b30; /* Apple Red – Ziffern */
}

.char-symbol {
    color: #1c1c1e; /* Schwarz/Dunkelgrau – Sonderzeichen */
}

/* Entferne Styles, die jetzt im .password-display sind, aus .generated-field falls nötig */
.generated-field {
    flex: 1;
    /* Hintergrund etc. wird jetzt von .password-display geregelt */
}


/* Der Übungs-Bereich */
.practice-wrapper {
    flex: 1;
    position: relative;
}

.practice-field {
    font-family: 'Courier New', Courier, monospace;
}

/* Indikator Icon */
.indicator {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    pointer-events: none;
}

/* Validierungs-Zustände */
.valid-success {
    border-color: var(--success-color) !important;
    background-color: #f0fff4 !important;
    color: #006400;
}

.valid-error {
    border-color: var(--danger-color) !important;
    background-color: #fff5f5 !important;
    color: #8b0000;
}

/* Toggle Switch (iOS-Stil) */
.toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 26px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    border-radius: 26px;
    transition: 0.3s;
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--accent-color);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

/* PIN Toggle (Segmented Control) */

.pin-toggle {
    margin-bottom: 8px;

    display: flex;
    background: #e9e9eb;
    border-radius: 9px;
    padding: 2px;
    width: fit-content;
}

.pin-toggle button {
    padding: 4px 10px;
    border: none;
    background: transparent;
    color: #555;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 7px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.pin-toggle button.active {
    background: white;
    color: #333;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* Drucken-Bereich */
.print-section { margin-top: 20px; }

.print-hint {
    font-size: 0.9rem;
    color: #555;
    padding: 10px;
    background: #fffbe6;
    border-radius: 8px;
    border: 1px solid #ffe58f;
    margin-bottom: 10px;
}

.print-btn {
    background-color: var(--success-color);
    color: white;
    flex: unset;
    width: 100%;
}

/* Druckzusammenfassung: im Browser unsichtbar */
#printSummary { display: none; }

.print-data-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    font-size: 0.95rem;
}
.print-data-table th {
    text-align: left;
    font-weight: 600;
    padding: 5px 10px 5px 0;
    width: 38%;
    vertical-align: top;
}
.print-data-table td {
    padding: 5px 0;
}
.print-data-table tr {
    border-bottom: 1px solid #e0e0e0;
}
/* Geheimwort-Zeile hervorheben */
.print-secret-row th,
.print-secret-row td {
    font-size: 1.1rem;
    font-weight: bold;
    padding-top: 8px;
    padding-bottom: 8px;
}
/* Generiert-am-Zeile dezent */
.print-date-row {
    border-bottom: none;
}
.print-date-row th,
.print-date-row td {
    font-size: 0.8rem;
    color: #888;
    font-weight: 400;
}

/* Drucken */
@media print {
    /* Ausgeblendete Elemente */
    h1, .intro,
    .input-section, .actions, .practice-wrapper, .print-section, .pin-toggle, .copy-btn,
    .output-section p { display: none; }

    /* Kompaktes Layout */
    body        { background: white; padding: 8px; }
    .container  { padding-bottom: 0; }
    .card       { padding: 12px 16px; margin-bottom: 10px; box-shadow: none; border: 1px solid #ccc; }
    h2          { font-size: 1rem; margin-bottom: 8px; padding-bottom: 6px; }
    .result-block   { margin-bottom: 10px; }
    .password-display { padding: 6px 10px; font-size: 1rem; }
    label       { margin-bottom: 4px; font-size: 0.85rem; }

    /* Druckzusammenfassung einblenden */
    #printSummary { display: block; }
    .print-data-table th,
    .print-data-table td { padding: 2px 0; font-size: 0.88rem; }
    .print-data-table { margin-bottom: 10px; }
    .print-secret-row th,
    .print-secret-row td { font-size: 1rem; padding-top: 5px; padding-bottom: 5px; }
    .print-secret-row {
        border-top: 2px solid #000;
        border-bottom: 2px solid #000;
    }
    .output-section { opacity: 1 !important; pointer-events: auto !important; }
    .password-display { border: 1px solid #000; }
}

/* FAQ */
.faq-section {
    border: 1px solid #e0e0e0;
}

.faq-section > summary.faq-summary {
    list-style: none; /* Standard-Dreieck entfernen */
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    padding: 4px 0;
    user-select: none;
}

.faq-section > summary.faq-summary::before {
    content: "▶";
    font-size: 0.75rem;
    color: var(--accent-color);
    transition: transform 0.2s;
    display: inline-block;
}

.faq-section[open] > summary.faq-summary::before {
    transform: rotate(90deg);
}

/* Webkit-Standardmarker entfernen */
.faq-section > summary.faq-summary::-webkit-details-marker { display: none; }

/* Modus-Toggle innerhalb der FAQ */
.faq-mode-toggle {
    display: flex;
    margin-left: auto;
    background: #e9e9eb;
    border-radius: 9px;
    padding: 2px;
    width: fit-content;
}

.faq-mode-toggle button {
    padding: 4px 12px;
    border: none;
    background: transparent;
    color: #555;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 7px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.faq-mode-toggle button.active {
    background: white;
    color: #333;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* Sichtbarkeit der Antwort-Versionen */
.faq-answer-simple { display: none; }

.faq-section.faq-mode-simple .faq-answer-simple   { display: block; }
.faq-section.faq-mode-simple .faq-answer-advanced { display: none; }

.faq-list {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.faq-item {
    border-radius: 8px;
    overflow: hidden;
}

.faq-item > summary {
    list-style: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 10px 14px;
    background-color: var(--input-bg);
    border-radius: 8px;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.faq-item > summary::before {
    content: "▶";
    font-size: 0.65rem;
    color: var(--accent-color);
    transition: transform 0.2s;
    flex-shrink: 0;
}

.faq-item[open] > summary::before {
    transform: rotate(90deg);
}

.faq-item > summary::-webkit-details-marker { display: none; }

.faq-item[open] > summary {
    border-radius: 8px 8px 0 0;
}

.faq-item p,
.faq-item ul {
    margin: 0;
    padding: 12px 14px;
    font-size: 0.92rem;
    line-height: 1.6;
    color: #444;
    background-color: #fafafa;
    border: 1px solid var(--input-bg);
    border-top: none;
}

.faq-item p + p,
.faq-item p + ul,
.faq-item ul + p {
    border-top: 1px solid var(--input-bg);
    padding-top: 8px;
}

.faq-item ul {
    padding-left: 30px;
}

/* Zwischenüberschrift direkt vor ihrer Liste: kein Trenner dazwischen */
.faq-item p.faq-label { padding-bottom: 0; }
.faq-item p.faq-label + ul {
    border-top: none;
    padding-top: 4px;
}

.faq-item[open] > *:last-child {
    border-radius: 0 0 8px 8px;
}

.site-footer {
    margin-top: 10px;
    text-align: center;
    font-size: 0.75rem;
    color: #8e8e93;
}

@media print {
    .faq-section, .site-footer { display: none; }
}

/* Mobile Optimierung */
@media (max-width: 700px) {
    .row { flex-direction: column; gap: 0; }
    .form-group { margin-bottom: 20px; }

    .result-row {
        flex-direction: column;
        gap: 10px;
    }
}
