/* =========================================================================
   1. CORE GLOBAL STYLING SYSTEM
   ========================================================================= */
:root {
        --primary: #2c2c2c;
        /* Deep Navy */
        --primary-light: #eff6ff;
        /* Ice Blue Accent */
        --accent: #2d6d6d;
        /* Slate Blue */
        --text-main: #1f2937;
        /* Off-Black Main Typography */
        --text-muted: #3b3b3b;
        /* Cool Grey Subtext */
        --bg-main: #f8fafc;
        /* Pale Charcoal Background */
        --border: #e2e8f0;
        /* Soft Table/Card Borders */
        --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
}

* {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
}

body {
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
        background-color: var(--bg-main);
        color: var(--text-main);
        line-height: 1.4;
        padding: 20px 10px; /* Reduced body edge spacing */
}

.container {
        max-width: 900px;
        margin: 0 auto;
}

/* =========================================================================
   2. HERO INTERFACE & PANEL FILTERS
   ========================================================================= */
.search-hero {
        color: #000000;
        padding: 12px; /* Compressed padding */
        border-radius: 2px;
        margin-bottom: 12px; /* Tighter margins */
        display: flex;
        flex-direction: column;
        gap: 12px;
}

.hero-header-row {
        display: flex;
        align-items: center;
        gap: 16px;
        width: 100%;
}

.search-hero .logo {
        width: 120px; /* Scaled down logo footprint */
        height: 120px;
        object-fit: contain;
        flex-shrink: 0;
}

.hero-text-block {
        display: flex;
        flex-direction: column;
        gap: 2px;
        text-align: left;
}

.search-hero h1 {
        font-size: 1.5rem; /* More compact header size */
        font-weight: 700;
        margin: 0;
        line-height: 1.2;
        color: #0f172a;
}

.search-hero p {
        font-size: 0.88rem; /* Scaled down subtext */
        margin: 0;
        color: #1e293b;
        line-height: 1.3;
}

.search-box {
        display: flex;
        width: 60%;
        background: #ffffff;
        padding: 4px;
        border-radius: 2px;
        border: 1px solid #282828;
        box-shadow: 0 4px 10px -1px rgba(0, 0, 0, 0.08);
        transition: border-color 0.2s, box-shadow 0.2s;
        margin: 2px auto 0 auto;
}

.search-box:focus-within {
        border-color: #0f172a;
        box-shadow: 0 4px 12px -1px rgba(15, 23, 42, 0.15);
}

.search-box input {
        flex: 1;
        border: none;
        background: transparent;
        padding: 4px 6px;
        font-size: 14px;
        color: #0f172a;
        outline: none;
        font-family: inherit;
}

.search-box input::placeholder {
        color: #94a3b8;
}

.search-box button {
        background-color: #338181;
        color: #ffffff;
        border: none;
        padding: 0 20px;
        font-size: 13px;
        font-weight: 600;
        border-radius: 2px;
        cursor: pointer;
        transition: background-color 0.15s, transform 0.1s;
}

.search-box button:hover {
        background-color: #3fa1a1;
}

.search-box button:active {
        transform: scale(0.98);
}
/* =========================================================================
   3. SEARCH RESULTS LIST (GRID VIEW)
   ========================================================================= */
h2 {
        font-size: 1.3rem;
        font-weight: 500;
        margin-bottom: 12px;
        color: #000000;
}

.grid-view {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 16px; /* Tighter layout gap */
        margin-bottom: 24px;
}

.med-card {
        background: #ffffff;
        border: 1px solid #282828;
        border-radius: 2px;
        padding: 16px; /* Compressed card interiors */
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        box-shadow: var(--shadow);
}

.med-card h3 {
        text-align: center;
        font-size: 1.15rem;
        background: #ffffff;
        color: #050505;
        margin-bottom: 6px;
}

.med-card .meta {
        font-size: 0.8rem;
        color: var(--text-muted);
        margin-bottom: 8px;
}

.btn-view {
        display: block;
        text-align: center;
        background-color: #338181;
        color: #ffffff;
        text-decoration: none;
        padding: 8px;
        border-radius: 2px;
        font-weight: 600;
        font-size: 0.88rem;
        margin-top: 10px;
        transition: background-color 0.2s, color 0.2s;
}

.btn-view:hover {
        background-color: #40a7a7;
        color: #ffffff;
}

/* =========================================================================
   4. DETAILED MEDICINE PROFILE LAYOUT Canvas
   ========================================================================= */
.profile-layout {
        background: #ffffff;
        border: 1px solid var(--border);
        border-radius: 2px;
        padding: 20px; /* Reduced canvas block padding for ultra compactness */
}

.back-link {
        color: var(--text-muted);
        text-decoration: none;
        font-size: 0.88rem;
        font-weight: 600;
        display: inline-block;
        margin-bottom: 12px;
}

.back-link:hover {
        color: var(--accent);
}

.profile-header {
        border-bottom: 2px solid var(--bg-main);
        padding-bottom: 12px;
        margin-bottom: 16px;
}

.profile-header h2 {
        font-size: 1.8rem; /* Compact layout title text size */
        margin-bottom: 4px;
}

.section-block {
        margin-bottom: 16px; /* Decreased panel block spacing gaps */
}

.section-block h4 {
        font-size: 0.95rem; /* Scaled down list row labels */
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: #338181;
        margin-bottom: 10px;
        border-left: 3px solid var(--accent);
        padding-left: 8px;
}

/* =========================================================================
   5. INTERACTIVE STRUCTURAL LAYOUT TABLES & COMPONENT CHIPS
   ========================================================================= */
.data-table {
        width: 100%;
        border-collapse: collapse;
        text-align: left;
        font-size: 0.88rem;
        margin-bottom: 8px;
        background: #ffffff;
        border: 1px solid #338181; /* Clear outer frame bounding */
        box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.data-table th {
        background-color: #338181; /* Deep slate background for headers */
        color: #ffffff;            /* High-contrast white text */
        font-weight: 600;
        padding: 10px 14px;
        border-bottom: 1px solid #338181;
        text-transform: uppercase;
        font-size: 0.78rem;
        letter-spacing: 0.5px;
}

.data-table td {
        padding: 12px 14px;
        border-bottom: 1px solid #000000; /* Soft cell division borders */
        color: var(--text-main);
        vertical-align: middle;
        line-height: 1.4;
}

/* Zebra striping for rapid visual scanning across dense rows */
.data-table tr:nth-child(even) {
        background-color: #f8fafc; 
}

/* Hover highlights for active path tracking */
.data-table tr:hover td {
        background-color: #f1f5f9;
}

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

/* =========================================================================
   SCROLL SYSTEM: Image Gallery Layout Utilities
   ========================================================================= */
.carousel-wrapper {
        position: relative;
        display: flex;
        align-items: center;
        width: 100%;
        background: #ffffff;
        border: 1px solid #cbd5e1;
        border-radius: 2px;
        padding: 10px 40px; /* Space on left/right for floating arrows */
}

.carousel-container {
        display: flex;
        gap: 12px;
        overflow-x: auto;
        scroll-behavior: smooth;
        width: 100%;
        padding: 4px 0;
}

/* Hide scrollbar tracking while preserving touch/swipe capabilities */
.carousel-container::-webkit-scrollbar {
        display: none;
}
.carousel-container {
        -ms-overflow-style: none;
        scrollbar-width: none;
}

.carousel-card {
        background: #ffffff;
        border: 1px solid var(--border);
        padding: 6px;
        border-radius: 2px;
        text-align: center;
        min-width: 130px;
        max-width: 130px;
        flex-shrink: 0;
}

.carousel-btn {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        background: #0f172a;
        color: #ffffff;
        border: none;
        width: 28px;
        height: 28px;
        border-radius: 50%;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: bold;
        font-size: 14px;
        z-index: 10;
        box-shadow: var(--shadow);
        transition: background 0.15s;
}

.carousel-btn:hover {
        background: var(--accent);
}

.carousel-btn.left { left: 8px; }
.carousel-btn.right { right: 8px; }

@media print {
        .carousel-wrapper { padding: 0; border: none; }
        .carousel-btn { display: none !important; }
        .carousel-container { overflow: visible; flex-wrap: wrap; }
}

.pill-box {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
}

.pill {
        background-color: var(--bg-main);
        border: 1px solid var(--border);
        padding: 4px 10px; /* Tight functional chips spacing */
        border-radius: 2px;
        font-size: 0.82rem;
        color: var(--text-main);
        font-weight: 500;
}

/* =========================================================================
   6. DYNAMIC TOOLTIP PRESENTATION ENGINE INSERT
   ========================================================================= */
[title] {
        position: relative;
        cursor: help;
}

[title]::after {
        content: attr(title);
        position: absolute;
        bottom: 125%;
        left: 50%;
        transform: translateX(-50%) scale(0.95);
        background: #0f172a;
        color: #ffffff;
        padding: 6px 10px;
        border-radius: 2px;
        font-size: 12px;
        font-weight: 500;
        line-height: 1.4;
        white-space: normal;
        min-width: 220px;
        max-width: 320px;
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        opacity: 0;
        pointer-events: none;
        z-index: 99999;
        transition: opacity 0.15s cubic-bezier(0.4, 0, 0.2, 1), transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
        text-align: left;
        border: 1px solid rgba(255, 255, 255, 0.1);
}

[title]::before {
        content: "";
        position: absolute;
        bottom: 115%;
        left: 50%;
        transform: translateX(-50%);
        border-width: 5px;
        border-style: solid;
        border-color: #0f172a transparent transparent transparent;
        opacity: 0;
        pointer-events: none;
        z-index: 99999;
}

[title]:hover::after {
        opacity: 1;
        transform: translateX(-50%) scale(1);
}

[title]:hover::before {
        opacity: 1;
}

.section-block a:hover code {
        background-color: var(--accent) !important;
        color: #ffffff !important;
        border-color: var(--accent) !important;
}
/* =========================================================================
   7. RISK LEVEL COLOR BADGE DICTIONARY
   ========================================================================= */
.badge {
        display: inline-block;
        padding: 2px 6px; /* Narrow profile label sizes */
        border-radius: 2px;
        font-size: 0.75rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        text-align: center;
}

.badge.Mild,
.badge.category-a,
.badge.category-b {
        background-color: #dcfce7;
        color: #15803d;
}

.badge.Moderate,
.badge.Caution,
.badge.category-c {
        background-color: #fef9c3;
        color: #a16207;
}

.badge.Severe,
.badge.Avoid,
.badge.category-d {
        background-color: #ffedd5;
        color: #ea580c;
}

.badge.Absolute,
.badge.Critical,
.badge.category-x {
        background-color: #fee2e2;
        color: #b91c1c;
}

/* =========================================================================
   8. PAGINATION & COMPONENT SYSTEM UTILITIES
   ========================================================================= */
.pagination {
        display: flex;
        justify-content: center;
        gap: 6px;
        margin-top: 16px;
}

.pagination a {
        display: inline-block;
        padding: 6px 12px; /* Tighter navigation squares layout */
        border: 1px solid var(--border);
        background-color: #ffffff;
        color: var(--text-main);
        text-decoration: none;
        border-radius: 2px;
        font-weight: 600;
        font-size: 0.85rem;
        transition: all 0.2s;
}

.pagination a.active,
.pagination a:hover {
        background-color: var(--accent);
        color: #ffffff;
        border-color: var(--accent);
}

/* =========================================================================
   9. INTERACTIVE PRINT INTERFACE NODES
   ========================================================================= */
.btn-print {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        width: auto;
        max-width: max-content;
        padding: 6px 12px; /* Tighter functional buttons layout */
        background-color: #f1f5f9;
        color: #0f172a;
        font-family: inherit;
        font-size: 13px;
        font-weight: 500;
        border: 1px solid #e2e8f0;
        border-radius: 2px;
        cursor: pointer;
        box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.02);
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-print:hover {
        background-color: #e2e8f0;
        border-color: #cbd5e1;
        transform: translateY(-1px);
}

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

.icon-print {
        font-size: 14px;
        display: inline-flex;
        align-items: center;
}

/* =========================================================================
   10. AUTOMATED PAPER MONOGRAPH PRINT MEDIA HARD COPY LAYOUT
   ========================================================================= */
@media print {
        body {
                background: #ffffff;
                color: #000000;
                padding: 0;
        }

        .search-hero,
        .back-link,
        .pagination,
        .btn-print,
        button {
                display: none !important;
        }

        .profile-layout {
                border: none;
                box-shadow: none;
                padding: 0;
        }

        .data-table th {
                background-color: #f1f5f9 !important;
                -webkit-print-color-adjust: exact;
                print-color-adjust: exact;
        }
        
        [title]::after {
                display: block !important;
                position: relative !important;
                opacity: 1 !important;
                background: transparent !important;
                color: #475569 !important;
                padding: 2px 0 0 6px !important;
                border: none !important;
                border-left: 2px solid #cbd5e1 !important;
                font-style: italic !important;
                font-size: 11px !important;
                bottom: auto !important;
                left: auto !important;
                transform: none !important;
        }
}

/* =========================================================================
   11. LIGHTBOX SYSTEM FOR CLINICAL IMAGING ASSETS
   ========================================================================= */
.lightbox-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(15, 23, 42, 0.85); /* Deep slate backdrop blur mimic */
        display: none;
        align-items: center;
        justify-content: center;
        z-index: 100000;
        cursor: zoom-out;
}

.lightbox-content {
        max-width: 85%;
        max-height: 85%;
        background: #ffffff;
        padding: 8px;
        border-radius: 4px;
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
        transform: scale(0.95);
        transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.lightbox-overlay.active {
        display: flex;
}

.lightbox-overlay.active .lightbox-content {
        transform: scale(1);
}

.carousel-card img {
        cursor: zoom-in;
        transition: opacity 0.15s;
}

.carousel-card img:hover {
        opacity: 0.9;
}

/* =========================================================================
   12. HIGH-DENSITY CRITICAL CELL HIGHLIGHTS
   ========================================================================= */
/* Applies implicit caution tracking profiles to vulnerable table cells */
.table-alert-danger {
        background-color: #fef2f2 !important; /* Soft light red warning cell background */
        border-left: 4px solid #ef4444 !important;
        font-weight: 500;
}

.table-alert-warning {
        background-color: #fffbeb !important; /* Soft light amber caution cell background */
        border-left: 4px solid #f59e0b !important;
}

@media print {
        .lightbox-overlay { display: none !important; }
        .table-alert-danger, .table-alert-warning { border-left: none !important; background: transparent !important; }
}
