/* =========================================================================
   1. CORE GLOBAL STYLING SYSTEM
   ========================================================================= */
:root {
        --primary: #5981f0;
        /* Deep Navy */
        --primary-light: #eff6ff;
        /* Ice Blue Accent */
        --accent: #2563eb;
        /* 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.5;
        padding: 40px 20px;
}

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

/* =========================================================================
   2. HERO INTERFACE & PANEL FILTERS
   ========================================================================= */
.search-hero {
        background: linear-gradient(135deg, var(--primary) 0%, #6d8cd6 100%);
        color: #000000;
        padding: 15px 20px;
        border-radius: 3px;
        box-shadow: var(--shadow);
        margin-bottom: 20px;
        text-align: center;
}

.search-hero h1 {
        font-size: 2.2rem;
        font-weight: 800;
        margin-bottom: 12px;
        letter-spacing: -0.5px;
        color: #1e3a8a;
        /* Letterpress effect for light text: dark shadow shifted 1px up and left */
        text-shadow: 1px 1px 0px rgba(255, 255, 255, 0.8);
}

.search-hero p {
        color: #363636;
        font-size: 1.1rem;
        margin-bottom: 20px;
        max-width: 600px;
        margin-left: auto;
        margin-right: auto;
}

.search-box {
        display: flex;
        max-width: 600px;
        margin: 0 auto;
        background: #ffffff;
        padding: 2px;
        border-radius: 2px;
        box-shadow: 0 2px 3px -3px rgb(0 0 0 / 0.1);
}

.search-box input {
        flex: 1;
        border: none;
        padding: 2px 4px;
        font-size: 1rem;
        color: var(--text-main);
        border-radius: 2px;
        outline: none;
}

.search-box button {
        background-color: var(--accent);
        color: #ffffff;
        border: none;
        padding: 0 28px;
        font-size: 1rem;
        font-weight: 600;
        border-radius: 2px;
        cursor: pointer;
        transition: background-color 0.2s;
}

.search-box button:hover {
        background-color: #1d4ed8;
}

/* =========================================================================
   3. SEARCH RESULTS LIST (GRID VIEW)
   ========================================================================= */
h2 {
        font-size: 1.5rem;
        font-weight: 500;
        margin-bottom: 20px;
        color: #000000;
}

.grid-view {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
        gap: 24px;
        margin-bottom: 40px;
}

.med-card {
        background: #ffffff;
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 24px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        box-shadow: var(--shadow);
        transition: transform 0.2s, box-shadow 0.2s;
}

.med-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.05);
}

.med-card h3 {
        font-size: 1.3rem;
        color: var(--primary);
        margin-bottom: 8px;
}

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

.btn-view {
        display: block;
        text-align: center;
        background-color: var(--primary-light);
        color: var(--accent);
        text-decoration: none;
        padding: 12px;
        border-radius: 8px;
        font-weight: 600;
        font-size: 0.95rem;
        margin-top: 16px;
        transition: background-color 0.2s, color 0.2s;
}

.btn-view:hover {
        background-color: var(--accent);
        color: #ffffff;
}

/* =========================================================================
   4. DETAILED MEDICINE PROFILE LAYOUT Canvas
   ========================================================================= */
.profile-layout {
        background: #ffffff;
        border: 1px solid var(--border);
        border-radius: 16px;
        padding: 40px;
        box-shadow: var(--shadow);
}

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

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

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

.profile-header h2 {
        font-size: 2.2rem;
        margin-bottom: 6px;
}

.section-block {
        margin-bottom: 35px;
}

.section-block h4 {
        font-size: 1.1rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: var(--text-muted);
        margin-bottom: 16px;
        border-left: 4px solid var(--accent);
        padding-left: 10px;
}

/* =========================================================================
   5. INTERACTIVE STRUCTURAL LAYOUT TABLES & COMPONENT CHIPS
   ========================================================================= */
.data-table {
        width: 100%;
        border-collapse: collapse;
        text-align: left;
        font-size: 0.95rem;
}

.data-table th {
        background-color: var(--bg-main);
        color: var(--text-muted);
        font-weight: 600;
        padding: 12px 16px;
        border-bottom: 1px solid var(--border);
}

.data-table td {
        padding: 16px;
        border-bottom: 1px solid var(--border);
        vertical-align: middle;
}

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

/* Component Pillboxes (For Allergens & Inactive Ingredients) */
.pill-box {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
}

.pill {
        background-color: var(--bg-main);
        border: 1px solid var(--border);
        padding: 6px 14px;
        border-radius: 20px;
        font-size: 0.9rem;
        color: var(--text-main);
        font-weight: 500;
}

/* =========================================================================
   6. RISK LEVEL COLOR BADGE DICTIONARY
   ========================================================================= */
.badge {
        display: inline-block;
        padding: 4px 10px;
        border-radius: 6px;
        font-size: 0.8rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        text-align: center;
}

/* Severity Color Map Layout Assignments */
.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;
}

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

.pagination a {
        display: inline-block;
        padding: 10px 16px;
        border: 1px solid var(--border);
        background-color: #ffffff;
        color: var(--text-main);
        text-decoration: none;
        border-radius: 8px;
        font-weight: 600;
        transition: all 0.2s;
}

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

/* =========================================================================
   PASTE THE NEW PRINT BUTTON CSS HERE
   ========================================================================= */
.btn-print {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: auto;
    max-width: max-content;
    margin-top: 0;
    padding: 10px 20px;
    background-color: #f1f5f9;
    color: #0f172a;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    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);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.btn-print:active {
    transform: translateY(0);
    background-color: #f1f5f9;
}

.icon-print {
    font-size: 16px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* =========================================================================
   KEEP THIS AS THE ABSOLUTE BOTTOM OF YOUR FILE
   ========================================================================= */
@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;
    }
}