/**
 * Creador de árbol genealógico interactivo - Estilos visuales
 * Fijate Tools - Estándares Canónicos
 */

:root {
    --bg-page: #0b0f17;
    --bg-card: rgba(17, 24, 39, 0.85);
    --bg-card-solid: #111827;
    --bg-card-hover: #1f2937;
    --bg-elevated: #1e293b;
    --bg-canvas: #090d16;
    --border-color: #334155;
    --border-subtle: rgba(51, 65, 85, 0.6);
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    --accent-blue: #3b82f6;
    --accent-blue-hover: #2563eb;
    --accent-blue-subtle: rgba(59, 130, 246, 0.15);

    --accent-gold: #f59e0b;
    --accent-gold-subtle: rgba(245, 158, 11, 0.15);

    --accent-emerald: #10b981;
    --accent-emerald-subtle: rgba(16, 185, 129, 0.15);

    --accent-rose: #f43f5e;
    --accent-rose-subtle: rgba(244, 63, 94, 0.15);

    --accent-purple: #a855f7;

    --gender-male: #38bdf8;
    --gender-male-bg: rgba(56, 189, 248, 0.12);
    --gender-female: #f472b6;
    --gender-female-bg: rgba(244, 114, 182, 0.12);
    --gender-other: #a3e635;
    --gender-other-bg: rgba(163, 230, 53, 0.12);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.6);
    --shadow-node: 0 4px 12px rgba(0, 0, 0, 0.35);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-heading: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
}

[data-theme="light"] {
    --bg-page: #f1f5f9;
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-card-solid: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-elevated: #e2e8f0;
    --bg-canvas: #f8fafc;
    --border-color: #cbd5e1;
    --border-subtle: rgba(203, 213, 225, 0.8);
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;

    --gender-male: #0284c7;
    --gender-male-bg: rgba(2, 132, 199, 0.1);
    --gender-female: #db2777;
    --gender-female-bg: rgba(219, 39, 119, 0.1);
    --gender-other: #65a30d;
    --gender-other-bg: rgba(101, 163, 13, 0.1);

    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.12);
    --shadow-node: 0 4px 12px rgba(15, 23, 42, 0.08);
}

/* Reset de contención */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    overflow-x: clip;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Tipografía de encabezados */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: -0.015em;
}

/* Layout canónico */
.tool-layout {
    max-width: 1200px;
    margin: 1.5rem auto 3rem;
    padding: 0 1rem;
    width: 100%;
    flex: 1;
}

.tool-with-sidebar {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.tool-main-content {
    flex: 1 1 0%;
    min-width: 0;
    max-width: 100%;
}

/* Tarjeta principal contenedora */
.card-main {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    backdrop-filter: blur(12px);
    margin-bottom: 2rem;
}

/* Barra de control superior */
.genealogy-controls-bar {
    padding: 1rem 1.25rem;
    background: var(--bg-card-solid);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
}

.controls-left,
.controls-right {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

/* Grupo selector de presets */
.preset-selector-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.preset-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.select-custom {
    height: 40px;
    padding: 0 36px 0 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--bg-elevated);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color 0.2s, background-color 0.2s;
    max-width: 280px;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}

.select-custom option {
    background-color: var(--bg-card-solid);
    color: var(--text-primary);
}

.select-custom:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--accent-blue-subtle);
}

/* Botones de acción canónicos */
.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    height: 40px;
    padding: 0 1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
    background: var(--bg-elevated);
    color: var(--text-primary);
    white-space: nowrap;
    text-decoration: none;
}

.btn-action:hover {
    background: var(--bg-card-hover);
    border-color: var(--text-muted);
    transform: translateY(-1px);
}

.btn-action:active {
    transform: translateY(0);
}

.btn-action-primary {
    background: var(--accent-blue);
    border-color: var(--accent-blue-hover);
    color: #ffffff;
}

.btn-action-primary:hover {
    background: var(--accent-blue-hover);
    border-color: var(--accent-blue-hover);
    color: #ffffff;
}

.btn-action-success {
    background: var(--accent-emerald);
    border-color: #059669;
    color: #ffffff;
}

.btn-action-success:hover {
    background: #059669;
    color: #ffffff;
}

.btn-action-gold {
    background: var(--accent-gold);
    border-color: #d97706;
    color: #ffffff;
}

.btn-action-gold:hover {
    background: #d97706;
    color: #ffffff;
}

/* Barra de búsqueda de personas */
.search-person-wrapper {
    position: relative;
    width: 220px;
}

.search-person-input {
    width: 100%;
    height: 40px;
    padding: 0 32px 0 34px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--bg-elevated);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: var(--font-sans);
    transition: all 0.2s;
}

.search-person-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    background-color: var(--bg-card-solid);
    box-shadow: 0 0 0 3px var(--accent-blue-subtle);
}

.search-icon-left {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-muted);
}

.search-clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: none;
}

.search-clear-btn:hover {
    color: var(--text-primary);
}

.search-results-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-card-solid);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    max-height: 240px;
    overflow-y: auto;
    z-index: 50;
    display: none;
}

.search-result-item {
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border-subtle);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--bg-elevated);
}

/* Contenedor del Lienzo Infinito */
.canvas-viewport-container {
    position: relative;
    width: 100%;
    height: 640px;
    background-color: var(--bg-canvas);
    background-image:
        radial-gradient(circle at 1px 1px, var(--border-subtle) 1px, transparent 0);
    background-size: 24px 24px;
    overflow: hidden;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.canvas-viewport-container.is-dragging {
    cursor: grabbing;
}

.canvas-viewport-container.is-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1000;
    border-radius: 0;
}

/* Plano de transformación del mundo */
.canvas-world-layer {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    will-change: transform;
}

/* Capa de conectores SVG */
.canvas-svg-layer {
    position: absolute;
    top: 0;
    left: 0;
    overflow: visible;
    pointer-events: none;
    z-index: 1;
}

.tree-link-path {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 2.2px;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: stroke 0.2s;
}

.tree-link-marriage {
    stroke: var(--accent-gold);
    stroke-dasharray: 4 2;
}

.tree-marriage-node {
    fill: var(--bg-card-solid);
    stroke: var(--accent-gold);
    stroke-width: 2px;
}

.tree-marriage-icon {
    font-size: 11px;
    text-anchor: middle;
    dominant-baseline: central;
    fill: var(--accent-gold);
}

/* Capa de tarjetas de personas */
.canvas-nodes-layer {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
}

/* Tarjeta individual de persona */
.tree-node-card {
    position: absolute;
    width: 220px;
    height: 120px;
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    box-shadow: var(--shadow-node);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    backdrop-filter: blur(8px);
    overflow: hidden;
}

.tree-node-card:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
    border-color: var(--accent-blue);
    z-index: 10;
}

.tree-node-card.is-selected {
    border-color: var(--accent-emerald) !important;
    box-shadow: 0 0 0 3px var(--accent-emerald-subtle), 0 8px 20px rgba(0, 0, 0, 0.5);
    z-index: 12;
}

.tree-node-card.is-root {
    border-color: var(--accent-gold);
}

/* Borde de género superior o lateral */
.tree-node-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 4px;
    background: var(--text-muted);
}

.tree-node-card.gender-m::before {
    background: var(--gender-male);
}

.tree-node-card.gender-f::before {
    background: var(--gender-female);
}

.tree-node-card.gender-o::before {
    background: var(--gender-other);
}

/* Cabecera de la tarjeta: Avatar + Datos principales */
.node-card-top {
    display: flex;
    gap: 0.65rem;
    align-items: center;
}

.node-avatar-box {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 2px solid var(--border-color);
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.tree-node-card.gender-m .node-avatar-box {
    border-color: var(--gender-male);
    background: var(--gender-male-bg);
}

.tree-node-card.gender-f .node-avatar-box {
    border-color: var(--gender-female);
    background: var(--gender-female-bg);
}

.tree-node-card.gender-o .node-avatar-box {
    border-color: var(--gender-other);
    background: var(--gender-other-bg);
}

.node-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.node-avatar-svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
    color: var(--text-muted);
}

.tree-node-card.gender-m .node-avatar-svg {
    color: var(--gender-male);
}

.tree-node-card.gender-f .node-avatar-svg {
    color: var(--gender-female);
}

.node-info-col {
    flex: 1;
    min-width: 0;
}

.node-fullname {
    font-family: var(--font-heading);
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.node-relationship-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    margin-top: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.tree-node-card.is-root .node-relationship-badge {
    background: var(--accent-gold-subtle);
    color: var(--accent-gold);
    font-weight: 700;
}

/* Pie de la tarjeta: Años, profesión y estado vital */
.node-card-bottom {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    font-size: 0.72rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-subtle);
    padding-top: 0.4rem;
}

.node-dates {
    font-family: var(--font-mono);
    font-weight: 500;
}

.node-deceased-badge {
    font-size: 0.65rem;
    color: var(--text-muted);
    opacity: 0.85;
}

/* Botonera de acciones rápidas sobre la tarjeta */
.node-hover-actions {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    gap: 3px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    background: rgba(17, 24, 39, 0.9);
    padding: 2px 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.tree-node-card:hover .node-hover-actions {
    opacity: 1;
    pointer-events: auto;
}

.btn-card-action {
    background: none;
    border: none;
    color: var(--text-secondary);
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-card-action:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.btn-card-action-add:hover {
    color: var(--accent-emerald);
}

.btn-card-action-edit:hover {
    color: var(--accent-blue);
}

/* Barra flotante de navegación del viewport (Zoom / Paneo) */
.canvas-viewport-toolbar {
    position: absolute;
    bottom: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 6px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
    z-index: 40;
}

.btn-viewport-tool {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-elevated);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-viewport-tool:hover {
    background: var(--bg-card-hover);
    border-color: var(--text-muted);
}

.zoom-level-indicator {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    text-align: center;
    color: var(--text-muted);
    padding: 2px 0;
}

/* Indicador de ayuda táctil en el canvas */
.canvas-hint-pill {
    position: absolute;
    bottom: 16px;
    left: 16px;
    background: rgba(17, 24, 39, 0.85);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    padding: 0.4rem 0.85rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.45rem;
    pointer-events: none;
    backdrop-filter: blur(6px);
    z-index: 30;
}

[data-theme="light"] .canvas-hint-pill {
    background: rgba(255, 255, 255, 0.9);
}

/* Modales canónicos accesibles */
.genealogy-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.genealogy-modal-overlay.is-active {
    opacity: 1;
    pointer-events: auto;
}

.genealogy-modal-card {
    background: var(--bg-card-solid);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.25s ease;
    overflow: hidden;
}

.genealogy-modal-overlay.is-active .genealogy-modal-card {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.btn-modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background: var(--bg-card);
}

/* Campos del formulario de edición */
.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-input,
.form-textarea {
    width: 100%;
    min-height: 40px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--bg-elevated);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.88rem;
    transition: all 0.2s;
}

.form-textarea {
    min-height: 80px;
    padding: 10px 12px;
    resize: vertical;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--accent-blue-subtle);
}

/* Selector segmentado de género */
.gender-toggle-group {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
}

.gender-toggle-btn {
    height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    transition: all 0.2s;
}

.gender-toggle-btn:hover {
    border-color: var(--text-muted);
}

.gender-toggle-btn.is-active[data-gender="M"] {
    background: var(--gender-male-bg);
    border-color: var(--gender-male);
    color: var(--gender-male);
}

.gender-toggle-btn.is-active[data-gender="F"] {
    background: var(--gender-female-bg);
    border-color: var(--gender-female);
    color: var(--gender-female);
}

.gender-toggle-btn.is-active[data-gender="O"] {
    background: var(--gender-other-bg);
    border-color: var(--gender-other);
    color: var(--gender-other);
}

/* Selector de avatar y subida de foto */
.avatar-picker-section {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.avatar-preview-box {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: var(--bg-elevated);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.avatar-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-actions-col {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

/* Interruptor de fallecido */
.switch-wrapper {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    cursor: pointer;
    user-select: none;
}

.switch-checkbox {
    display: none;
}

.switch-track {
    width: 44px;
    height: 24px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    position: relative;
    transition: background 0.2s, border-color 0.2s;
}

.switch-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
}

.switch-checkbox:checked + .switch-track {
    background: var(--accent-rose);
    border-color: var(--accent-rose);
}

.switch-checkbox:checked + .switch-track .switch-thumb {
    transform: translateX(20px);
}

/* Menú flotante de añadir familiar */
.add-relation-menu {
    position: absolute;
    background: var(--bg-card-solid);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    z-index: 100;
    min-width: 190px;
    backdrop-filter: blur(12px);
}

.relation-menu-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s;
}

.relation-menu-btn:hover {
    background: var(--bg-elevated);
    color: var(--accent-blue);
}

/* Panel de estadísticas (modal) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.stat-box {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent-blue);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.stats-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.stats-list-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border-subtle);
}

.stats-list-item:last-child {
    border-bottom: none;
}

/* Sección didáctica SEO inferior */
.genealogy-editorial-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-md);
    margin-top: 2.5rem;
}

.editorial-header {
    text-align: center;
    max-width: 720px;
    margin: 0 auto 2.5rem;
}

.editorial-title {
    font-size: 1.8rem;
    margin-bottom: 0.75rem;
}

.editorial-desc {
    color: var(--text-muted);
    font-size: 1rem;
}

.editorial-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2rem;
    margin-bottom: 2.5rem;
}

.editorial-card {
    background: var(--bg-card-solid);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.editorial-card-title {
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.editorial-card-text {
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Tabla de fuentes de investigación genealógica */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin: 1rem 0;
}

.genealogy-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    text-align: left;
}

.genealogy-table th,
.genealogy-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.genealogy-table th {
    background: var(--bg-elevated);
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--text-primary);
}

.genealogy-table tr:last-child td {
    border-bottom: none;
}

/* Bloque FAQ */
.faq-section {
    margin-top: 2rem;
}

.faq-item {
    border-bottom: 1px solid var(--border-color);
    padding: 1.2rem 0;
}

.faq-item:last-child {
    border-bottom: none;
}

.faq-question {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.faq-answer {
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Banner de privacidad cliente */
.privacy-badge-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    background: var(--accent-emerald-subtle);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--text-primary);
    font-size: 0.88rem;
    margin-top: 1.5rem;
}

.privacy-badge-banner strong {
    color: var(--accent-emerald);
}

/* Responsividad en dispositivos móviles */
@media (max-width: 900px) {
    .editorial-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .tool-layout {
        margin: 1rem auto 2rem;
        padding: 0 0.75rem;
    }

    .genealogy-controls-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .controls-left,
    .controls-right {
        width: 100%;
        justify-content: space-between;
    }

    .preset-selector-group {
        width: 100%;
    }

    .select-custom {
        max-width: 100%;
        flex: 1;
    }

    .search-person-wrapper {
        width: 100%;
    }

    .canvas-viewport-container {
        height: 520px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}
