/* Question Overview page */

#qo-page {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.qo-section {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    overflow: hidden;
}

.qo-section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.qo-section-toggle {
    background: none;
    border: none;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1 1 auto;
    text-align: left;
    font-weight: 600;
    color: #212529;
    cursor: pointer;
}

.qo-section-toggle:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
    border-radius: 0.25rem;
}

.qo-section-caret {
    transition: transform 0.15s ease;
    font-size: 1rem;
}

.qo-section[aria-collapsed="true"] .qo-section-caret {
    transform: rotate(-90deg);
}

.qo-section[aria-collapsed="true"] .qo-section-body {
    display: none;
}

.qo-section-body {
    padding: 0.5rem 1rem 1rem;
}

.qo-empty-section {
    padding: 1rem 0.25rem;
    color: #6c757d;
    font-size: 0.875rem;
}

.qo-rows {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-top: 0.5rem;
}

.qo-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.75rem;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 0.375rem;
    transition: background-color 0.15s ease, opacity 0.25s ease;
}

.qo-row.qo-row-removing {
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.qo-row:hover {
    background: #f8f9fa;
}

.qo-row-main {
    flex: 1 1 auto;
    min-width: 0;
}

.qo-row-text {
    font-weight: 500;
    color: #212529;
    word-break: break-word;
}

.qo-row-text p:last-child,
.qo-row-text :last-child {
    margin-bottom: 0;
}

.qo-row-help {
    margin-top: 0.25rem;
    color: #6c757d;
    font-size: 0.875rem;
    word-break: break-word;
}

.qo-row-help p:last-child,
.qo-row-help :last-child {
    margin-bottom: 0;
}

.qo-row-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.375rem;
}

.qo-row-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.5rem;
}

.qo-option-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1;
}

.qo-row-actions {
    display: flex;
    gap: 0.375rem;
    flex: 0 0 auto;
}

.qo-row-actions .btn {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Dialog (native <dialog>) */

.qo-dialog {
    padding: 0;
    border: none;
    border-radius: 0.5rem;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175);
    max-width: 720px;
    width: calc(100% - 2rem);
    max-height: calc(100vh - 2rem);
    background: #fff;
}

.qo-dialog-sm {
    max-width: 440px;
}

.qo-dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
}

.qo-dialog[open] {
    display: flex;
    flex-direction: column;
}

.qo-dialog-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #dee2e6;
}

.qo-dialog-title {
    margin: 0;
    flex: 1 1 auto;
    font-size: 1.125rem;
}

.qo-dialog-body {
    padding: 1rem 1.25rem;
    overflow-y: auto;
    flex: 1 1 auto;
}

.qo-dialog-footer {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
}

.qo-rte {
    min-height: 140px;
    background: #fff;
}

.qo-rte-small {
    min-height: 80px;
}

.qo-options-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.qo-option-row {
    padding: 0.75rem;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 0.375rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.qo-option-fields {
    display: grid;
    gap: 0.5rem;
    grid-template-columns: 1fr;
}

.qo-option-actions {
    display: flex;
    gap: 0.375rem;
    justify-content: flex-end;
}

/* Toast */

.qo-toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.qo-toast {
    pointer-events: auto;
    min-width: 240px;
    max-width: 380px;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    color: #fff;
    background: #212529;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    font-size: 0.875rem;
    opacity: 0;
    transform: translateY(-8px);
    animation: qo-toast-in 0.2s forwards;
}

.qo-toast.qo-toast-out {
    animation: qo-toast-out 0.25s forwards;
}

.qo-toast-success { background: #198754; }
.qo-toast-danger  { background: #dc3545; }
.qo-toast-warning { background: #fd7e14; color: #212529; }
.qo-toast-info    { background: #0d6efd; }

@keyframes qo-toast-in {
    to { opacity: 1; transform: translateY(0); }
}

@keyframes qo-toast-out {
    to { opacity: 0; transform: translateY(-8px); }
}

/* Desktop layout for option fields */
@media (min-width: 768px) {
    .qo-option-fields {
        grid-template-columns: 2fr 0.6fr 1.2fr 1fr;
        align-items: end;
    }
}

/* Mobile */
@media (max-width: 575.98px) {
    .qo-row {
        flex-direction: column;
    }

    .qo-row-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .qo-dialog {
        width: 100%;
        max-width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        margin: 0;
    }

    .qo-dialog-footer {
        position: sticky;
        bottom: 0;
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    }

    .qo-toast-container {
        top: auto;
        bottom: calc(1rem + env(safe-area-inset-bottom));
        left: 1rem;
        right: 1rem;
    }

    .qo-toast {
        max-width: none;
    }
}
