/* ==========================================================================
   1. LAYOUT & HAUPTSTRUKTUR (Bildschirm-Ansicht)
   ========================================================================== */

.wcc-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: #f3f6fb; /* etwas softeres Grau-Blau */
    padding: 20px;
    box-sizing: border-box;
}

/* Info-Bar oben */
.wcc-info-bar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 10px;
    gap: 10px;
}

.wcc-info-button {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 999px;
    border: 1px solid #f59e0b;
    background: #fffbeb;
    color: #92400e;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.wcc-info-button:hover {
    background: #fef3c7;
}

.wcc-info-box {
    flex: 1;
    font-size: 12px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 6px;
    padding: 6px 10px;
    color: #92400e;
}

/* Linke Spalte: Eingaben */
.wcc-input-column {
    flex: 0 0 320px;
    background: #ffffff;
    border: 1px solid #d4dbea;
    padding: 20px;
    height: 85vh;
    overflow-y: auto;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
    border-radius: 8px;
}

.wcc-meta-inputs input {
    width: 100%;
    margin-bottom: 15px;
    padding: 8px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 13px;
}

/* Ahnen-Eingabe-Liste */
.wcc-field-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 5px;
    padding: 4px 6px;
    border-radius: 4px;
    transition: background 0.15s ease, border-left-color 0.15s ease;
}

.wcc-field-group.active {
    background: #e0f2fe;
    border-left: 4px solid #0369a1;
}

.field-num {
    font-size: 11px;
    color: #94a3b8;
    width: 32px;
    flex-shrink: 0;
    margin-bottom: 2px;
}

/* Hauptzeile: Name + Detail-Button */
.wcc-field-main {
    display: flex;
    gap: 6px;
    align-items: center;
    width: 100%;
}

.dog-input {
    width: 100%;
    border: 1px solid #e2e8f0;
    padding: 4px 8px;
    font-size: 13px;
    border-radius: 3px;
    box-sizing: border-box;
    background: #f8fafc;
}
.dog-input:focus {
    border-color: #0ea5e9;
    background: #ffffff;
    outline: none;
}

/* Detail-Toggle-Button */
.wcc-detail-toggle {
    padding: 3px 8px;
    font-size: 11px;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #eef2ff;
    color: #4338ca;
    cursor: pointer;
    white-space: nowrap;
}
.wcc-detail-toggle:hover {
    background: #e0e7ff;
}

/* Detail-Textarea-Wrapper */
.wcc-detail-wrap {
    margin-top: 4px;
    width: 100%;
}

.dog-detail {
    width: 100%;
    min-height: 50px;
    font-size: 11px;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
    padding: 4px 6px;
    resize: vertical;
    box-sizing: border-box;
}

/* Rechte Spalte: Visualisierung */
.wcc-visual-column {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
}

.wcc-sticky-panel {
    position: sticky;
    top: 20px;
}

/* Toolbar / Buttons / COI-Anzeige */
.wcc-toolbar {
    background: #ffffff;
    padding: 10px 20px;
    border: 1px solid #d4dbea;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.04);
}

.wcc-result-box {
    font-weight: 600;
    font-size: 16px;
    color: #0f172a;
}

#coi-value {
    color: #e11d48;
    margin-left: 5px;
    font-size: 20px;
}

.wcc-result-sublabel {
    font-size: 11px;
    color: #6b7280;
    margin-left: 6px;
}

/* AVK-Box in Toolbar */
.wcc-avk-box {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    margin-left: 20px;
    margin-right: auto;
}
.wcc-avk-box label {
    color: #4b5563;
}
.wcc-avk-box select {
    font-size: 12px;
    padding: 2px 4px;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #f9fafb;
}
#avk-value {
    font-weight: 600;
    color: #1d4ed8;
    margin-left: 4px;
}

/* Bibliothek in der Toolbar */
.wcc-lib-panel {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    flex-wrap: wrap;
}

.wcc-lib-name-input {
    min-width: 180px;
    max-width: 220px;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #f9fafb;
    font-size: 12px;
}

.wcc-lib-select {
    min-width: 220px;
    max-width: 260px;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    font-size: 12px;
}

/* Versions-Badge */
.wcc-version-pill {
    font-size: 10px;
    background: #e2e8f0;
    color: #475569;
    padding: 2px 8px;
    border-radius: 999px;
}
.wcc-version-loaded {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* Buttons */
.wcc-btn {
    padding: 8px 15px;
    cursor: pointer;
    border-radius: 999px;
    font-size: 14px;
    border: none;
    transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.wcc-btn:active {
    transform: translateY(1px);
    box-shadow: none;
}

.primary {
    background: #0f766e;
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(15, 118, 110, 0.3);
}
.primary:hover {
    background: #0d9488;
}

.secondary {
    background: #0f172a;
    color: #f9fafb;
}
.secondary:hover {
    background: #020617;
}

.outline {
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #475569;
}
.outline:hover {
    background: #e2e8f0;
}

/* Analyse Details Box */
#wcc-analysis-details {
    background: #ffffff;
    border: 1px solid #d4dbea;
    padding: 15px;
    margin-bottom: 20px;
    max-height: 260px;
    overflow-y: auto;
    display: none;
    border-radius: 8px;
}
#wcc-analysis-details h4 {
    margin-top: 0;
    font-size: 15px;
    color: #0f172a;
}

/* Pfad-Einträge */
.path-item {
    font-size: 12px;
    border-left: 3px solid #e2e8f0;
    padding: 8px 8px 8px 10px;
    margin: 4px 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: #f8fafc;
    border-radius: 4px;
}
.path-item:nth-child(odd) {
    background: #f1f5f9;
}
.path-name { 
    font-weight: 600; 
    color: #be123c; 
}
.path-info { 
    color: #4b5563; 
    font-size: 11px; 
}
.path-value { 
    font-weight: 600; 
    color: #0369a1; 
    font-size: 11px;
}

/* ==========================================================================
   2. SCREEN PEDIGREE CANVAS (Bildschirm-Ansicht)
   ========================================================================== */

.pedigree-canvas {
    background: #ffffff;
    padding: 20px;
    border: 1px solid #d4dbea;
    width: 100%;
    min-width: 900px;
    overflow-x: auto;
    box-sizing: border-box;
    border-radius: 10px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.pedigree-header-info {
    text-align: center;
    border-bottom: 2px solid #0f172a;
    padding-bottom: 10px;
    margin-bottom: 12px;
}
.pedigree-header-info h2 {
    margin: 0;
    font-size: 20px;
    letter-spacing: 0.03em;
}
.pedigree-header-info p {
    margin: 4px 0 0;
    font-size: 12px;
    color: #4b5563;
}

/* viel Höhe für den Stammbaum */
.tree-grid {
    display: flex;
    justify-content: space-between;
    height: 2000px;
}

/* zarte Hintergrundnuancen je Generation */
.gen-col {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    flex: 1;
    margin: 0 3px;
}
.gen-1 { background: linear-gradient(to bottom, #e0f2fe 0, #eff6ff 100%); }
.gen-2 { background: linear-gradient(to bottom, #fef9c3 0, #fffbeb 100%); }
.gen-3 { background: linear-gradient(to bottom, #fce7f3 0, #fdf2ff 100%); }
.gen-4 { background: linear-gradient(to bottom, #dcfce7 0, #f0fdf4 100%); }
.gen-5 { background: #f8fafc; }
.gen-6 { background: #f1f5f9; }

.tree-node {
    border: 1px solid rgba(148, 163, 184, 0.7);
    background: rgba(255, 255, 255, 0.9);
    margin: 2px 0;
    padding: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    overflow: hidden;
    height: 100%;
    border-radius: 4px;
    cursor: pointer;
    box-sizing: border-box;
    transition: transform 0.1s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.gen-1 .tree-node, .gen-2 .tree-node { font-size: 16px; }
.gen-3 .tree-node { font-size: 14px; }
.gen-4 .tree-node { font-size: 12px; }
.gen-5 .tree-node { font-size: 11px; }

.tree-node:hover {
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.15);
    transform: translateY(-1px);
}

.tree-node.active {
    background-color: #fef3c7;
    border-color: #f59e0b;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3);
}

.tree-node.duplicate {
    background-color: #fee2e2 !important;
    border-color: #ef4444;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.25);
}

/* doppelte Ahnen, die NICHT in den COI eingehen – schraffiert */
.tree-node.duplicate-blocked {
    border-color: #ef4444;
    background-image: repeating-linear-gradient(
        135deg,
        rgba(239, 68, 68, 0.20),
        rgba(239, 68, 68, 0.20) 3px,
        rgba(255, 255, 255, 0.95) 3px,
        rgba(255, 255, 255, 0.95) 6px
    );
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15);
}

.node-content {
    width: 100%;
    z-index: 2;
}

.node-name {
    font-weight: 600;
    display: block;
    line-height: 1.2;
    color: #111827;
}

.node-id {
    font-size: 0.75em;
    color: #94a3b8;
    display: block;
    margin-bottom: 2px;
}

/* Bildbereich 4:3 */
.node-img {
    width: 80%;
    aspect-ratio: 4 / 3;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    margin-bottom: 2px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed #cbd5e1;
}

.node-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.node-file-input { display: none; }

.upload-label {
    cursor: pointer;
    color: #4b5563;
    font-size: 24px;
    font-weight: bold;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(248, 250, 252, 0.7);
    transition: background 0.15s ease, color 0.15s ease;
    z-index: 100;
}
.upload-label:hover {
    background: rgba(255, 255, 255, 0.9);
    color: #111827;
}

/* Gen 6: Name sichtbar, bei Platzmangel abgeschnitten */

.gen-6 .tree-node {
    font-size: 10px;                /* Text wieder sichtbar */
    border: 1px solid #cbd5e1;
    background: #e5e7eb;
    padding: 2px 4px;
    white-space: nowrap;            /* alles in einer Zeile */
    overflow: hidden;               /* überstehender Text wird abgeschnitten */
    text-overflow: ellipsis;        /* … am Ende */
}

/* optional: Desktop-Tooltip mit vollem Namen */
@media (min-width: 900px) {
    .gen-6 .tree-node:hover {
        background: #9ca3af;
    }
    .gen-6 .tree-node:hover::after {
        content: attr(data-name);
        position: absolute;
        right: 30px;
        background: #111827;
        color: #f9fafb;
        padding: 4px 6px;
        font-size: 11px;
        border-radius: 3px;
        white-space: nowrap;
        z-index: 200;
    }


.pedigree-footer {
    font-size: 12px;
    color: #6b7280;
    text-align: right;
    margin-top: 6px;
    border-top: 1px solid #e5e7eb;
}

/* ================================================================
   Responsive: Smartphone / kleine Tablets
   ================================================================ */

@media (max-width: 900px) {
    .wcc-wrapper {
        flex-direction: column;
        padding: 8px;
        overflow: hidden;
    }

    .wcc-input-column {
        flex: 1 1 auto;
        height: auto;
        max-height: 40vh;
        margin-bottom: 15px;
        width: 100%;
    }

    .wcc-sticky-panel {
        position: static;
    }

    .wcc-visual-column {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .pedigree-canvas {
        min-width: 900px;
        margin-right: 0;
        transform-origin: top left;
    }

    .tree-grid {
        height: 1800px;
        width: 100%;
    }
    
    .tree-node {
        padding: 2px;
    }
}

/* ==================================================================
   3. PDF EXPORT STYLES
   ================================================================== */

.pdf-page {
    width: 210mm;
    height: 296mm;
    background: #ffffff;
    padding: 15mm;
    box-sizing: border-box;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    position: relative;
    display: block;
    overflow: hidden;
}

.pdf-header {
    text-align: center;
    border-bottom: 2px solid #111827;
    margin-bottom: 5mm;
    padding-bottom: 5px;
    width: 100%;
}
.pdf-header h1 { 
    margin: 0; 
    font-size: 18px; 
    text-transform: uppercase; 
    color: #111827; 
}
.pdf-header p { 
    margin: 5px 0 0; 
    font-size: 14px; 
    color: #4b5563; 
}

.pdf-footer {
    position: absolute;
    bottom: 10mm;
    right: 15mm;
    left: 15mm;
    text-align: right;
    border-top: 1px solid #e5e7eb;
    padding-top: 5px;
    font-size: 12px;
    color: #6b7280;
}

/* PDF Seite 1/2: Baum */
.pdf-tree-container {
    width: 100%;
    height: 235mm;
    overflow: hidden;
}

.pdf-gen-col {
    float: left;
    width: 25%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    padding-right: 2mm;
    box-sizing: border-box;
}
.pdf-gen-col:last-child { padding-right: 0; }

.pdf-node {
    border: 1px solid #1f2937;
    border-radius: 2px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
    width: 100%;
    margin: 1px 0;
    height: 100%;
}

.pdf-node.duplicate { 
    background: #fee2e2; 
    border-color: #b91c1c; 
}

.pdf-node-name {
    font-weight: 600;
    line-height: 1.1;
    margin-bottom: 1px;
    color: #111827;
    padding: 0 2px;
}

.pdf-node-id {
    font-size: 8px;
    color: #6b7280;
    position: absolute;
    top: 0;
    left: 2px;
}

/* PDF: Detailtext in der zweiten Ahnentafel */
.pdf-node-detail {
    margin-top: 2px;
    padding: 1px 2px 2px;
    font-size: 12px;
    line-height: 1.2;
    color: #374151;
    border-top: 1px solid #e5e7eb;
    text-align: left;
    width: 95%;
}

/* Bilder im PDF */
.pdf-node-img {
    width: 90%;
    background: #f3f4f6;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e5e7eb;
    margin-bottom: 2px;
    flex-shrink: 0;
}
.pdf-node-img img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
}

/* Bildgrößen / Schriftgrößen im PDF */
.pg-gen-3 .pdf-node-img {
    height: 90%;
    width: auto;
    aspect-ratio: 4/3;
}
.pg-gen-4 .pdf-node-img {
    height: 90%;
    width: auto;
    aspect-ratio: 4/3;
}

.pg-gen-1 .pdf-node { font-size: 14px; }
.pg-gen-2 .pdf-node { font-size: 14px; }
.pg-gen-3 .pdf-node { font-size:12px; }
.pg-gen-4 .pdf-node { font-size: 12px; }

/* PDF Seite 2/3: Pfade & Listen */

.pdf-analysis-box {
    border: 1px solid #fecaca;
    background: #fef2f2;
    padding: 3mm;
    margin-bottom: 4mm;
    font-size: 12px;
}
.pdf-analysis-box h3 { 
    margin: 0 0 2mm 0; 
    font-size: 12px; 
    color: #b91c1c; 
}
.pdf-analysis-content ul { 
    padding-left: 3mm; 
    margin: 0; 
}
.pdf-analysis-content li { 
    margin-bottom: 1mm; 
}

.pdf-list-grid {
    width: 100%;
    overflow: hidden;
}

.pdf-sub-section {
    float: left;
    width: 48%;
    margin-right: 2%;
}
.pdf-sub-section:last-child { margin-right: 0; }

.pdf-sub-section h3 {
    font-size: 12px;
    border-bottom: 1px solid #111827;
    margin: 0 0 5mm 0;
    text-transform: uppercase;
}

.pdf-ancestor-block {
    border: 1px solid #e5e7eb;
    margin-bottom: 2px;
    padding: 2px;
    background: #ffffff;
    font-size: 12px;
}
.pdf-ancestor-block.duplicate { 
    background: #fee2e2; 
}

.pdf-a-gen5 { 
    font-weight: 600; 
    display: block; 
    background: #f9fafb; 
    padding: 1px; 
    color: #111827; 
}
.pdf-a-gen6-group { 
    margin-left: 5px; 
    border-left: 2px solid #e5e7eb; 
    padding-left: 3px; 
    margin-top: 1px; 
}
.pdf-a-gen6 { 
    display: block; 
    color: #4b5563; 
}

/* PDF Seite 3: Detail-Texte (falls genutzt) */

.pdf-detail-block {
    border: 1px solid #e5e7eb;
    margin-bottom: 3px;
    padding: 3px;
    background: #ffffff;
    font-size: 14px;
}

.pdf-detail-block-title {
    font-weight: 600;
    margin-bottom: 2px;
    color: #111827;
}

.pdf-detail-block-text {
    color: #4b5563;
}
