/*
 * Basic styling for the gene‑centric trial finder.  The layout uses a simple
 * responsive column layout: filters on the left (wrapping when narrow) and
 * results on the right.  Cards expand to reveal additional information.
 */

html, body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    background: linear-gradient(180deg, #f8fbff 0%, #f4f8fb 100%);
    color: #1f2d3d;
}

header {
    background: linear-gradient(135deg, #005ea2, #0b7fc3);
    color: white;
    padding: 1.25rem 1rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 48, 84, 0.2);
}

header h1 {
    margin: 0 0 0.5rem 0;
    font-size: 1.7rem;
}

header p {
    margin: 0;
    font-size: 0.95rem;
    opacity: 0.92;
}

main {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    width: 100%;
    max-width: none;
    margin: 0;
    box-sizing: border-box;
}

.search-section {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

#searchForm {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
    max-width: 900px;
    align-items: center;
    background: #ffffff;
    border: 1px solid #dbe6f1;
    border-radius: 10px;
    padding: 0.75rem;
    box-shadow: 0 3px 10px rgba(24, 76, 124, 0.08);
}

#geneInput {
    flex: 1;
    min-width: 240px;
    padding: 0.6rem 0.7rem;
    font-size: 1rem;
    border: 1px solid #b7c8d8;
    border-radius: 6px;
}

#geneInput:focus {
    outline: none;
    border-color: #2f88d5;
    box-shadow: 0 0 0 3px rgba(47, 136, 213, 0.2);
}

#searchForm button {
    padding: 0.6rem 1rem;
    font-size: 1rem;
    background: linear-gradient(135deg, #0666b6, #0f87d8);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

#searchForm button:hover {
    filter: brightness(0.95);
}

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: stretch;
}

.filter-block {
    background-color: #fff;
    border: 2px solid #d5e2ee;
    border-radius: 10px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(25, 60, 92, 0.08);
}

.filter-block h3 {
    margin: 0;
    font-size: 1rem;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    color: #173a57;
    letter-spacing: 0.01em;
}

.filter-block > :not(h3) {
    padding-left: 0.6rem;
    padding-right: 0.6rem;
}

#biomarker-filter {
    border-color: #7cc8d3;
}

#biomarker-filter h3 {
    background: #d9f5f8;
}

#phase-filter {
    border-color: #8bb8f2;
}

#phase-filter h3 {
    background: #e5f0ff;
}

#status-filter {
    border-color: #90d0ae;
}

#status-filter h3 {
    background: #e4f7ec;
}

#type-filter {
    border-color: #d3b16d;
}

#type-filter h3 {
    background: #fff2d8;
}

#purpose-filter {
    border-color: #c9a5db;
}

#purpose-filter h3 {
    background: #f6e9ff;
}

#disease-filter {
    border-color: #ef9bb3;
}

#disease-filter h3 {
    background: #ffe7ef;
}

#location-filter {
    border-color: #f3b183;
}

#location-filter h3 {
    background: #ffeede;
}

.mobile-filter-stack {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
    height: 100%;
}

.mobile-filter-stack .filter-block {
    flex: 1 1 0;
    min-height: 0;
}

.mobile-filter-stack .filter-block ul {
    height: auto;
    flex: 1;
    min-height: 0;
}

.filter-stack {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
    height: 100%;
}

.filter-stack .filter-block {
    flex: 1 1 0;
    min-height: 0;
}

.filter-stack #phase-filter {
    flex: 3 1 0;
}

.filter-stack #type-filter {
    flex: 2 1 0;
}

.filter-stack .filter-block ul {
    height: auto;
    flex: 1;
    min-height: 0;
}

/* Sub-filter grouping inside Location filter */
.sub-filter {
    margin-top: 0.5rem;
}
.sub-filter h4 {
    margin: 0.25rem 0;
    font-size: 0.9rem;
    color: #333;
    border-bottom: 1px dashed #eee;
    padding-bottom: 0.2rem;
}
.sub-filter ul {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 150px;
    overflow-y: auto;
    font-size: 0.85rem;
}
.sub-filter li {
    margin-bottom: 0.25rem;
}

.filter-block ul {
    list-style: none;
    margin: 0;
    padding: 0.25rem 0.1rem 0.55rem;
    height: 220px;
    overflow-y: auto;
}

/* Nested list styling for location filter: indent sub-lists under United States */
#location-options li ul {
    list-style: none;
    margin: 0.25rem 0 0 1rem;
    padding-left: 0;
    border-left: 1px dashed #e5ad86;
    max-height: 150px;
    overflow-y: auto;
    font-size: 0.85rem;
}

/* Bold the group label for the United States header in the location filter */
#location-options > li > label {
    font-weight: bold;
    color: #333;
}

.filter-block li {
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.filter-block li label {
    display: inline-block;
    white-space: nowrap;
}

.filter-block input[type="checkbox"] {
    margin-right: 0.25rem;
}

.results {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.trial-card {
    background-color: #fff;
    border: 1px solid #d7e1ec;
    border-radius: 10px;
    padding: 1rem;
    box-shadow: 0 3px 10px rgba(36, 78, 113, 0.08);
}

.trial-card .card-header {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.5rem;
}

.trial-card .card-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
}

.trial-card h4 {
    margin: 0 0 0.25rem 0;
    font-size: 1.1rem;
    color: #065f9f;
}

.trial-card .meta {
    font-size: 0.9rem;
    color: #576a7d;
    margin-bottom: 0.5rem;
}

.trial-card button.toggle-details {
    background: linear-gradient(135deg, #0666b6, #0f87d8);
    color: #fff;
    border: none;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.82rem;
    margin-top: 0.5rem;
    align-self: start;
}

.trial-card button.toggle-details:hover {
    filter: brightness(0.95);
}

button.report-toggle {
    border: none;
    color: #fff;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.82rem;
    white-space: nowrap;
}

button.report-toggle.add {
    background: linear-gradient(135deg, #1b8f45, #28b65e);
}

button.report-toggle.remove {
    background: linear-gradient(135deg, #b4232d, #d43c46);
}

button.report-toggle:hover {
    filter: brightness(0.95);
}

.trial-card .details {
    display: none;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    line-height: 1.4;
}

.trial-card .details p {
    margin: 0.25rem 0;
}

.highlight {
    background-color: #fff59d;
    font-weight: bold;
    padding: 0 0.1rem;
}

.highlight-biomarker {
    background-color: #b3e5fc;
    font-weight: bold;
    padding: 0 0.1rem;
}

.nci-toggle {
    display: flex;
    align-items: center;
    margin-left: 0.5rem;
    font-size: 0.9rem;
    color: #28465f;
}
.nci-toggle input {
    margin-right: 0.3rem;
}

.debug-panel {
    margin-top: 1rem;
    padding: 1rem;
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    max-height: 300px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 0.8rem;
}

.raw-result-section {
    max-width: 1400px;
    margin: 0.5rem auto 0;
    width: 100%;
}

.raw-result-section > summary {
    cursor: pointer;
    font-size: 0.98rem;
    color: #28465f;
    font-weight: 600;
    list-style: disclosure-closed;
}

.raw-result-section[open] > summary {
    list-style: disclosure-open;
}

.filter-search {
    width: 100%;
    box-sizing: border-box;
    padding: 0.4rem 0.55rem;
    font-size: 0.85rem;
    border: 1px solid #bfd0df;
    border-radius: 6px;
    margin: 0.5rem 0 0.55rem;
}

.filter-search:focus {
    outline: none;
    border-color: #2f88d5;
    box-shadow: 0 0 4px rgba(47, 136, 213, 0.3);
}

.trial-search-section {
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
}

.trial-search-section input {
    width: 100%;
    max-width: 800px;
    padding: 0.65rem 1rem;
    font-size: 1rem;
    border: 2px solid #8ebce4;
    border-radius: 8px;
    background: #fff;
}

.trial-search-section input:focus {
    outline: none;
    box-shadow: 0 0 5px rgba(0, 102, 153, 0.25);
    border-color: #2f88d5;
}

.highlight-search {
    background-color: #c8e6c9;
    font-weight: bold;
    padding: 0 0.1rem;
}

.filter-block li.hidden {
    display: none;
}

@media (max-width: 768px) {
    .filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filter-stack {
        gap: 1rem;
        height: auto;
    }

    .filter-stack #phase-filter,
    .filter-stack #type-filter {
        flex: 1 1 auto;
    }

    .filter-stack .filter-block ul {
        flex: none;
        height: 170px;
        min-height: 170px;
    }

    .mobile-filter-stack {
        gap: 1rem;
        height: auto;
    }

    .mobile-filter-stack .filter-block {
        flex: 1 1 auto;
    }

    .mobile-filter-stack .filter-block ul {
        flex: none;
        height: 170px;
        min-height: 170px;
    }
}

@media (max-width: 480px) {
    .filters {
        grid-template-columns: 1fr;
    }

    .filter-stack {
        gap: 1rem;
    }

    .filter-stack .filter-block ul {
        height: 160px;
        min-height: 160px;
    }

    .mobile-filter-stack .filter-block ul {
        height: 160px;
        min-height: 160px;
    }

    #searchForm {
        flex-direction: column;
        align-items: stretch;
    }

    .nci-toggle {
        margin-left: 0;
    }
}

.quick-select-section {
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
}

.quick-select-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #e3f2fd;
    border: 1px solid #90caf9;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    color: #1565c0;
}

.quick-select-label:hover {
    background-color: #bbdefb;
}

.quick-select-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.disclaimer {
    text-align: center;
    padding: 1rem;
    margin-top: 2rem;
    background-color: #f5f5f5;
    border-top: 1px solid #ddd;
    color: #666;
    font-size: 0.9rem;
}

.disclaimer p {
    margin: 0;
}

.trial-title-link {
    color: inherit;
    text-decoration: none;
}

.trial-title-link:hover {
    color: #006699;
    text-decoration: underline;
}

.view-report-btn {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 900;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, #0666b6, #0f87d8);
    color: #fff;
    font-weight: 600;
    padding: 0.65rem 1rem;
    box-shadow: 0 6px 16px rgba(6, 102, 182, 0.3);
    cursor: pointer;
}

.view-report-btn:hover {
    filter: brightness(0.95);
}

.report-modal {
    position: fixed;
    inset: 0;
    z-index: 950;
    background: rgba(15, 31, 46, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    box-sizing: border-box;
}

.report-modal[hidden] {
    display: none;
}

.report-modal-content {
    width: min(700px, 100%);
    max-height: 80vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 10px;
    padding: 1rem;
    box-shadow: 0 8px 24px rgba(16, 40, 62, 0.25);
}

.report-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.report-modal-header h3 {
    margin: 0;
}

.close-report-btn {
    border: none;
    background: transparent;
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    color: #38546d;
}

.report-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.report-list li {
    border: 1px solid #d7e1ec;
    border-radius: 8px;
    padding: 0.65rem 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
}

.report-item-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.report-item-title {
    font-weight: 600;
    color: #174468;
}

.report-item-nct {
    font-size: 0.88rem;
    color: #4f6a81;
}

.report-empty {
    color: #5e7388;
    margin: 0.5rem 0 0;
}

.report-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.9rem;
}

.report-action-btn {
    border: none;
    border-radius: 6px;
    background: linear-gradient(135deg, #0666b6, #0f87d8);
    color: #fff;
    padding: 0.45rem 0.7rem;
    font-size: 0.84rem;
    cursor: pointer;
}

.report-action-btn:hover {
    filter: brightness(0.95);
}

.report-action-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.report-action-btn-danger {
    background: linear-gradient(135deg, #b4232d, #d43c46);
}

.report-action-status {
    margin: 0.6rem 0 0;
    font-size: 0.84rem;
    color: #335776;
    min-height: 1rem;
}
