/* ========================================================================
   Custom questionnaire editor — full-screen three-panel layout: pages on the
   left, the content of the selected page in the middle, settings on the right.
   Mirrors the custom report editor (report-canvas.css) so both editors read
   the same.
   ======================================================================== */

.cqe-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10010;
}

.custom-questionnaire-editor {
    background: #fff;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    padding: 12px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    font-family: RobotoCondensedRegular, Arial, sans-serif;
}

.cqe-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.cqe-name {
    width: 280px;
    padding: 6px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
}

.cqe-status {
    flex: 1;
    font-size: 13px;
    color: #008180;
}

.cqe-status-success {
    color: #065f46;
}

.cqe-status-error {
    color: #991b1b;
}

.cqe-btn-active {
    background: #e0f7f4;
}

.cqe-body {
    display: grid;
    grid-template-columns: 240px 1fr 380px;
    gap: 10px;
    flex: 1;
    min-height: 0;
}

/* The general-settings panel has no per-item settings, so it takes the room the
   right panel would otherwise occupy. */
.cqe-body-wide {
    grid-template-columns: 240px 1fr;
}

.cqe-sidebar, .cqe-inspector {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
    overflow: auto;
}

.cqe-canvas {
    min-width: 0;
    min-height: 0;
    overflow: auto;
}

.cqe-section-title, .cqe-inspector-title {
    font-weight: 600;
    font-size: 13px;
    color: #374151;
    margin-top: 4px;
}

/* --- Left panel: pages --------------------------------------------------- */

.cqe-sidebar-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

.cqe-sidebar-item:hover {
    background: #e0f7f4;
}

.cqe-sidebar-item.selected {
    background: #d1f0ec;
    font-weight: 600;
}

/* Drag-and-drop: the dragged page takes the highlighted page's slot. */
.cqe-sidebar-item.cqe-drop-target {
    outline: 2px dashed #0d9488;
    outline-offset: -2px;
}

.cqe-sidebar-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cqe-sidebar-meta {
    color: #6b7280;
    font-size: 11px;
}

.cqe-block {
    margin-top: 6px;
    width: 100%;
}

.cqe-mini {
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    padding: 0 2px;
    line-height: 1;
}

.cqe-mini:hover {
    color: #008180;
}

.cqe-mini:disabled {
    opacity: .35;
    cursor: default;
}

.cqe-mini-delete:hover {
    color: #dc2626;
}

/* --- Middle panel: page content ----------------------------------------- */

.cqe-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 4px;
}

.cqe-panel-title {
    font-weight: 600;
    font-size: 15px;
    color: #111827;
}

.cqe-page-head {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-left: 4px solid #008180;
    border-radius: 8px;
    background: #f8fafa;
    cursor: pointer;
}

.cqe-page-head.selected {
    background: #e0f7f4;
    border-color: #b6e3dd;
    border-left-color: #008180;
}

.cqe-page-title-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    box-sizing: border-box;
}

.cqe-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cqe-add-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.cqe-empty, .cqe-hint {
    color: #6b7280;
    font-size: 13px;
}

/* --- Cards (items and settings groups) ---------------------------------- */

.cqe-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
}

.cqe-card-title {
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .3px;
    color: #6b7280;
}

.cqe-item {
    cursor: pointer;
    border-left: 4px solid #e5e7eb;
}

.cqe-item:hover {
    border-color: #b6e3dd;
}

.cqe-item.selected {
    border-color: #b6e3dd;
    border-left-color: #008180;
    box-shadow: 0 0 0 2px rgba(0, 129, 128, .12);
}

.cqe-item-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cqe-item-actions {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
}

.cqe-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.cqe-badge-page {
    background: #e0f7f4;
    color: #008180;
}

.cqe-badge-question {
    background: #dbeafe;
    color: #2563eb;
}

.cqe-badge-text {
    background: #fef3e2;
    color: #b87a3d;
}

.cqe-type-label {
    font-size: 12px;
    color: #6b7280;
}

.cqe-flag {
    color: #008180;
    font-size: 13px;
}

.cqe-item-input {
    width: 100%;
}

/* --- Answer options ----------------------------------------------------- */

.cqe-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #f9fafb;
}

.cqe-options-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
    color: #6b7280;
}

.cqe-option-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.cqe-option-number {
    width: 18px;
    padding-top: 8px;
    font-size: 12px;
    color: #9ca3af;
    text-align: right;
}

.cqe-option-inputs {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.cqe-add-option {
    align-self: flex-start;
}

/* --- Fields ------------------------------------------------------------- */

.cqe-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 12px;
    color: #6b7280;
}

.cqe-field-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.cqe-field-label {
    font-size: 12px;
    color: #6b7280;
}

.cqe-check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
}

.cqe-number {
    width: 90px;
}

.cqe-color-input {
    width: 40px;
    height: 26px;
    padding: 0;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: none;
    cursor: pointer;
}

.cqe-lang-input-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cqe-lang-tag {
    min-width: 28px;
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
}

.cqe-button-text-input {
    width: 140px;
}

/* --- Languages ---------------------------------------------------------- */

.cqe-language-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.cqe-language-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 12px;
    background: #e0f7f4;
    color: #008180;
    font-size: 12px;
    font-weight: 700;
}

.cqe-language-remove {
    background: none;
    border: none;
    color: #008180;
    cursor: pointer;
    line-height: 1;
    padding: 0 2px;
}

.cqe-language-remove:hover {
    color: #dc2626;
}

.cqe-language-input {
    width: 60px;
    padding: 5px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    text-transform: uppercase;
    font-size: 12px;
}

/* --- Segmented switch (standard vs existing question type) -------------- */

.cqe-segmented {
    display: flex;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    overflow: hidden;
}

.cqe-segmented button {
    flex: 1;
    padding: 6px 10px;
    border: none;
    background: #fff;
    color: #374151;
    font-size: 12px;
    cursor: pointer;
}

.cqe-segmented button:hover {
    background: #f3f4f6;
}

.cqe-segmented button.active {
    background: #008180;
    color: #fff;
    font-weight: 600;
}

/* --- Delete-page confirmation ------------------------------------------ */

.cqe-confirm-dialog {
    max-width: 420px;
}

.cqe-confirm-name {
    font-weight: 600;
    color: #111827;
}
