@import './tokens.css';

/* Base reset for embedded components */
.cxi * {
    box-sizing: border-box;
}

.cxi {
    font-family: var(--font-system);
    color: var(--ink);
    line-height: 1.5;
    font-size: 16px;
}

/* Focus styles */
.cxi :focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
    border-radius: 6px;
}

/* Modal shell */
.cxi-modal-backdrop {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.cxi-modal {
    width: min(680px, 92vw);
    background: linear-gradient(180deg, var(--surface), var(--surface-2));
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid #eef2f7;
    overflow: hidden;
}

.cxi-modal-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px var(--pad);
    background: linear-gradient(90deg, var(--accent-50), transparent 60%);
    border-bottom: 1px solid #eef2f7;
}

.cxi-badge {
    font-size: 12px;
    color: var(--muted);
    border: 1px solid #e5e7eb;
    padding: 2px 8px;
    border-radius: 999px;
    background: #fff;
}

.cxi-title {
    margin: 0;
    font-weight: 800;
    letter-spacing: -0.01em;
    font-size: clamp(22px, 3vw, 28px);
}

.cxi-modal-body {
    padding: 16px var(--pad) 8px;
}

.cxi-modal-body p {
    margin: 0 0 10px 0;
    color: var(--muted);
}

.cxi-perks {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 10px 0 6px;
}

.cxi-perk {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px dashed #dbe4ee;
    background: #fff;
    color: var(--ink);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 13px;
}

/* Button row */
.cxi-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px var(--pad) 18px;
}

.cxi-btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 12px 14px;
    font-weight: 700;
    cursor: pointer;
}

.cxi-btn-primary {
    background: var(--accent);
    color: #fff;
}

.cxi-btn-primary:hover {
    background: var(--accent-600);
}

.cxi-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cxi-btn-ghost {
    background: #fff;
    border-color: #e5e7eb;
    color: var(--ink);
}

/* Survey panel */
.cxi-panel {
    width: min(780px, 96vw);
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    border: 1px solid #eef2f7;
    margin: 16px auto;
    overflow: hidden;
}

.cxi-panel-head {
    padding: 16px var(--pad);
    background: #f8fafc;
    border-bottom: 1px solid #eef2f7;
}

.cxi-panel-title {
    margin: 0;
    font-size: clamp(18px, 2.6vw, 22px);
    font-weight: 800;
    letter-spacing: -0.01em;
}

.cxi-panel-sub {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.cxi-panel-body {
    padding: 14px var(--pad);
    display: grid;
    gap: 14px;
}

.cxi-field label {
    font-weight: 700;
    display: block;
    margin-bottom: 6px;
}

.cxi-hint {
    color: var(--subtle);
    font-size: 12px;
}

.cxi-input,
.cxi-textarea {
    width: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px 12px;
    font: inherit;
    background: #fff;
}

.cxi-textarea {
    min-height: 74px;
    resize: vertical;
}

.cxi-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cxi-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 999px;
    border: 1px solid #dbe4ee;
    background: #fff;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
}

.cxi-chip[data-state="pos"] {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #15803d;
}

.cxi-chip[data-state="neg"] {
    background: #fee2e2;
    border-color: #fecaca;
    color: #991b1b;
}

.cxi-chip[data-state="neu"] {
    background: #fff;
    color: var(--ink);
}

.cxi-chip .dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #cbd5e1;
}

.cxi-chip[data-state="pos"] .dot {
    background: #10b981;
}

.cxi-chip[data-state="neg"] .dot {
    background: #ef4444;
}

.cxi-conflict {
    background: #fffbeb;
    border: 1px solid #fef3c7;
    border-radius: 12px;
    padding: 12px;
}

.cxi-conflict h4 {
    margin: 0 0 6px 0;
    font-size: 14px;
    color: #854d0e;
}

.cxi-conflict-quote {
    font-style: italic;
    color: #78350f;
    font-size: 12px;
}

.cxi-panel-foot {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    padding: 12px var(--pad) 16px;
    border-top: 1px solid #eef2f7;
    background: #fff;
}

.cxi-progress {
    color: var(--subtle);
    font-size: 12px;
}

/* Action plan widget */
.cxi-plan {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px;
    background: #f9fafb;
}

.cxi-plan h4 {
    margin: 0 0 8px 0;
}

.cxi-plan ul {
    margin: 6px 0 0 18px;
}