/**
 * Pedigree Tree Styles
 *
 * Visual box-style pedigree tree with 3 generations
 * Supports both horizontal (desktop) and vertical (mobile) layouts
 */

/* =============================================================================
   Container and Structure
   ============================================================================= */

.pedigree-tree {
    display: flex;
    flex-direction: row;
    gap: 0;
    overflow-x: auto;
    padding: 24px;
    background: linear-gradient(135deg, #f8faf8 0%, #f1f5f1 100%);
    border-radius: 16px;
    border: 1px solid #e5e7eb;
    position: relative;
}

.pedigree-tree::-webkit-scrollbar {
    height: 8px;
}

.pedigree-tree::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.pedigree-tree::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.pedigree-tree::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Generation Columns */
.pedigree-gen {
    display: flex;
    flex-direction: column;
    min-width: 200px;
    position: relative;
    padding: 0 12px;
}

.pedigree-gen:first-child {
    padding-left: 0;
}

.pedigree-gen:last-child {
    padding-right: 0;
}

.pedigree-gen-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    margin-bottom: 12px;
    padding-left: 4px;
}

.pedigree-gen-boxes {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    flex: 1;
    gap: 8px;
}

/* Generation sizing */
.pedigree-gen.gen-0 {
    min-width: 220px;
}

.pedigree-gen.gen-0 .pedigree-gen-boxes {
    justify-content: center;
}

.pedigree-gen.gen-1 {
    min-width: 200px;
}

.pedigree-gen.gen-2 {
    min-width: 180px;
}

.pedigree-gen.gen-3 {
    min-width: 160px;
}

/* =============================================================================
   Pedigree Boxes
   ============================================================================= */

.pedigree-box {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    padding: 12px 14px;
    position: relative;
    transition: all 0.2s ease;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.pedigree-box:hover {
    border-color: #519548;
    box-shadow: 0 4px 12px rgba(81, 149, 72, 0.15);
    transform: translateY(-2px);
}

/* Gender indicators */
.pedigree-box.male {
    border-left: 4px solid #3b82f6;
}

.pedigree-box.female {
    border-left: 4px solid #ec4899;
}

/* External ancestor (dashed border) */
.pedigree-box.external {
    background: #fafafa;
    border-style: dashed;
}

/* Private record */
.pedigree-box.private {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.pedigree-box.private .pedigree-name {
    color: #94a3b8;
    font-style: italic;
}

/* Empty/unknown slot */
.pedigree-box.empty {
    background: #f8fafc;
    border-color: #e2e8f0;
    border-style: dashed;
}

.pedigree-box.empty .pedigree-name {
    color: #94a3b8;
    font-style: italic;
    font-weight: 400;
}

/* Compact mode (for great-grandparents) */
.pedigree-box.compact {
    padding: 8px 10px;
    min-height: 44px;
}

.pedigree-box.compact .pedigree-name {
    font-size: 0.8125rem;
}

.pedigree-box.compact .pedigree-titles {
    font-size: 0.625rem;
}

/* =============================================================================
   Box Content
   ============================================================================= */

.pedigree-titles {
    color: #059669;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.pedigree-name {
    font-weight: 600;
    font-size: 0.9375rem;
    color: #1e293b;
    text-decoration: none;
    display: block;
    line-height: 1.3;
    word-break: break-word;
}

.pedigree-name:hover {
    color: #519548;
}

.pedigree-reg {
    font-size: 0.75rem;
    color: #64748b;
    font-family: 'SF Mono', SFMono-Regular, Consolas, monospace;
    margin-top: 4px;
}

.pedigree-color {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 2px;
}

/* =============================================================================
   Health Test Badges
   ============================================================================= */

.pedigree-health {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.health-badge {
    font-size: 0.625rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    white-space: nowrap;
}

.health-badge.hip {
    background: #dbeafe;
    color: #1e40af;
}

.health-badge.elbow {
    background: #dcfce7;
    color: #166534;
}

.health-badge.eye {
    background: #fef3c7;
    color: #92400e;
}

.health-badge.dna {
    background: #f3e8ff;
    color: #7c3aed;
}

.health-badge.heart {
    background: #fee2e2;
    color: #991b1b;
}

.health-badge.other {
    background: #f1f5f9;
    color: #475569;
}

/* =============================================================================
   Connecting Lines
   ============================================================================= */

.pedigree-gen:not(:last-child)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    width: 12px;
    height: 2px;
    background: #d1d5db;
}

/* Vertical connecting lines between generations */
.pedigree-gen-boxes {
    position: relative;
}

.pedigree-gen.gen-1 .pedigree-gen-boxes::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 25%;
    bottom: 25%;
    width: 2px;
    background: #d1d5db;
}

.pedigree-gen.gen-2 .pedigree-gen-boxes::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 12.5%;
    bottom: 12.5%;
    width: 2px;
    background: #d1d5db;
}

/* =============================================================================
   Empty State
   ============================================================================= */

.pedigree-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    background: #f8fafc;
    border: 2px dashed #e2e8f0;
    border-radius: 16px;
    color: #94a3b8;
    text-align: center;
}

.pedigree-empty i {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

.pedigree-empty p {
    margin: 0;
    font-size: 1rem;
}

/* =============================================================================
   Pedigree Card (container for use on pet.php)
   ============================================================================= */

.pedigree-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    margin-top: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.pedigree-card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 8px;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pedigree-card h2 i {
    color: #519548;
}

.pedigree-card > p {
    color: #64748b;
    font-size: 0.9375rem;
    margin: 0 0 20px;
}

.pedigree-actions {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 12px;
}

/* =============================================================================
   Health Tests Section (for edit/view pages)
   ============================================================================= */

.health-tests-section {
    margin-top: 24px;
}

.health-tests-section h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0 0 16px;
    color: #1e293b;
}

.health-test-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.health-test-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.health-test-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.health-test-type {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
}

.health-test-name {
    font-weight: 500;
    color: #1e293b;
}

.health-test-result {
    font-weight: 600;
    color: #059669;
    font-size: 1.125rem;
}

.health-test-date {
    font-size: 0.75rem;
    color: #94a3b8;
}

.health-test-actions {
    display: flex;
    gap: 8px;
}

.health-test-add {
    margin-top: 12px;
}

/* =============================================================================
   Responsive Design
   ============================================================================= */

@media (max-width: 1024px) {
    .pedigree-tree {
        padding: 16px;
    }

    .pedigree-gen {
        min-width: 160px;
        padding: 0 8px;
    }

    .pedigree-gen.gen-0 {
        min-width: 180px;
    }

    .pedigree-gen.gen-3 {
        min-width: 140px;
    }

    .pedigree-box {
        padding: 10px 12px;
    }

    .pedigree-name {
        font-size: 0.875rem;
    }
}

@media (max-width: 768px) {
    .pedigree-tree {
        flex-direction: column;
        gap: 16px;
    }

    .pedigree-gen {
        min-width: 100% !important;
        padding: 0;
    }

    .pedigree-gen-boxes {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    .pedigree-box {
        flex: 1 1 calc(50% - 4px);
        min-width: 140px;
    }

    .pedigree-gen.gen-3 .pedigree-box {
        flex: 1 1 calc(25% - 6px);
        min-width: 100px;
    }

    /* Hide connecting lines on mobile */
    .pedigree-gen::after,
    .pedigree-gen-boxes::before {
        display: none;
    }

    .pedigree-card {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .pedigree-gen-boxes {
        flex-direction: column;
    }

    .pedigree-box {
        flex: 1 1 100%;
    }

    .pedigree-gen.gen-3 .pedigree-box {
        flex: 1 1 calc(50% - 4px);
    }

    .health-test-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .health-test-result {
        font-size: 1rem;
    }
}

/* =============================================================================
   Print Styles
   ============================================================================= */

@media print {
    .pedigree-tree {
        background: white;
        border: 1px solid #ccc;
        box-shadow: none;
    }

    .pedigree-box {
        break-inside: avoid;
        box-shadow: none;
    }

    .pedigree-box:hover {
        transform: none;
        box-shadow: none;
    }

    .pedigree-actions {
        display: none;
    }
}

/* =============================================================================
   External Ancestor Modal
   ============================================================================= */

.external-ancestor-modal .modal-content {
    border-radius: 16px;
}

.external-ancestor-modal .modal-header {
    background: linear-gradient(135deg, #519548 0%, #3d7038 100%);
    color: white;
    border-radius: 16px 16px 0 0;
    padding: 20px 24px;
}

.external-ancestor-modal .modal-title {
    font-weight: 600;
}

.external-ancestor-modal .modal-body {
    padding: 24px;
}

.external-ancestor-modal .form-section {
    margin-bottom: 24px;
}

.external-ancestor-modal .form-section h6 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e5e7eb;
}

.gender-selector {
    display: flex;
    gap: 12px;
}

.gender-option {
    flex: 1;
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.gender-option:hover {
    border-color: #94a3b8;
}

.gender-option.selected.male {
    border-color: #3b82f6;
    background: #eff6ff;
}

.gender-option.selected.female {
    border-color: #ec4899;
    background: #fdf2f8;
}

.gender-option i {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.gender-option.male i {
    color: #3b82f6;
}

.gender-option.female i {
    color: #ec4899;
}

.gender-option span {
    display: block;
    font-weight: 500;
    font-size: 0.875rem;
}
