/**
 * 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);
}

/* ========================================
   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-accent-dark, #8B6D4F), 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-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-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);
}

/* 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 {
    color: var(--sample-drawer-accent, #B8956A);
    margin-right: 6px;
}

/* 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;
}

/* 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;
    }
}
