/* ==========================================================================
   CONSISTENT HEADER PUBMED STYLES - Matches Benefits/Protocols Headers
   Compact, theme-aligned design that integrates with existing sections
   ========================================================================== */

/* ==========================================================================
   PUBMED SECTION CONTAINER
   ========================================================================== */

.pubmed-section {
    margin-top: 0;
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
}

/* ==========================================================================
   PUBMED HEADER - Consistent with Other Section Headers
   ========================================================================== */

.pubmed-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: 0;
    transition: all 0.2s ease;
    margin: 0;
    user-select: none;
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.pubmed-header:hover {
    background: rgba(59, 130, 246, 0.08);
    border-radius: 6px;
}

.pubmed-header:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 6px;
}

/* Match section header styling */
.pubmed-header.section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

/* ==========================================================================
   PUBMED TITLE - Matches Other Section Titles
   ========================================================================== */

.pubmed-title {
    color: #f1f5f9;
    font-size: 16px;
    font-weight: 600;
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    flex: 1;
}

/* Remove emoji, keep text clean like other headers */
.pubmed-title::before {
    content: '';
    display: none;
}

.pubmed-count {
    color: #94a3b8;
    font-weight: 500;
    font-size: 16px;
    margin-left: 0;
}

/* Hover state for title */
.pubmed-header:hover .pubmed-title {
    color: #3b82f6;
}

/* ==========================================================================
   PUBMED TOGGLE CHEVRON - Inline with Title
   ========================================================================== */

.pubmed-toggle {
    display: flex;
    align-items: center;
    color: #94a3b8;
    font-size: 14px;
    margin-left: auto;
    min-width: 20px;
    justify-content: center;
}

.toggle-icon {
    font-size: 14px;
    transition: transform 0.2s ease, color 0.2s ease;
    color: #94a3b8;
}

.pubmed-header[aria-expanded="true"] .toggle-icon {
    transform: rotate(180deg);
    color: #3b82f6;
}

.pubmed-header:hover .toggle-icon {
    color: #3b82f6;
}

/* Hide toggle text, keep only chevron */
.toggle-text {
    display: none;
}

/* ==========================================================================
   PUBMED CONTENT - Clean Separator
   ========================================================================== */

.pubmed-content {
    display: none;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
    margin-top: 12px;
    border-top: 1px solid #334155;
    padding-top: 16px;
}

.pubmed-content[aria-hidden="false"] {
    display: block !important;
    opacity: 1 !important;
    max-height: none !important;
    overflow: visible !important;
}

/* ==========================================================================
   STUDIES CONTAINER - Clean Grid Layout
   ========================================================================== */

.pubmed-studies {
    display: grid;
    gap: 12px;
    margin: 0;
}

/* ==========================================================================
   INDIVIDUAL STUDY STYLING - Refined Cards
   ========================================================================== */

.pubmed-study {
    background: #111827;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 14px;
    transition: all 0.2s ease;
    position: relative;
}

.pubmed-study:hover {
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
    transform: translateY(-1px);
}

/* ==========================================================================
   STUDY HEADER - Title and Year
   ========================================================================== */

.study-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}

.study-title {
    flex: 1;
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.study-title a {
    color: #f1f5f9;
    text-decoration: none;
    transition: all 0.2s ease;
}

.study-title a:hover {
    color: #3b82f6;
    text-decoration: underline;
}

.study-year {
    background: #1e293b;
    color: #94a3b8;
    padding: 3px 7px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid #334155;
}

/* ==========================================================================
   STUDY AUTHORS - Compact Format
   ========================================================================== */

.study-authors {
    margin-bottom: 10px;
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.3;
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.authors-label {
    color: #94a3b8;
    font-weight: 500;
    margin-right: 4px;
}

/* ==========================================================================
   STUDY METADATA - Compact PMID and Journal
   ========================================================================== */

.study-metadata {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.study-pmid {
    display: flex;
    align-items: center;
    gap: 5px;
}

.pmid-label {
    color: #94a3b8;
    font-size: 12px;
    font-weight: 500;
}

.pmid-link {
    background: #3b82f6;
    color: #ffffff;
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 5px;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    transition: background-color 0.2s ease;
}

.pmid-link:hover {
    background: #2563eb;
}

.study-journal {
    color: #94a3b8;
    font-size: 12px;
    font-style: italic;
}

.journal-label {
    color: #94a3b8;
    font-weight: 500;
    margin-right: 4px;
    font-style: normal;
}

/* ==========================================================================
   STUDY ACTIONS - Compact Button
   ========================================================================== */

.study-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 2px;
}

.study-link-btn {
    background: #3b82f6;
    color: #ffffff;
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    transition: background-color 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.study-link-btn:hover {
    background: #2563eb;
}

.study-link-btn::after {
    content: '→';
    font-size: 10px;
    opacity: 0.8;
}

/* ==========================================================================
   ADDITIONAL STUDIES SECTION - Subtle
   ========================================================================== */

.additional-studies {
    margin-top: 10px;
    animation: fadeIn 0.3s ease;
}

.show-more-studies {
    background: transparent;
    color: #3b82f6;
    border: 1px solid #3b82f6;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    margin-top: 12px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.show-more-studies:hover {
    background: #3b82f6;
    color: #ffffff;
}

.show-more-studies:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.show-more-count {
    background: rgba(59, 130, 246, 0.2);
    padding: 1px 4px;
    border-radius: 6px;
    font-size: 10px;
}

/* ==========================================================================
   INTEGRATION WITH SECTION STRUCTURE
   ========================================================================== */

/* Make pubmed section look like other sections */
.section.pubmed-section {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

/* Section title styling to match Benefits, Protocols, etc. */
.section-title.pubmed-section-title {
    color: #f1f5f9;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    cursor: pointer;
    padding: 8px 12px;
    margin: 0;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-title.pubmed-section-title:hover {
    background: rgba(59, 130, 246, 0.08);
    border-radius: 6px;
    color: #3b82f6;
}

/* ==========================================================================
   PARENT CONTAINER FIXES
   ========================================================================== */

.peptide-card {
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
}

.card-content {
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
}

.section {
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
}

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pubmed-content[aria-hidden="false"] {
    animation: fadeIn 0.3s ease;
}

/* ==========================================================================
   RESPONSIVE DESIGN - Mobile & Tablet
   ========================================================================== */

@media (max-width: 768px) {
    .pubmed-header {
        padding: 6px 10px;
    }
    
    .pubmed-title {
        font-size: 15px;
    }
    
    .pubmed-count {
        font-size: 15px;
    }
    
    .pubmed-studies {
        gap: 10px;
    }
    
    .pubmed-study {
        padding: 12px;
    }
    
    .study-header {
        flex-direction: column;
        gap: 6px;
        align-items: flex-start;
    }
    
    .study-title {
        font-size: 14px;
    }
    
    .study-year {
        align-self: flex-start;
        font-size: 10px;
        padding: 2px 5px;
    }
    
    .study-metadata {
        flex-direction: column;
        gap: 5px;
        align-items: flex-start;
    }
    
    .study-authors {
        font-size: 12px;
    }
    
    .pmid-link {
        font-size: 10px;
        padding: 1px 4px;
    }
    
    .study-journal {
        font-size: 11px;
    }
    
    .study-link-btn {
        padding: 5px 8px;
        font-size: 11px;
        width: 100%;
        justify-content: center;
    }
    
    .show-more-studies {
        padding: 5px 10px;
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .pubmed-header {
        padding: 5px 8px;
    }
    
    .pubmed-title {
        font-size: 14px;
    }
    
    .pubmed-study {
        padding: 10px;
    }
    
    .study-title {
        font-size: 13px;
    }
    
    .study-authors,
    .study-journal {
        font-size: 11px;
    }
    
    .pmid-label,
    .journal-label {
        font-size: 11px;
    }
    
    .study-link-btn {
        font-size: 10px;
        padding: 4px 6px;
    }
    
    .show-more-studies {
        font-size: 10px;
        padding: 4px 8px;
    }
}

/* ==========================================================================
   ACCESSIBILITY ENHANCEMENTS
   ========================================================================== */

.pubmed-header:focus-visible,
.study-link-btn:focus-visible,
.pmid-link:focus-visible,
.show-more-studies:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .pubmed-header {
        border: 1px solid #ffffff;
    }
    
    .pubmed-study {
        border-width: 2px;
    }
    
    .study-title a {
        text-decoration: underline;
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
    
    .toggle-icon {
        transition: none !important;
    }
    
    .pubmed-header:hover,
    .pubmed-study:hover,
    .study-link-btn:hover,
    .pmid-link:hover {
        transform: none;
    }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
    .pubmed-section {
        break-inside: avoid;
        margin-top: 12px;
    }
    
    .pubmed-header {
        background: #f8f9fa !important;
        border: 1px solid #000;
        color: #000 !important;
        padding: 6px 8px;
    }
    
    .pubmed-content {
        display: block !important;
        opacity: 1 !important;
        max-height: none !important;
        border-top: 1px solid #000;
    }
    
    .pubmed-study {
        background: #f8f9fa !important;
        border: 1px solid #ccc;
        break-inside: avoid;
        margin-bottom: 8px;
    }
    
    .study-title a {
        color: #000 !important;
        text-decoration: underline;
    }
    
    .study-link-btn,
    .show-more-studies {
        display: none;
    }
    
    .pmid-link {
        background: #e9ecef !important;
        color: #000 !important;
        border: 1px solid #000;
    }
    
    .toggle-icon {
        display: none;
    }
}