/* Basic resets and typography */
html {
    font-family: 'Inter', sans-serif;
    background-color: #f6f7fb;
    color: #202124;
}

body {
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    background-color: #2c3e50;
    color: #ecf0f1;
    padding: 1.5rem 1rem;
    text-align: center;
}

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

header p {
    margin: 0;
    font-size: 1rem;
    line-height: 1.4;
}

main {
    flex: 1;
    padding: 2rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

form input[type="text"] {
    flex: 1 1 300px;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}

form button {
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
    border: none;
    border-radius: 4px;
    background-color: #3498db;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.2s;
}

form button:hover {
    background-color: #2980b9;
}

#status {
    margin-bottom: 1rem;
    font-weight: 600;
}

.hidden {
    display: none;
}

/* Visually-hidden but available to screen readers (used for the search input label). */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Consistent, visible keyboard-focus indicator for interactive controls. Uses
   :focus-visible so it only shows for keyboard/AT users, not on mouse clicks. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
    border-radius: 2px;
}

#resultSection h2 {
    margin-top: 0;
}

/* Summary table now uses a responsive grid layout to present key-value pairs as cards */
#summaryTable {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    list-style: none;
    padding: 0;
    border: none;
}
#summaryTable tr {
    display: contents;
}
#summaryTable th,
#summaryTable td {
    border: none;
    padding: 0.25rem 0;
}
#summaryTable th {
    font-weight: 600;
    color: #555;
    margin-right: 0.25rem;
}
#summaryTable td {
    font-weight: 400;
    color: #202124;
}

#rawDetails {
    margin-top: 1rem;
}

#rawOutput {
    white-space: pre-wrap;
    font-family: monospace;
    background-color: #f6f8fa;
    padding: 1rem;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
    max-height: 400px;
    overflow: auto;
}

/* Detailed sections styling */
#detailsContainer details {
    margin-bottom: 1rem;
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}
#detailsContainer details summary {
    font-weight: 600;
    cursor: pointer;
    outline: none;
    padding: 0.75rem 1rem;
    background-color: #f8f9fb;
}
#detailsContainer details[open] summary {
    border-bottom: 1px solid #e0e0e0;
}
#detailsContainer details table {
    width: 100%;
    border-collapse: collapse;
}
#detailsContainer details th,
#detailsContainer details td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid #f0f0f0;
}
#detailsContainer details tr:last-child th,
#detailsContainer details tr:last-child td {
    border-bottom: none;
}
#detailsContainer details th {
    background-color: #f8f9fb;
    font-weight: 600;
    width: 40%;
    color: #555;
}

footer {
    background-color: #f0f3f7;
    color: #555;
    text-align: center;
    padding: 1rem;
    font-size: 0.9rem;
}

footer a {
    color: #3498db;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Cards layout for displaying variant annotations */
.cards-container {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.card {
    background-color: #ffffff;
    border: 2px solid #d0d7e2;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
    padding: 0;
    position: relative;
    overflow: hidden;
}

.card h3 {
    margin: 0;
    padding: 0.7rem 1rem;
    font-size: 1rem;
    color: #1f2937;
    background-color: #eef2f7;
    border-bottom: 1px solid #d0d7e2;
}

.card .card-content {
    padding: 0.85rem 1rem 1rem;
    font-size: 0.95rem;
    line-height: 1.4;
}
.card .card-content span {
    display: block;
    margin-bottom: 0.25rem;
}
.card a {
    color: #3498db;
    text-decoration: none;
    font-weight: 600;
}
.card a:hover {
    text-decoration: underline;
}

/* Predictor emojis styling */
.predictor-emojis {
    font-size: 1.5rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Predictor summary in predictors card: show label and emoji pairs inline */
.predictor-summary {
    font-size: 1.1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.predictor-summary strong {
    margin-right: 0.15rem;
}

/* Style details within cards for predictor values */
.card-content details {
    margin-top: 0.5rem;
}
.card-content details summary {
    cursor: pointer;
    font-weight: 600;
    margin-bottom: 0.25rem;
}
.card-content details ul {
    margin: 0;
    padding-left: 1.2rem;
    list-style: disc;
}

/* Style tables inside card details (e.g., gnomAD population data) */
.card-content details table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.card-content details th,
.card-content details td {
    padding: 0.25rem 0.5rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid #f0f0f0;
}
.card-content details th {
    background-color: #f8f9fb;
    font-weight: 600;
    color: #555;
}



.card[data-card="variant"] {
    border-color: #93c5fd;
}
.card[data-card="variant"] h3 {
    background-color: #dbeafe;
    border-bottom-color: #93c5fd;
}

.card[data-card="clinvar"] {
    border-color: #c4b5fd;
}
.card[data-card="clinvar"] h3 {
    background-color: #ede9fe;
    border-bottom-color: #c4b5fd;
}

.card[data-card="gnomad"] {
    border-color: #6ee7b7;
}
.card[data-card="gnomad"] h3 {
    background-color: #d1fae5;
    border-bottom-color: #6ee7b7;
}

.card[data-card="predictors"] {
    border-color: #fcd34d;
}
.card[data-card="predictors"] h3 {
    background-color: #fef3c7;
    border-bottom-color: #fcd34d;
}

.card[data-card="oncokb"] {
    border-color: #fdba74;
}
.card[data-card="oncokb"] h3 {
    background-color: #ffedd5;
    border-bottom-color: #fdba74;
}

.card[data-card="cosmic"] {
    border-color: #f9a8d4;
}
.card[data-card="cosmic"] h3 {
    background-color: #fce7f3;
    border-bottom-color: #f9a8d4;
}

.card[data-card="search"] {
    border-color: #9ca3af;
}
.card[data-card="search"] h3 {
    background-color: #f3f4f6;
    border-bottom-color: #9ca3af;
}

.card[data-card="spliceai"] {
    border-color: #67e8f9;
}
.card[data-card="spliceai"] h3 {
    background-color: #cffafe;
    border-bottom-color: #67e8f9;
}

.card[data-card="civic"] {
    border-color: #a5b4fc;
}
.card[data-card="civic"] h3 {
    background-color: #e0e7ff;
    border-bottom-color: #a5b4fc;
}

.card[data-card="pubmed"] {
    border-color: #86efac;
}
.card[data-card="pubmed"] h3 {
    background-color: #dcfce7;
    border-bottom-color: #86efac;
}

.card[data-card="fda-approved-drugs-by-gene"] {
    border-color: #fca5a5;
}
.card[data-card="fda-approved-drugs-by-gene"] h3 {
    background-color: #fee2e2;
    border-bottom-color: #fca5a5;
}

.card[data-card="clinical-trials"] {
    border-color: #2dd4bf;
}
.card[data-card="clinical-trials"] h3 {
    background-color: #ccfbf1;
    border-bottom-color: #2dd4bf;
}

.card[data-card="guidelines"] {
    border-color: #bef264;
}
.card[data-card="guidelines"] h3 {
    background-color: #f7fee7;
    border-bottom-color: #bef264;
}

/* Card tab bar */
.card-tabs {
    display: flex;
    border-bottom: 1px solid #e5e7eb;
    margin: 0 0 0.75rem;
}
.card-tab-btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 600;
    border: none;
    border-bottom: 2px solid transparent;
    background: transparent;
    cursor: pointer;
    color: #6b7280;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
}
.card-tab-btn:hover {
    color: #374151;
}
.card-tab-btn.active {
    color: #1f2937;
    border-bottom-color: #4b5563;
}
.card-tab-panel {
    display: none;
}
.card-tab-panel.active {
    display: block;
}

/* Tumor type input row */
.tumor-type-row {
    flex-basis: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.tumor-type-row label {
    white-space: nowrap;
    font-size: 0.9rem;
    color: #4b5563;
    font-weight: 600;
}
.tumor-type-row .optional-label {
    font-weight: 400;
    font-style: italic;
    color: #9ca3af;
    font-size: 0.82rem;
}
.tumor-type-row input[type="text"] {
    flex: 1 1 220px;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
}

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

@media (max-width: 640px) {
    .cards-container {
        grid-template-columns: 1fr;
    }
}

/* Optional AI review panel */
.ai-review-card {
    grid-column: 1 / -1;
    border-color: #c7d2fe;
    background: linear-gradient(180deg, #ffffff 0%, #f8faff 100%);
}

.ai-review-intro,
.ai-review-summary,
.ai-review-rationale {
    margin: 0 0 0.75rem;
    line-height: 1.45;
}

.ai-review-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0.75rem 0;
}

.ai-review-controls label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
}

.ai-review-controls select {
    min-width: min(100%, 320px);
    padding: 0.45rem 0.55rem;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #fff;
    font-size: 0.9rem;
}

.ai-review-controls button {
    padding: 0.5rem 0.85rem;
    border: none;
    border-radius: 4px;
    background: #4f46e5;
    color: #fff;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
}

.ai-review-controls button:disabled {
    cursor: wait;
    opacity: 0.7;
}

/* Secondary action (e.g. Copy prompt) — lighter than the primary Run button */
.ai-review-controls .ai-review-secondary-btn {
    background: #eef2ff;
    color: #3730a3;
}
.ai-review-controls .ai-review-secondary-btn:hover {
    background: #e0e7ff;
}

/* Optional bring-your-own OpenRouter key */
.ai-review-key {
    margin: 0.25rem 0 0.5rem;
    font-size: 0.85rem;
}
.ai-review-key > summary {
    cursor: pointer;
    color: #4f46e5;
    font-weight: 600;
    padding: 0.15rem 0;
}
.ai-review-key-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0.4rem 0 0.3rem;
}
.ai-review-key-row input[type="password"] {
    flex: 1 1 240px;
    padding: 0.45rem 0.55rem;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font: inherit;
    font-size: 0.9rem;
}
.ai-review-key-remember {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.82rem;
    color: #4b5563;
    white-space: nowrap;
}
.ai-review-key-note {
    font-size: 0.78rem;
    color: #6b7280;
    line-height: 1.4;
}

/* Turnstile widget mount point (empty unless a site key is configured) */
.ai-review-turnstile:not(:empty) {
    margin: 0.5rem 0;
}

.ai-review-notes {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin: 0.75rem 0;
}

.ai-review-notes label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
}

.ai-review-notes textarea {
    width: 100%;
    min-height: 4.5rem;
    padding: 0.5rem 0.6rem;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #fff;
    font: inherit;
    font-size: 0.9rem;
    line-height: 1.4;
    resize: vertical;
    box-sizing: border-box;
}

.ai-review-notes textarea:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.ai-review-output {
    margin-top: 0.75rem;
}

.ai-review-disclaimer,
.ai-review-loading,
.ai-review-error,
.ai-review-empty {
    padding: 0.55rem 0.65rem;
    border-radius: 4px;
    font-size: 0.82rem;
    line-height: 1.4;
}

.ai-review-disclaimer {
    margin-bottom: 0.75rem;
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.ai-review-loading,
.ai-review-empty {
    background: #f8fafc;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.ai-review-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.ai-review-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.ai-review-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.55rem;
    border-radius: 999px;
    background: #eef2ff;
    color: #3730a3;
    font-size: 0.82rem;
    font-weight: 700;
}

.ai-review-output h4 {
    margin: 0.85rem 0 0.35rem;
    font-size: 0.95rem;
    color: #1f2937;
}

.ai-review-list {
    margin: 0.25rem 0 0.75rem 1.25rem;
    padding: 0;
}

.ai-review-list li {
    margin-bottom: 0.35rem;
    line-height: 1.4;
}
