/* OncoGrant Intelligence — Clean, professional UI */

:root {
    --primary: #1a56db;
    --primary-dark: #1e40af;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

header {
    background: var(--primary-dark);
    color: white;
    padding: 1.5rem 2rem;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.subtitle {
    color: rgba(255,255,255,0.8);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.stats-bar {
    display: flex;
    gap: 2rem;
    padding: 0.75rem 2rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-size: 0.8125rem;
    color: var(--text-secondary);
    align-items: center;
}

.sync-btn {
    margin-left: auto;
    padding: 0.35rem 0.75rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.sync-btn:hover { background: var(--primary-dark); }
.sync-btn:disabled { background: var(--text-secondary); cursor: not-allowed; }

/* Tab navigation */
.tab-bar {
    display: flex;
    gap: 0;
    background: var(--surface);
    border-bottom: 2px solid var(--border);
    padding: 0 2rem;
}

.tab {
    padding: 0.75rem 1.5rem;
    border: none;
    background: none;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
}

.tab:hover { color: var(--text); }
.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

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

/* Sync banner */
.sync-banner {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.sync-banner-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sync-banner-content p {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 0.125rem;
}

.small-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #bfdbfe;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

.input-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.input-panel h2 {
    font-size: 1.125rem;
    margin-bottom: 0.75rem;
}

textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.875rem;
    resize: vertical;
    min-height: 150px;
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

.filters {
    display: flex;
    gap: 1rem;
    margin: 1rem 0;
    flex-wrap: wrap;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.checkbox-group {
    justify-content: flex-end;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-transform: none;
    font-weight: 400;
    cursor: pointer;
}

select, input[type="text"], input[type="email"] {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: white;
    font-family: inherit;
}

input[type="text"]:focus, input[type="email"]:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

.btn-row {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

button#match-btn, button[type="submit"] {
    flex: 1;
    padding: 0.75rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

button#match-btn:hover, button[type="submit"]:hover {
    background: var(--primary-dark);
}

button#match-btn:disabled, button[type="submit"]:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
}

.btn-secondary {
    padding: 0.75rem 1.25rem;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover { background: var(--bg); }

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    cursor: pointer;
}

.btn-small:hover { background: var(--bg); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }

/* Browse opportunities */
.browse-panel {
    margin-bottom: 1.5rem;
}

.browse-panel h2 {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.browse-summary {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.opp-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 0.5rem;
    transition: box-shadow 0.2s;
}

.opp-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.opp-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.opp-title {
    flex: 1;
    font-weight: 600;
    font-size: 0.875rem;
}

.opp-title a {
    color: var(--primary);
    text-decoration: none;
}

.opp-title a:hover { text-decoration: underline; }

.opp-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.status-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
}

.status-open {
    background: #ecfdf5;
    color: var(--success);
}

.status-closed {
    background: #fef2f2;
    color: var(--danger);
}

/* Results */
.results-panel {
    margin-top: 1.5rem;
}

.results-panel h2 {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.results-summary {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.result-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: box-shadow 0.2s;
}

.result-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.result-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.result-title {
    flex: 1;
    font-weight: 600;
    font-size: 0.9375rem;
}

.result-title a {
    color: var(--primary);
    text-decoration: none;
}

.result-title a:hover { text-decoration: underline; }

.result-score {
    flex-shrink: 0;
    text-align: right;
}

.score-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--success);
}

.score-label {
    font-size: 0.6875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.result-meta {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.meta-tag {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background: #f1f5f9;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.mechanism-tag {
    background: #ede9fe;
    color: #7c3aed;
}

.disease-tag {
    background: #fef3c7;
    color: #92400e;
}

.result-justification {
    font-size: 0.875rem;
    color: var(--text);
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.result-risks {
    margin-bottom: 0.5rem;
}

.risk-tag {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background: #fef3c7;
    color: var(--warning);
    border-radius: 4px;
    font-size: 0.75rem;
    margin-right: 0.25rem;
    margin-bottom: 0.25rem;
}

.score-breakdown {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.breakdown-item {
    font-size: 0.6875rem;
    color: var(--text-secondary);
}

.breakdown-bar {
    display: inline-block;
    height: 4px;
    background: var(--primary);
    border-radius: 2px;
    margin-left: 0.25rem;
    vertical-align: middle;
}

.result-sources {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.result-sources summary {
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.source-item {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.source-item a { color: var(--primary); }

/* Loading */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-panel {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: 1rem;
    color: var(--danger);
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* ==================== DEADLINES ==================== */

.deadlines-panel h2 {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.deadlines-header {
    display: flex;
    justify-content: space-between;
    align-items: end;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.deadline-month h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.deadline-month {
    margin-bottom: 1.5rem;
}

.deadline-item {
    display: flex;
    gap: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 0.5rem;
    transition: box-shadow 0.2s;
}

.deadline-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.deadline-item.urgent {
    border-left: 3px solid var(--danger);
}

.deadline-item.soon {
    border-left: 3px solid var(--warning);
}

.deadline-date-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 60px;
    flex-shrink: 0;
}

.deadline-day {
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--text);
}

.deadline-remaining {
    font-size: 0.6875rem;
    color: var(--text-secondary);
}

.urgent .deadline-remaining { color: var(--danger); font-weight: 600; }
.soon .deadline-remaining { color: var(--warning); font-weight: 600; }

.deadline-info {
    flex: 1;
}

.deadline-title {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.deadline-title a {
    color: var(--primary);
    text-decoration: none;
}

.deadline-title a:hover { text-decoration: underline; }

.deadline-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.deadline-type-tag {
    background: #dbeafe;
    color: var(--primary);
}

/* ==================== PROFILE ==================== */

.profile-panel h2 {
    font-size: 1.125rem;
    margin-bottom: 0.25rem;
}

.profile-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.profile-cards {
    margin-bottom: 1rem;
}

.profile-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
}

.profile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.profile-actions {
    display: flex;
    gap: 0.5rem;
}

.profile-card-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.profile-abstract-preview {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-style: italic;
}

.text-secondary { color: var(--text-secondary); }

.profile-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-row .form-group {
    flex: 1;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.form-group .hint {
    font-weight: 400;
    color: var(--text-secondary);
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
}

/* ==================== ASK AI ==================== */

.ask-examples {
    margin: 1rem 0;
    padding: 1rem;
    background: #f0f9ff;
    border-radius: var(--radius);
}

.ask-examples p {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.example-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.example-chip {
    padding: 0.375rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    text-align: left;
}

.example-chip:hover {
    background: #dbeafe;
    border-color: var(--primary);
}

#ask-input {
    min-height: 80px;
}

#ask-btn {
    flex: 1;
    padding: 0.75rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#ask-btn:hover { background: var(--primary-dark); }
#ask-btn:disabled { background: var(--text-secondary); cursor: not-allowed; }

.ask-loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.ask-result {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.answer-text {
    font-size: 0.9375rem;
    line-height: 1.7;
    color: var(--text);
}

.answer-text p { margin-bottom: 0.75rem; }

.sources-summary {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.ask-history-panel {
    margin-top: 1.5rem;
}

.ask-history-panel h3 {
    font-size: 0.9375rem;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.ask-history-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    overflow: hidden;
}

.ask-history-q {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.ask-history-q:hover { background: var(--bg); }

.ask-history-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
    flex-shrink: 0;
    min-width: 80px;
}

.ask-history-question {
    font-size: 0.875rem;
    font-weight: 500;
}

.ask-history-a {
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
    color: var(--text);
    background: var(--bg);
    border-top: 1px solid var(--border);
    line-height: 1.6;
}

/* ==================== PROFILE ALERTS ==================== */

.alert-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.alert-section h3 {
    font-size: 0.9375rem;
    margin-bottom: 0.75rem;
}

.alert-toggle {
    justify-content: center;
}

.profile-alert-badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    background: #ecfdf5;
    color: var(--success);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.375rem;
}

footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

@media (max-width: 640px) {
    .stats-bar { flex-wrap: wrap; gap: 0.75rem; }
    .tab-bar { padding: 0 1rem; }
    .tab { padding: 0.75rem 1rem; font-size: 0.8125rem; }
    .filters { flex-direction: column; }
    .result-header { flex-direction: column; }
    .opp-header { flex-direction: column; }
    .form-row { flex-direction: column; }
    .deadlines-header { flex-direction: column; }
    .deadline-item { flex-direction: column; gap: 0.5rem; }
    .deadline-date-col { flex-direction: row; gap: 0.5rem; }
}
