/* ================================================================
   NeuroEvidence.ai — Drug Card Stylesheet
   ================================================================ */

/* ── Drug Card Container ─────────────────────────────────────── */

.drug-card {
    max-width: 860px;
    margin: 0 auto;
    font-family: "DM Sans", system-ui, -apple-system, sans-serif;
    color: var(--navy, #0a1628);
    background: var(--white, #ffffff);
    border-radius: var(--radius, 12px);
    box-shadow: var(--shadow-md, 0 4px 16px rgba(10,22,40,0.07));
    overflow: hidden;
    border: 1px solid var(--gray-200, #e8ecf0);
}

/* ── Header ──────────────────────────────────────────────────── */

.dc-header {
    background: linear-gradient(135deg, #008f7f 0%, #00a896 50%, #00b8a3 100%);
    padding: 1.5rem 1.75rem 1.4rem;
    position: relative;
}

.dc-therapeutic-group {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.88);
    background: rgba(255, 255, 255, 0.18);
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    margin-bottom: 0.5rem;
}

.dc-generic-name {
    font-size: 1.55rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.3px;
    margin-bottom: 0.2rem;
    line-height: 1.2;
}

.dc-brand-names {
    font-size: 0.88rem;
    color: rgba(255,255,255,0.78);
    margin-bottom: 0.6rem;
    font-weight: 400;
}

.dc-brand-names strong {
    font-weight: 600;
    color: rgba(255,255,255,0.92);
}

.dc-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.5rem;
}

.dc-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.22rem 0.7rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.dc-badge-class {
    background: rgba(255,255,255,0.2);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
}

.dc-badge-route {
    background: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.85);
    border: 1px solid rgba(255,255,255,0.18);
    font-weight: 500;
}

/* ── Body ────────────────────────────────────────────────────── */

.dc-body {
    padding: 0;
}

/* ── Section shared styles ───────────────────────────────────── */

.dc-section {
    padding: 1.25rem 1.75rem;
    border-bottom: 1px solid var(--gray-200, #e8ecf0);
}

.dc-section:last-child {
    border-bottom: none;
}

/* Unified typography system for the drug card modal:
   - PRIMARY section headers (MECHANISM OF ACTION, DOSING, INTERACTIONS,
     SIDE EFFECTS, CLINICAL PEARLS) — teal to stand out at a glance.
   - SUBSECTION labels (HALF-LIFE, PROTEIN BINDING, METABOLISM, etc.) —
     smaller, gray, subordinate to section headers.
   - BODY content — one consistent size/weight/color across paragraphs,
     lists, PK values, indication bullets. Only color changes (dark
     navy) differentiates content from labels.
*/

.dc-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--teal, #00a896);            /* primary heading color */
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.dc-section-title svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    color: var(--teal, #00a896);
    opacity: 0.85;
}

/* ── Mechanism ───────────────────────────────────────────────── */

.dc-mechanism-summary {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--navy, #0a1628);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.dc-mechanism-detail {
    font-size: 0.88rem;
    color: var(--gray-600, #4a5568);
    margin-top: 0.5rem;
    line-height: 1.6;
    padding-top: 0.55rem;
    border-top: 1px dashed var(--gray-200, #e8ecf0);
    font-weight: 400;
}

/* ── PK Row (half-life / metabolism) ────────────────────────── */

.dc-pk-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.25rem;
}

.dc-pk-item {
    flex: 1 1 180px;
    min-width: 0;
}

/* Subsection label style — smaller + grayer than the section header so
   the hierarchy reads: SECTION (teal) > subsection (gray) > content. */
.dc-pk-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gray-500, #6b7a8d);
    margin-bottom: 0.25rem;
}

.dc-pk-value {
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--navy, #0a1628);
    font-weight: 400;
}

/* ── Dosing Table ────────────────────────────────────────────── */

.dc-dosing-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm, 8px);
    border: 1px solid var(--gray-200, #e8ecf0);
}

.dc-dosing-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    min-width: 460px;
}

.dc-dosing-table thead {
    background: var(--gray-100, #f1f3f6);
}

.dc-dosing-table thead th {
    padding: 0.55rem 0.9rem;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-500, #6b7a8d);
    border-bottom: 1px solid var(--gray-200, #e8ecf0);
    white-space: nowrap;
}

.dc-dosing-table tbody tr {
    border-bottom: 1px solid var(--gray-100, #f1f3f6);
    transition: background 0.15s;
}

.dc-dosing-table tbody tr:last-child {
    border-bottom: none;
}

.dc-dosing-table tbody tr:hover {
    background: #f8f9fc;
}

.dc-dosing-table td {
    padding: 0.65rem 0.9rem;
    color: var(--navy, #0a1628);
    vertical-align: top;
    line-height: 1.45;
}

.dc-dosing-table td:first-child {
    font-weight: 600;
    color: var(--navy, #0a1628);
}

.dc-dosing-table td.dc-max-dose {
    color: var(--gray-600, #4a5568);
    font-size: 0.84rem;
}

/* ── Boxed Warning ───────────────────────────────────────────── */

.dc-boxed-warning {
    background: #fff5f5;
    border: 1.5px solid #fc8181;
    border-radius: var(--radius-sm, 8px);
    padding: 0.9rem 1rem;
    margin-bottom: 1rem;
}

.dc-boxed-warning-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #c53030;
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.dc-boxed-warning-label svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

.dc-boxed-warning-text {
    font-size: 0.875rem;
    color: #742a2a;
    line-height: 1.55;
}

/* Subsection label used inside a section card (e.g., "Contraindications",
   "Neurology-Specific Warnings"). Matches .dc-pk-label for a unified
   subordinate-label treatment across the card. */
.dc-subsection-title {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--gray-500, #6b7a8d);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.4rem;
}

.dc-subsection-title.dc-subsection-neuro {
    color: #b7791f;
}

.dc-subgroup {
    margin-bottom: 0.85rem;
}
.dc-subgroup:last-child {
    margin-bottom: 0;
}

/* ── Contraindications & Neuro Warnings ─────────────────────── */

.dc-warning-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.dc-warning-list li {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--navy, #0a1628);
    line-height: 1.55;
    font-weight: 400;
}

.dc-warning-list li::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fc8181;
    margin-top: 0.4em;
    flex-shrink: 0;
}

.dc-warning-list.dc-neuro li::before {
    background: #f6ad55;
}

/* ── Drug Interactions ───────────────────────────────────────── */

.dc-interactions-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dc-interaction-item {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    gap: 0.1rem 0.75rem;
    padding: 0.65rem 0.9rem;
    border-radius: var(--radius-sm, 8px);
    border: 1px solid transparent;
    font-size: 0.875rem;
    align-items: start;
}

.dc-interaction-item.severity-high {
    background: #fff5f5;
    border-color: #fc8181;
}

.dc-interaction-item.severity-moderate {
    background: var(--amber-bg, #fef9ec);
    border-color: var(--amber-border, #e5b94e);
}

.dc-interaction-item.severity-low {
    background: var(--gray-100, #f1f3f6);
    border-color: var(--gray-200, #e8ecf0);
}

.dc-interaction-severity {
    grid-row: 1 / 3;
    grid-column: 1;
    align-self: center;
}

.dc-severity-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: 3px;
}

.severity-high .dc-severity-dot   { background: #e53e3e; }
.severity-moderate .dc-severity-dot { background: #d69e2e; }
.severity-low .dc-severity-dot    { background: #a0aab4; }

.dc-interaction-drug {
    grid-row: 1;
    grid-column: 2;
    font-weight: 600;
    color: var(--navy, #0a1628);
    line-height: 1.3;
}

.dc-interaction-effect {
    grid-row: 2;
    grid-column: 2;
    color: var(--gray-600, #4a5568);
    font-size: 0.84rem;
    line-height: 1.4;
}

.dc-severity-tag {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.1rem 0.45rem;
    border-radius: 20px;
    margin-left: 0.4rem;
    vertical-align: middle;
}

.severity-high .dc-severity-tag   { background: #fed7d7; color: #c53030; }
.severity-moderate .dc-severity-tag { background: #fefcbf; color: #975a16; }
.severity-low .dc-severity-tag    { background: var(--gray-200, #e8ecf0); color: var(--gray-500, #6b7a8d); }

/* ── Monitoring ──────────────────────────────────────────────── */

.dc-monitoring-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.dc-monitoring-list li {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--gray-600, #4a5568);
    line-height: 1.45;
}

.dc-monitoring-list li::before {
    content: "";
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--teal, #00a896);
    margin-top: 0.5em;
    flex-shrink: 0;
}

/* ── Clinical Pearls ─────────────────────────────────────────── */

.dc-pearls-section {
    background: var(--teal-bg, #e6f7f5);
    border-top: 1px solid rgba(0,168,150,0.18);
}

.dc-pearls-section .dc-section-title {
    color: var(--teal-dark, #008f7f);
}

.dc-pearls-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.dc-pearls-list li {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    font-size: 0.9rem;
    color: #1a4a44;
    line-height: 1.5;
}

.dc-pearl-bullet {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--teal, #00a896);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 800;
    flex-shrink: 0;
    margin-top: 0.15em;
    letter-spacing: 0;
}

/* ── Related Trials ──────────────────────────────────────────── */

.dc-trials-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.dc-trial-pill {
    display: inline-block;
    padding: 0.3rem 0.7rem;
    background: var(--gray-100, #f1f3f6);
    border: 1px solid var(--gray-200, #e8ecf0);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--navy, #0a1628);
    cursor: default;
    transition: background 0.15s, border-color 0.15s;
}

.dc-trial-pill:hover {
    background: var(--teal-bg, #e6f7f5);
    border-color: var(--teal, #00a896);
    color: var(--teal-dark, #008f7f);
}

/* ── Empty / placeholder states ─────────────────────────────── */

.dc-empty {
    font-size: 0.85rem;
    color: var(--gray-400, #a0aab4);
    font-style: italic;
}

/* ── Loading skeleton ────────────────────────────────────────── */

.dc-skeleton {
    background: linear-gradient(90deg,
        var(--gray-100, #f1f3f6) 25%,
        var(--gray-200, #e8ecf0) 50%,
        var(--gray-100, #f1f3f6) 75%);
    background-size: 400% 100%;
    animation: dc-shimmer 1.4s ease infinite;
    border-radius: 4px;
    height: 1em;
    display: block;
}

@keyframes dc-shimmer {
    0%   { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

/* ── Error state ─────────────────────────────────────────────── */

.dc-error {
    padding: 2rem 1.75rem;
    text-align: center;
}

.dc-error-icon {
    width: 36px;
    height: 36px;
    color: #fc8181;
    margin: 0 auto 0.75rem;
    display: block;
}

.dc-error-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--navy, #0a1628);
    margin-bottom: 0.3rem;
}

.dc-error-msg {
    font-size: 0.875rem;
    color: var(--gray-500, #6b7a8d);
}

/* ── Overlay modal wrapper ───────────────────────────────────── */

.dc-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10,22,40,0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: dc-fade-in 0.2s ease;
}

.dc-modal-overlay.hidden {
    display: none;
}

@keyframes dc-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.dc-modal-inner {
    width: 100%;
    max-width: 860px;
    height: min(85vh, 780px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--white, #ffffff);
    border-radius: var(--radius, 12px);
    box-shadow: 0 20px 60px rgba(10,22,40,0.25);
    animation: dc-slide-up 0.25s cubic-bezier(0.4,0,0.2,1);
    position: relative;
}

/* #dc-modal-body is the intermediate wrapper fetchAndShowDrug injects
   between .dc-modal-inner and .drug-card. Without flex props here the
   flex chain is broken and .drug-card's flex:1 has no effect — content
   overflows and is clipped instead of scrolling. */
.dc-modal-inner #dc-modal-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Inside the modal, the drug-card itself becomes a flex column so the
   body pane is the only scrollable region — header + tabs stay fixed. */
.dc-modal-inner .drug-card {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    max-width: none;
    margin: 0;
    border: none;
    border-radius: inherit;
    box-shadow: none;
}

.dc-modal-inner .dc-header,
.dc-modal-inner .dc-tabs-bar {
    flex-shrink: 0;
}

.dc-modal-inner .dc-body-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

@keyframes dc-slide-up {
    from { transform: translateY(14px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.dc-modal-close {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    font-size: 1.3rem;
    line-height: 1;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    z-index: 2;
}

.dc-modal-close:hover {
    background: rgba(255,255,255,0.35);
}

/* ── Inline embed mode (not modal) ──────────────────────────── */

.dc-inline {
    border-radius: var(--radius, 12px);
    overflow: hidden;
    border: 1px solid var(--gray-200, #e8ecf0);
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(10,22,40,0.06));
}

/* ── Responsive ──────────────────────────────────────────────── */

/* ── Mobile Responsive (max-width: 768px) ────────────────────── */

@media (max-width: 768px) {
    /* Modal: Full width, minimal margin */
    .dc-modal-inner {
        width: calc(100% - 1rem);
        max-width: 100%;
        height: 92vh;
        margin: 0 0.5rem;
        border-radius: 8px;
    }

    /* Dosing table: Horizontal scroll */
    .dc-dosing-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
    }

    /* Font sizes: Slightly smaller */
    .dc-generic-name {
        font-size: 1.3rem;
    }

    .dc-brand-names {
        font-size: 0.82rem;
    }

    .dc-section-title {
        font-size: 0.68rem;
    }

    .dc-mechanism-summary {
        font-size: 0.9rem;
    }

    .dc-mechanism-detail {
        font-size: 0.8rem;
    }

    /* Interaction cards: Stack vertically */
    .dc-interactions-list {
        gap: 0.4rem;
    }

    .dc-interaction-item {
        padding: 0.6rem 0.8rem;
        grid-template-columns: auto 1fr;
        grid-gap: 0.1rem 0.6rem;
    }

    .dc-interaction-drug {
        font-size: 0.85rem;
    }

    .dc-interaction-effect {
        font-size: 0.8rem;
    }

    /* PK items: Better mobile wrap */
    .dc-pk-row {
        gap: 0.8rem;
    }

    .dc-pk-item {
        flex: 1 1 140px;
    }

    .dc-pk-label {
        font-size: 0.7rem;
    }

    .dc-pk-value {
        font-size: 0.85rem;
    }

    /* Pearls: More readable on mobile */
    .dc-pearls-list li {
        font-size: 0.85rem;
        gap: 0.5rem;
    }

    .dc-pearl-bullet {
        width: 16px;
        height: 16px;
        font-size: 0.55rem;
    }

    /* Close button: Easier to tap */
    .dc-modal-close {
        width: 36px;
        height: 36px;
        top: 0.75rem;
        right: 0.75rem;
    }

    /* Trial pills: Better wrapping */
    .dc-trials-list {
        gap: 0.35rem;
    }

    .dc-trial-pill {
        padding: 0.25rem 0.6rem;
        font-size: 0.75rem;
    }
}

@media (max-width: 600px) {
    .dc-header {
        padding: 1.1rem 1.2rem;
    }

    .dc-generic-name {
        font-size: 1.25rem;
    }

    .dc-section {
        padding: 1rem 1.2rem;
    }

    .dc-dosing-table {
        font-size: 0.82rem;
    }

    .dc-dosing-table td,
    .dc-dosing-table th {
        padding: 0.5rem 0.65rem;
    }

    .dc-interaction-item {
        padding: 0.55rem 0.75rem;
    }

    .dc-modal-inner {
        height: 95vh;
    }
}

/* ── Peer drugs (same-class pills) ───────────────────────── */
.dc-peer-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.dc-peer-pill {
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    color: #008f7f;
    background: #e6f7f5;
    border: 1px solid rgba(0, 168, 150, 0.25);
    padding: 0.3rem 0.75rem;
    border-radius: 50px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.dc-peer-pill:hover {
    background: #00a896;
    color: #ffffff;
    border-color: #00a896;
}

/* ── Collapsible Sections ────────────────────────────────── */
.dc-collapsible {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-top: 0.75rem;
    overflow: hidden;
}

.dc-collapsible-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0.7rem 1rem;
    background: #f8fafc;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}

.dc-collapsible-toggle:hover {
    background: #f1f5f9;
}

.dc-collapsible-toggle .dc-section-title {
    margin: 0;
    font-size: 0.78rem;
}

.dc-chevron {
    font-size: 0.75rem;
    color: #94a3b8;
    transition: transform 0.2s;
}

.dc-open .dc-chevron {
    transform: rotate(180deg);
}

.dc-collapsible-body {
    display: none;
    padding: 0.5rem 1rem 1rem;
}

.dc-open .dc-collapsible-body {
    display: block;
}

/* ── Lists (indications, off-label, generic content) ───── */
.dc-list {
    list-style: disc;
    padding-left: 1.2rem;
    margin: 0.4rem 0;
    font-size: 0.9rem;
    color: var(--navy, #0a1628);
    line-height: 1.55;
    font-weight: 400;
}

.dc-list li {
    margin-bottom: 0.3rem;
}

/* ── Adverse Effects ─────────────────────────────────────── */
.dc-ae-group {
    margin-bottom: 0.85rem;
}

/* Subsection label — matches .dc-pk-label: gray, small, uppercase */
.dc-ae-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--gray-500, #6b7a8d);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.35rem;
}

.dc-ae-label.dc-ae-serious {
    color: #dc2626;
}

/* ── Tabs ─────────────────────────────────────────────────── */
.dc-tabs-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e2e8f0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 0.5rem;
}

.dc-tabs-bar::-webkit-scrollbar {
    display: none;
}

.dc-tab-btn {
    flex-shrink: 0;
    padding: 0.55rem 0.9rem;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: inherit;
    color: #64748b;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.dc-tab-btn:hover {
    color: #0f172a;
}

.dc-tab-btn.dc-tab-active {
    color: #00a896;
    border-bottom-color: #00a896;
}

.dc-tab-pane {
    padding: 0.5rem 0;
}
