/**
 * Copyright (c) 2026 DNA Genics, S.L. All rights reserved.
 * 
 * Shared Sample Drawer CSS - Reusable modal drawer for displaying SampleMasterData.
 * Responsive animation: slides from right on desktop, slides up from bottom on mobile.
 * Supports CSS variable theming via cssPrefix.
 */

/* ========================================
   CSS VARIABLES (Default Theme)
   ======================================== */

:root {
    --sample-drawer-accent: #B8956A;
    --sample-drawer-accent-light: #D4C4A8;
    --sample-drawer-accent-dark: #8B6D4F;
    --sample-drawer-bg: #1A1C1E;
    --sample-drawer-header-bg: #0D0D0F;
    --sample-drawer-text: #E5E0D8;
    --sample-drawer-text-muted: #A89F91;
    --sample-drawer-border: rgba(168, 159, 145, 0.2);

    /* Header gradient + text color. Default mirrors the accent gradient below with dark text.
       Reports with a distinct header identity (e.g. a primary brand color unrelated to the
       accent color) can override just these three variables via a themed wrapper class
       instead of restyling the whole header. */
    --sample-drawer-header-bg-start: var(--sample-drawer-accent-dark);
    --sample-drawer-header-bg-end: var(--sample-drawer-accent);
    --sample-drawer-header-text: var(--sample-drawer-header-bg);
}

.ancient-modern-genetics-summary,
.ancient-modern-genetics-loading {
    color: var(--sample-drawer-text-muted, #A89F91);
    font-size: 0.9rem;
    line-height: 1.55;
    margin-bottom: 0.9rem;
}

.ancient-modern-genetics-summary {
    margin-bottom: 0;
}

.ancient-modern-genetics-list-label {
    color: var(--sample-drawer-text, #E5E0D8);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    margin-bottom: 0.45rem;
    text-transform: uppercase;
}

.ancient-modern-genetics-list {
    list-style: none;
    margin: 0 0 0.9rem;
    padding: 0;
}

.ancient-modern-genetics-list li {
    border-bottom: 1px solid var(--sample-drawer-border, rgba(168, 159, 145, 0.2));
    color: var(--sample-drawer-text, #E5E0D8);
    display: flex;
    font-size: 0.9rem;
    justify-content: space-between;
    padding: 0.4rem 0;
}

.ancient-modern-genetics-list li span:last-child {
    color: var(--sample-drawer-text-muted, #A89F91);
    font-variant-numeric: tabular-nums;
}

.ancient-modern-genetics-regions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 1rem 0;
}

.ancient-modern-genetics-regions span {
    background: rgba(184, 149, 106, 0.15);
    border: 1px solid var(--sample-drawer-border, rgba(168, 159, 145, 0.2));
    border-radius: 1rem;
    color: var(--sample-drawer-text, #E5E0D8);
    font-size: 0.78rem;
    padding: 0.2rem 0.55rem;
}

/* ========================================
   DRAWER CONTAINER & BACKDROP
   ======================================== */

body.drawer-open {
    overflow: hidden;
}

.dna-sample-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
}

.dna-sample-drawer.open {
    display: block;
}

.dna-sample-drawer-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

/* ========================================
   DRAWER PANEL - DESKTOP (Slide from Right)
   ======================================== */

.dna-sample-drawer-panel {
    position: absolute;
    top: 0;
    left: auto;
    right: 0;
    width: 100%;
    max-width: 500px;
    height: 100%;
    background: var(--sample-drawer-bg, #1A1C1E);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.dna-sample-drawer.open .dna-sample-drawer-panel {
    transform: translateX(0);
}

/* ========================================
   DRAWER HEADER
   ======================================== */

.dna-sample-drawer-header {
    padding: 20px 24px;
    background: linear-gradient(135deg, var(--sample-drawer-header-bg-start, var(--sample-drawer-accent-dark, #8B6D4F)), var(--sample-drawer-header-bg-end, var(--sample-drawer-accent, #B8956A)));
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.dna-sample-drawer-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--sample-drawer-header-text, var(--sample-drawer-header-bg, #0D0D0F));
    margin: 0;
}

.dna-sample-drawer-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: var(--sample-drawer-header-text, var(--sample-drawer-header-bg, #0D0D0F));
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.dna-sample-drawer-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ========================================
   DRAWER BODY
   ======================================== */

.dna-sample-drawer-body {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    color: var(--sample-drawer-text, #E5E0D8);
}

/* ========================================
   DRAWER CONTENT SECTIONS
   ======================================== */

/* Portrait Section */
.sample-drawer-portrait {
    text-align: center;
    margin: 1.5rem 0;
    padding: 0 1rem;
}

.sample-drawer-portrait img {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--sample-drawer-accent, #B8956A);
}

/* AI-generated portrait disclosure note, independent of the auto-attached marker on the
   image itself. Text sourced from Common/AiLegalDisclaimer.cs (ImageShortNotice). */
.sample-drawer-portrait-note {
    max-width: 280px;
    margin: 0.6rem auto 0;
    font-size: 0.7rem;
    line-height: 1.4;
    color: var(--sample-drawer-text, #E5E0D8);
    opacity: 0.65;
}

/* Sample ID and Location Header */
.sample-drawer-info {
    text-align: center;
    margin-bottom: 1.5rem;
    padding: 0 1rem;
}

.sample-drawer-info h3 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.5rem;
    color: var(--sample-drawer-text, #E5E0D8);
    margin: 0 0 0.5rem;
    font-weight: 600;
}

.sample-drawer-info p {
    color: var(--sample-drawer-text-muted, #A89F91);
    margin: 0;
    font-size: 0.9375rem;
}

.sample-drawer-info i,
.sample-drawer-info .dna-icon {
    color: var(--sample-drawer-accent, #B8956A);
}

/* Secondary "Sample ID" (AADR accession) badge shown additively next to the descriptive
   display label. Theme-adaptive via currentColor/inherit so it works on both light and
   dark/cinematic report themes; see docs/development/ancient-sample-public-identifier.md. */
.dna-accession-badge {
    display: inline-block;
    font-family: 'Courier New', Consolas, monospace;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    opacity: 0.7;
    color: inherit;
    margin: 0 0 0.5rem;
}

/* Era Badge and Date Range */
.sample-drawer-era {
    text-align: center;
    margin-bottom: 1.5rem;
    padding: 0 1rem;
}

.sample-drawer-era-badge {
    display: inline-block;
    background: var(--sample-drawer-accent-light, #D4C4A8);
    color: var(--sample-drawer-header-bg, #0D0D0F);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: fit-content;
}

.sample-drawer-dates {
    display: block;
    margin-top: 8px;
    font-size: 0.875rem;
    color: var(--sample-drawer-text-muted, #A89F91);
}

/* Genetic Distance Score */
.sample-drawer-distance {
    text-align: center;
    margin-bottom: 1.5rem;
    padding: 0 1rem;
}

.sample-drawer-distance-badge {
    display: inline-block;
    font-size: 1.25rem;
    font-weight: 700;
    padding: 8px 20px;
    border-radius: 20px;
    margin-bottom: 4px;
}

.sample-drawer-distance-label {
    display: block;
    margin-top: 6px;
    font-size: 0.8125rem;
    color: var(--sample-drawer-text-muted, #A89F91);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Badge color overrides for drawer */
.dna-sample-drawer-body .badge-success,
.dna-sample-drawer-body .sample-drawer-distance-badge.badge-success {
    background-color: #28a745 !important;
    color: #ffffff !important;
}

.dna-sample-drawer-body .badge-warning,
.dna-sample-drawer-body .sample-drawer-distance-badge.badge-warning {
    background-color: #ffc107 !important;
    color: var(--sample-drawer-header-bg, #0D0D0F) !important;
}

.dna-sample-drawer-body .badge-danger,
.dna-sample-drawer-body .sample-drawer-distance-badge.badge-danger {
    background-color: #dc3545 !important;
    color: #ffffff !important;
}

/* Drawer Sections */
.sample-drawer-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--sample-drawer-border, rgba(168, 159, 145, 0.2));
}

.sample-drawer-section:first-child {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

.sample-drawer-section h5 {
    color: var(--sample-drawer-accent, #B8956A);
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sample-drawer-metadata {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
}

.sample-drawer-metadata-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sample-drawer-metadata-label {
    color: var(--sample-drawer-text-muted, #A89F91);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.sample-drawer-metadata-value {
    color: var(--sample-drawer-text, #E5E0D8);
    font-size: 0.9375rem;
    font-weight: 500;
}

.sample-drawer-metadata-value .badge {
    color: var(--sample-drawer-header-bg, #0D0D0F) !important;
}

/* Haplogroup Match Type badge (mirrors .haplo-drawer-match-badge color coding) */
.sample-drawer-match-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8125rem;
    font-weight: 600;
}

.sample-drawer-match-badge.exact {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.4);
}

.sample-drawer-match-badge.base {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.4);
}

.sample-drawer-match-badge.subclade {
    background: rgba(139, 92, 246, 0.2);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.4);
}

.sample-drawer-match-badge.parent {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.sample-drawer-match-badge.close {
    background: rgba(236, 72, 153, 0.2);
    color: #f472b6;
    border: 1px solid rgba(236, 72, 153, 0.4);
}

.sample-drawer-match-badge.related {
    background: rgba(148, 163, 184, 0.2);
    color: #cbd5e1;
    border: 1px solid rgba(148, 163, 184, 0.4);
}

/* Matched DNA Segments browser (compact; only chromosomes with shared segments) */
.sample-drawer-segments-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    margin-bottom: 0.9rem;
    font-size: 0.8rem;
    color: var(--sample-drawer-text-muted, #A89F91);
}

.sample-drawer-segments-summary strong {
    color: var(--sample-drawer-accent, #B8956A);
    font-weight: 600;
}

/* Coverage / confidence chip and notice (sparse-SNP, long-cM match flag) */
.sample-drawer-density-chip {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.sample-drawer-density-chip-low {
    background: rgba(212, 168, 75, 0.15);
    color: #d4a84b;
    border: 1px solid rgba(212, 168, 75, 0.35);
}

.sample-drawer-segments-lowcov-notice {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.9rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    background: rgba(212, 168, 75, 0.08);
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--sample-drawer-text-muted, #A89F91);
}

.sample-drawer-segments-browser {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.sample-drawer-segment-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.sample-drawer-segment-label {
    flex: 0 0 3rem;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    color: var(--sample-drawer-text-muted, #A89F91);
    text-align: right;
    white-space: nowrap;
}

.sample-drawer-segment-track {
    position: relative;
    flex: 1 1 auto;
    height: 12px;
    background: rgba(168, 159, 145, 0.15);
    border-radius: 6px;
    overflow: hidden;
}

.sample-drawer-segment-tick {
    position: absolute;
    top: 0;
    bottom: 0;
    min-width: 2px;
    background: var(--sample-drawer-accent, #B8956A);
    border-radius: 6px;
    opacity: 0.9;
    cursor: help;
    transition: opacity 0.15s ease, background 0.15s ease;
}

.sample-drawer-segment-tick:hover {
    opacity: 1;
    background: var(--sample-drawer-accent-light, #D4C4A8);
}

.sample-drawer-segment-meta {
    flex: 0 0 auto;
    min-width: 6.5rem;
    font-size: 0.68rem;
    color: var(--sample-drawer-text-muted, #A89F91);
    text-align: right;
    white-space: nowrap;
}

.sample-drawer-segments-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--sample-drawer-text-muted, #A89F91);
}

.sample-drawer-segments-empty {
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--sample-drawer-text-muted, #A89F91);
    opacity: 0.85;
}

@media (max-width: 480px) {
    .sample-drawer-segment-label {
        flex-basis: 2.4rem;
        font-size: 0.66rem;
    }

    .sample-drawer-segment-meta {
        min-width: 5rem;
        font-size: 0.62rem;
    }
}

/* Map Container */
.sample-drawer-map-section {
    padding: 1.5rem 0;
}

.sample-drawer-map-container {
    height: 250px;
    width: 100%;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--sample-drawer-border, rgba(168, 159, 145, 0.15));
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    background: var(--sample-drawer-bg, #1A1C1E);
}

.sample-drawer-map-container .leaflet-container {
    background: var(--sample-drawer-bg, #1A1C1E);
    height: 100%;
    width: 100%;
}

.sample-drawer-map-container .leaflet-control-attribution {
    background: rgba(0, 0, 0, 0.6);
    color: var(--sample-drawer-text-muted, #A89F91);
    font-size: 10px;
    padding: 4px 8px;
}

.sample-drawer-map-container .leaflet-control-attribution a {
    color: var(--sample-drawer-accent, #B8956A);
    text-decoration: none;
}

.sample-drawer-map-container .leaflet-control-attribution a:hover {
    color: var(--sample-drawer-accent, #B8956A);
    text-decoration: underline;
}

/* Era Description */
.era-description-content {
    color: var(--sample-drawer-text, #E5E0D8);
    line-height: 1.6;
    font-size: 0.9375rem;
}

.era-description-content p {
    margin-bottom: 12px;
}

.era-description-content p:last-child {
    margin-bottom: 0;
}

/* Publication Links */
.sample-drawer-publication-link {
    color: var(--sample-drawer-accent-light, #D4B896);
    text-decoration: none;
    font-weight: 600;
    display: inline-block;
    margin-right: 12px;
}

.sample-drawer-publication-link:hover,
.sample-drawer-publication-link:focus {
    color: var(--sample-drawer-accent, #B8956A);
    text-decoration: underline;
}

/* Button Styles */
.dna-sample-drawer-body .btn-primary,
.sample-drawer-section .btn-primary {
    background: var(--sample-drawer-header-bg, #0D0D0F) !important;
    border-color: var(--sample-drawer-accent, #B8956A) !important;
    color: var(--sample-drawer-accent, #B8956A) !important;
}

.dna-sample-drawer-body .btn-primary:hover,
.sample-drawer-section .btn-primary:hover {
    background: var(--sample-drawer-accent, #B8956A) !important;
    border-color: var(--sample-drawer-accent, #B8956A) !important;
    color: var(--sample-drawer-header-bg, #0D0D0F) !important;
}

.dna-sample-drawer-body .btn-outline-secondary,
.sample-drawer-section .btn-outline-secondary {
    background: transparent !important;
    border-color: var(--sample-drawer-accent-light, #D4B896) !important;
    color: var(--sample-drawer-accent-light, #D4B896) !important;
}

.dna-sample-drawer-body .btn-outline-secondary:hover,
.sample-drawer-section .btn-outline-secondary:hover {
    background: rgba(196, 149, 106, 0.1) !important;
    border-color: var(--sample-drawer-accent, #B8956A) !important;
    color: var(--sample-drawer-accent, #B8956A) !important;
}

/* ========================================
   MOBILE RESPONSIVE (Slide from Bottom)
   ======================================== */

@media (max-width: 768px) {
    .dna-sample-drawer-panel {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: none;
        max-height: 90vh;
        transform: translateY(100%);
        border-radius: 24px 24px 0 0;
    }
    
    .dna-sample-drawer.open .dna-sample-drawer-panel {
        transform: translateY(0);
    }
    
    .dna-sample-drawer-header {
        border-radius: 24px 24px 0 0;
        position: relative;
    }
    
    .dna-sample-drawer-header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: rgba(255, 255, 255, 0.3);
        border-radius: 2px;
    }
    
    .sample-drawer-portrait {
        margin: 1rem 0;
    }
    
    .sample-drawer-portrait img {
        width: 160px;
        height: 160px;
    }
    
    .sample-drawer-info {
        margin-bottom: 1rem;
    }
    
    .sample-drawer-info h3 {
        font-size: 1.25rem;
    }
    
    .sample-drawer-era {
        margin-bottom: 1rem;
    }
    
    .sample-drawer-distance {
        margin-bottom: 1rem;
    }
    
    .sample-drawer-distance-badge {
        font-size: 1.1rem;
        padding: 6px 16px;
    }
    
    .sample-drawer-map-container {
        height: 200px;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .dna-sample-drawer {
        display: none !important;
    }
}
