/**
 * Experiments Page CSS - A/B Testing and Cohort Builder
 */

/* ============================================
   EXPERIMENT TABS
   ============================================ */
.experiments-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
}

.exp-tab {
    padding: 10px 20px;
    border: none;
    background: var(--bg-warm);
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.exp-tab.active {
    background: var(--accent);
    color: white;
}

.exp-tab:hover:not(.active) {
    background: var(--bg-cream);
}

.exp-content {
    display: none;
}

.exp-content.active {
    display: block;
}

/* ============================================
   A/B TESTING FORM ELEMENTS
   ============================================ */
.select-field {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.2s;
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8480' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

.select-field:focus {
    outline: none;
    border-color: var(--accent);
}

.select-field:hover {
    border-color: var(--text-muted);
}

.input-field {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    font-family: 'DM Mono', monospace;
    font-size: 13px;
    color: var(--text);
    transition: border-color 0.2s;
    -moz-appearance: textfield;
}

.input-field::-webkit-outer-spin-button,
.input-field::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-field:focus {
    outline: none;
    border-color: var(--accent);
}

/* RCT Config Sections */
.rct-config-section {
    margin: 20px 0;
}

.rct-config-section .form-label {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 12px;
    display: block;
}

/* Checkbox Grid */
.checkbox-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    color: var(--text);
}

.checkbox-item:hover {
    border-color: var(--accent);
    background: var(--bg-cream);
}

.checkbox-item:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
}

.checkbox-item input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: 4px;
    background: var(--bg-card);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    flex-shrink: 0;
}

.checkbox-item input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.checkbox-item input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-item input[type="checkbox"]:hover {
    border-color: var(--accent);
}

/* Form Actions */
.form-actions {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* ============================================
   A/B TESTING
   ============================================ */
.ab-config {
    display: flex;
    align-items: center;
    gap: 20px;
    margin: 20px 0;
}

.variant-card {
    flex: 1;
    background: var(--bg-cream);
    border-radius: 12px;
    padding: 20px;
}

.variant-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.variant-badge {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: white;
}

.variant-badge.a { background: var(--sage); }
.variant-badge.b { background: var(--accent); }

.variant-title {
    font-size: 14px;
    font-weight: 500;
}

.config-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.vs-divider {
    font-size: 14px;
    color: var(--text-muted);
    font-style: italic;
    flex-shrink: 0;
}

/* Experiment List */
.experiment-list {
    margin-top: 32px;
}

.experiment-item {
    background: var(--bg-card);
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
}

.experiment-item.expanded {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.experiment-row {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.15s;
}

.experiment-row:hover {
    background: var(--bg-cream);
}

.experiment-info {
    flex: 1;
}

.experiment-name {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 4px;
}

.experiment-meta {
    font-size: 12px;
    color: var(--text-muted);
    font-family: 'DM Mono', monospace;
}

.experiment-results {
    display: flex;
    gap: 24px;
    margin-right: 24px;
}

.experiment-stat {
    text-align: center;
}

.experiment-stat-value {
    font-size: 20px;
    font-weight: 600;
    font-family: 'DM Mono', monospace;
}

.experiment-stat-value.winner { color: var(--sage); }

.experiment-stat-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-family: 'DM Mono', monospace;
}

.experiment-toggle {
    transition: transform 0.2s;
}

.experiment-toggle.rotated {
    transform: rotate(90deg);
}

/* ============================================
   EXPERIMENT DETAIL (Expandable)
   ============================================ */
.experiment-detail {
    display: none;
    padding: 0 20px 20px;
    background: var(--bg-cream);
    border-top: 1px solid var(--border);
}

.experiment-detail.open {
    display: block;
}

.experiment-detail-loading,
.experiment-detail-error {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.experiment-detail-error {
    color: var(--accent);
}

.experiment-detail-content {
    padding-top: 16px;
}

.arms-comparison {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 16px;
}

.arm-section {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 16px;
}

.arm-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.arm-label {
    font-weight: 500;
    font-size: 14px;
}

.arm-run-count {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'DM Mono', monospace;
}

.arm-scores {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.arm-score {
    text-align: center;
    flex: 1;
}

.arm-score-value {
    font-size: 18px;
    font-weight: 600;
    font-family: 'DM Mono', monospace;
    color: var(--text);
}

.arm-score-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-family: 'DM Mono', monospace;
}

.arm-personas-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-family: 'DM Mono', monospace;
    margin-bottom: 10px;
}

.arm-persona {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: var(--bg-cream);
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 12px;
}

.persona-name {
    font-weight: 500;
    flex: 1;
}

.persona-scenario {
    color: var(--text-muted);
    font-size: 11px;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.persona-scores {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--text-muted);
}

.persona-pass {
    color: var(--sage);
    font-weight: 600;
}

.persona-fail {
    color: var(--accent);
    font-weight: 600;
}

/* Comparison Divider */
.comparison-divider {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 12px;
}

.comparison-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-family: 'DM Mono', monospace;
    margin-bottom: 12px;
    text-align: center;
}

.comparison-deltas {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.delta {
    font-size: 12px;
    font-family: 'DM Mono', monospace;
    padding: 6px 12px;
    border-radius: 6px;
    background: var(--bg-warm);
    text-align: center;
}

.delta.positive {
    background: var(--sage-light);
    color: var(--sage);
}

.delta.negative {
    background: var(--accent-light);
    color: var(--accent);
}

/* ============================================
   COHORT BUILDER
   ============================================ */
.cohort-builder {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.cohort-input-panel,
.cohort-preview-panel {
    background: var(--bg-card);
    border-radius: 14px;
    padding: 24px;
}

.cohort-textarea {
    width: 100%;
    min-height: 120px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
    margin-bottom: 16px;
    line-height: 1.6;
}

.cohort-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.cohort-preview {
    background: var(--bg-cream);
    border-radius: 10px;
    padding: 16px;
    font-size: 13px;
    line-height: 1.6;
}

.cohort-preview pre {
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Cohort Actions */
.cohort-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

/* Cohort Jobs List */
.cohort-jobs {
    margin-top: 32px;
}

.cohort-job {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 12px;
}

.cohort-job-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.cohort-job-name {
    font-size: 15px;
    font-weight: 500;
}

.cohort-job-status {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 12px;
    font-family: 'DM Mono', monospace;
}

.cohort-job-status.pending {
    background: var(--gold-light);
    color: var(--gold);
}

.cohort-job-status.running {
    background: var(--accent-light);
    color: var(--accent);
}

.cohort-job-status.completed {
    background: var(--sage-light);
    color: var(--sage);
}

.cohort-job-progress {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.cohort-job-progress-bar {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
    .cohort-builder {
        grid-template-columns: 1fr;
    }

    .ab-config {
        flex-direction: column;
    }

    .vs-divider {
        padding: 10px 0;
    }

    .variant-card {
        width: 100%;
    }
}
