/* ==========================================================================
   Clinical Trial Search — Laura's Search
   ========================================================================== */

/* ---------- Container ---------- */
.cts-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: #2c3e50;
    line-height: 1.6;
}

/* ---------- Intro ---------- */
.cts-intro {
    background: linear-gradient(135deg, #f0f4f8 0%, #e8eef5 100%);
    border-left: 4px solid #5b7fa5;
    border-radius: 6px;
    padding: 20px 24px;
    margin-bottom: 30px;
}
.cts-intro p {
    margin: 0 0 8px;
    font-size: 15px;
    color: #3a4a5c;
}
.cts-intro p:last-child {
    margin-bottom: 0;
}

/* ---------- Form ---------- */
.cts-form {
    background: #fff;
    border: 1px solid #dde3ea;
    border-radius: 8px;
    padding: 28px;
    margin-bottom: 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.cts-form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.cts-form-row:last-of-type {
    margin-bottom: 0;
}
.cts-form-row--primary .cts-field--condition {
    flex: 2;
    min-width: 200px;
}
.cts-form-row--primary .cts-field--location {
    flex: 1;
    min-width: 180px;
}
.cts-form-row--filters .cts-field {
    flex: 1;
    min-width: 160px;
}

.cts-field label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #34495e;
    margin-bottom: 6px;
}
.cts-required {
    color: #c0392b;
}
.cts-optional {
    font-weight: 400;
    color: #7f8c8d;
    font-size: 12px;
}

.cts-field input,
.cts-field select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #bdc3c7;
    border-radius: 6px;
    font-size: 15px;
    color: #2c3e50;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}
.cts-field input:focus,
.cts-field select:focus {
    outline: none;
    border-color: #5b7fa5;
    box-shadow: 0 0 0 3px rgba(91,127,165,0.15);
}
.cts-field input::placeholder {
    color: #95a5a6;
}

/* ---------- NCI Toggle ---------- */
.cts-form-row--nci {
    margin-top: 4px;
    margin-bottom: 0;
}

.cts-nci-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    padding: 8px 0;
}

.cts-nci-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.cts-nci-toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: #bdc3c7;
    border-radius: 12px;
    transition: background 0.2s;
    flex-shrink: 0;
}
.cts-nci-toggle-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.cts-nci-toggle input:checked + .cts-nci-toggle-switch {
    background: #2c6faa;
}
.cts-nci-toggle input:checked + .cts-nci-toggle-switch::after {
    transform: translateX(20px);
}

.cts-nci-toggle-label {
    font-size: 14px;
    font-weight: 600;
    color: #34495e;
    line-height: 1.3;
}
.cts-nci-toggle-hint {
    display: block;
    font-size: 12px;
    font-weight: 400;
    color: #7f8c8d;
}

/* ---------- NCI Badge & Card accent ---------- */
.cts-tag--nci {
    background: #1a5276;
    color: #fff;
}
.cts-study--nci {
    border-left: 3px solid #2c6faa;
}
.cts-study-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* ---------- Buttons ---------- */
.cts-form-actions {
    margin-top: 22px;
    text-align: center;
}

.cts-btn {
    display: inline-block;
    padding: 12px 32px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
.cts-btn:active {
    transform: scale(0.98);
}

.cts-btn--search {
    background: #5b7fa5;
    color: #fff;
    min-width: 220px;
}
.cts-btn--search:hover {
    background: #4a6d91;
}
.cts-btn--search:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

.cts-btn--more {
    background: #ecf0f1;
    color: #34495e;
    padding: 10px 28px;
    font-size: 14px;
}
.cts-btn--more:hover {
    background: #dde3ea;
}

/* ---------- Results Header ---------- */
.cts-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 2px solid #ecf0f1;
    flex-wrap: wrap;
    gap: 10px;
}
.cts-results-header h3 {
    margin: 0;
    font-size: 18px;
    color: #2c3e50;
    font-weight: 600;
}
.cts-results-count {
    font-size: 14px;
    color: #7f8c8d;
}

/* ---------- Source Filter Bar ---------- */
.cts-source-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
    padding: 10px 14px;
    background: #f4f6f7;
    border-radius: 6px;
    flex-wrap: wrap;
}
.cts-filter-label {
    font-size: 13px;
    font-weight: 600;
    color: #5a6a7a;
    margin-right: 4px;
}
.cts-filter-btn {
    padding: 5px 14px;
    border: 1px solid #dde3ea;
    border-radius: 20px;
    background: #fff;
    font-size: 13px;
    font-weight: 500;
    color: #5a6a7a;
    cursor: pointer;
    transition: all 0.2s;
}
.cts-filter-btn:hover {
    border-color: #5b7fa5;
    color: #2c3e50;
}
.cts-filter-btn--active {
    background: #5b7fa5;
    border-color: #5b7fa5;
    color: #fff;
}
.cts-filter-btn--active:hover {
    background: #4a6d91;
    border-color: #4a6d91;
    color: #fff;
}

/* ---------- Study Card ---------- */
.cts-study {
    background: #fff;
    border: 1px solid #dde3ea;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.03);
    transition: box-shadow 0.2s;
}
.cts-study:hover {
    box-shadow: 0 3px 12px rgba(0,0,0,0.07);
}

.cts-study-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.cts-study-title {
    font-size: 17px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
    flex: 1;
    line-height: 1.4;
}
.cts-study-title a {
    color: #2c6faa;
    text-decoration: none;
}
.cts-study-title a:hover {
    text-decoration: underline;
}

.cts-study-nct {
    font-size: 12px;
    color: #7f8c8d;
    background: #f4f6f7;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Tags row */
.cts-study-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.cts-tag {
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.cts-tag--status {
    background: #d4edda;
    color: #155724;
}
.cts-tag--status-other {
    background: #fff3cd;
    color: #856404;
}
.cts-tag--phase {
    background: #d6eaf8;
    color: #1a5276;
}
.cts-tag--type {
    background: #f0e6f6;
    color: #6c3483;
}

/* Summary */
.cts-study-summary {
    font-size: 14px;
    color: #4a5568;
    margin-bottom: 14px;
    line-height: 1.6;
}

/* Meta grid */
.cts-study-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}
.cts-meta-item {
    font-size: 13px;
    color: #5a6a7a;
}
.cts-meta-label {
    font-weight: 600;
    color: #34495e;
    display: inline;
}

/* Locations list */
.cts-study-locations {
    font-size: 13px;
    color: #5a6a7a;
    margin-bottom: 14px;
}
.cts-study-locations strong {
    color: #34495e;
}
.cts-study-locations ul {
    margin: 6px 0 0;
    padding-left: 18px;
}
.cts-study-locations li {
    margin-bottom: 3px;
}
.cts-locations-more {
    color: #7f8c8d;
    font-style: italic;
    font-size: 12px;
}

/* Expand/collapse */
.cts-study-details {
    display: none;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #ecf0f1;
}
.cts-study-details.cts-open {
    display: block;
}
.cts-study-details h4 {
    font-size: 14px;
    font-weight: 600;
    color: #34495e;
    margin: 14px 0 6px;
}
.cts-study-details h4:first-child {
    margin-top: 0;
}
.cts-eligibility-text {
    font-size: 13px;
    color: #4a5568;
    white-space: pre-line;
    max-height: 300px;
    overflow-y: auto;
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    line-height: 1.5;
}

/* Study footer */
.cts-study-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 14px;
    flex-wrap: wrap;
    gap: 10px;
}

.cts-toggle-details {
    background: none;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    padding: 6px 14px;
    font-size: 13px;
    color: #5a6a7a;
    cursor: pointer;
    transition: all 0.2s;
}
.cts-toggle-details:hover {
    background: #f4f6f7;
    border-color: #95a5a6;
}

.cts-study-link {
    display: inline-block;
    background: #5b7fa5;
    color: #fff !important;
    padding: 8px 18px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none !important;
    transition: background 0.2s;
}
.cts-study-link:hover {
    background: #4a6d91;
}

/* ---------- Contact info ---------- */
.cts-contact-info {
    font-size: 13px;
    color: #4a5568;
}
.cts-contact-info a {
    color: #2c6faa;
}

/* ---------- Pagination ---------- */
.cts-pagination {
    text-align: center;
    padding: 20px 0;
}

/* ---------- Error ---------- */
.cts-error {
    background: #fdf0f0;
    border: 1px solid #f5c6cb;
    border-left: 4px solid #c0392b;
    border-radius: 6px;
    padding: 16px 20px;
    margin-bottom: 20px;
    color: #721c24;
    font-size: 14px;
}

/* ---------- Attribution ---------- */
.cts-attribution {
    text-align: center;
    padding: 20px 0;
    border-top: 1px solid #ecf0f1;
    margin-top: 20px;
}
.cts-attribution p {
    font-size: 12px;
    color: #95a5a6;
    margin: 0;
}
.cts-attribution a {
    color: #7f8c8d;
    text-decoration: underline;
}

/* ---------- Loading spinner ---------- */
.cts-spinner {
    text-align: center;
    padding: 40px 0;
}
.cts-spinner::after {
    content: '';
    display: inline-block;
    width: 36px;
    height: 36px;
    border: 3px solid #dde3ea;
    border-top-color: #5b7fa5;
    border-radius: 50%;
    animation: cts-spin 0.7s linear infinite;
}
@keyframes cts-spin {
    to { transform: rotate(360deg); }
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
    .cts-form {
        padding: 18px;
    }
    .cts-form-row {
        flex-direction: column;
        gap: 14px;
    }
    .cts-study {
        padding: 18px;
    }
    .cts-study-header {
        flex-direction: column;
    }
    .cts-study-meta {
        grid-template-columns: 1fr;
    }
    .cts-study-footer {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
}
