/*
 * File: assets/css/pi9-questionnaire.css
 * Styles for Pi9 Questionnaire — front-end form and admin question builder.
 *
 * @package Pi9Questionnaire
 */

/* ============================================================
   CSS Custom Properties
   ============================================================ */
:root {
    --pi9q-primary:  #0C3F3F;
    --pi9q-accent:   #f2633a;
    --pi9q-text:     #1a1a1a;
    --pi9q-muted:    #555555;
    --pi9q-border:   #d1d5db;
    --pi9q-card-bg:  #f8f9fa;
    --pi9q-error:    #b32d2e;
    --pi9q-success:  #1a6e3c;
    --pi9q-radius:   6px;
    --pi9q-spacing:  1.25rem;
}

/* ============================================================
   Front-end: Form Wrapper
   ============================================================ */
.pi9q-form-wrap {
    max-width: 760px;
    margin: 0 auto;
    font-size: 1rem;
    color: var(--pi9q-text);
}

.pi9q-title {
    color: var(--pi9q-primary);
    margin-bottom: 0.5rem;
}

.pi9q-description {
    color: var(--pi9q-muted);
    margin-bottom: var(--pi9q-spacing);
}

/* ============================================================
   Front-end: Question Block
   ============================================================ */
.pi9q-question-block {
    background: var(--pi9q-card-bg);
    border: 1px solid var(--pi9q-border);
    border-radius: var(--pi9q-radius);
    padding: var(--pi9q-spacing);
    margin-bottom: var(--pi9q-spacing);
    transition: border-color 0.15s ease;
}

.pi9q-question-block.pi9q-has-error {
    border-color: var(--pi9q-error);
}

/* ============================================================
   Front-end: Labels
   ============================================================ */
.pi9q-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--pi9q-text);
}

.pi9q-label--inline {
    display: inline;
    margin-left: 0.4rem;
}

.pi9q-required {
    color: var(--pi9q-error);
    margin-left: 2px;
    font-weight: 700;
}

/* ============================================================
   Front-end: Help Text
   ============================================================ */
.pi9q-help {
    display: block;
    color: var(--pi9q-muted);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

/* ============================================================
   Front-end: Inputs
   ============================================================ */
.pi9q-textarea,
.pi9q-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--pi9q-border);
    border-radius: var(--pi9q-radius);
    padding: 0.55rem 0.75rem;
    font-size: 1rem;
    color: var(--pi9q-text);
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pi9q-textarea:focus,
.pi9q-input:focus {
    outline: none;
    border-color: var(--pi9q-primary);
    box-shadow: 0 0 0 3px rgba(12, 63, 63, 0.15);
}

.pi9q-textarea {
    resize: vertical;
    min-height: 100px;
}

/* ============================================================
   Front-end: Radio & Checkbox Groups
   ============================================================ */
.pi9q-radio-group,
.pi9q-checkbox-group {
    border: none;
    padding: 0;
    margin: 0;
}

.pi9q-radio-group legend,
.pi9q-checkbox-group legend {
    font-weight: 600;
    margin-bottom: 0.4rem;
    padding: 0;
    color: var(--pi9q-text);
}

.pi9q-radio-option,
.pi9q-checkbox-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.pi9q-radio-option input[type="radio"],
.pi9q-checkbox-option input[type="checkbox"] {
    flex-shrink: 0;
    width: 1.1em;
    height: 1.1em;
    accent-color: var(--pi9q-primary);
}

.pi9q-single-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.pi9q-single-checkbox input[type="checkbox"] {
    flex-shrink: 0;
    width: 1.1em;
    height: 1.1em;
    margin-top: 2px;
    accent-color: var(--pi9q-primary);
}

/* ============================================================
   Front-end: Error Messages
   ============================================================ */
.pi9q-error {
    color: var(--pi9q-error);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    padding: 0.4rem 0.6rem;
    background: #fff0f0;
    border-left: 3px solid var(--pi9q-error);
    border-radius: 3px;
}

.pi9q-error-summary {
    background: #fff0f0;
    border: 1px solid var(--pi9q-error);
    border-left: 4px solid var(--pi9q-error);
    border-radius: var(--pi9q-radius);
    padding: var(--pi9q-spacing);
    margin-bottom: var(--pi9q-spacing);
    color: var(--pi9q-error);
}

.pi9q-error-summary p {
    margin: 0 0 0.5rem;
}

.pi9q-error-summary ul {
    margin: 0;
    padding-left: 1.25rem;
}

.pi9q-error-summary a {
    color: var(--pi9q-error);
    text-decoration: underline;
}

/* ============================================================
   Front-end: Success Box
   ============================================================ */
.pi9q-success {
    background: #f0faf4;
    border: 1px solid #1a6e3c;
    border-left: 4px solid var(--pi9q-success);
    border-radius: var(--pi9q-radius);
    padding: var(--pi9q-spacing);
    margin-bottom: var(--pi9q-spacing);
    color: var(--pi9q-success);
    font-weight: 600;
}

.pi9q-success p {
    margin: 0;
}

/* ============================================================
   Front-end: Notice (closed/inactive)
   ============================================================ */
.pi9q-notice {
    background: var(--pi9q-card-bg);
    border: 1px solid var(--pi9q-border);
    border-left: 4px solid var(--pi9q-primary);
    border-radius: var(--pi9q-radius);
    padding: var(--pi9q-spacing);
    color: var(--pi9q-muted);
}

/* ============================================================
   Front-end: CTA for Anonymous Users
   ============================================================ */
.pi9q-cta {
    background: var(--pi9q-card-bg);
    border: 1px solid var(--pi9q-border);
    border-radius: var(--pi9q-radius);
    padding: var(--pi9q-spacing);
    margin-top: var(--pi9q-spacing);
}

.pi9q-cta p {
    margin-top: 0;
}

.pi9q-member-btn {
    display: inline-block;
    background: var(--pi9q-accent);
    color: #fff !important;
    border: none;
    border-radius: var(--pi9q-radius);
    padding: 0.6rem 1.2rem;
    font-weight: 700;
    text-decoration: none;
    transition: background 0.15s ease;
}

.pi9q-member-btn:hover,
.pi9q-member-btn:focus {
    background: var(--pi9q-primary);
    color: #fff !important;
    text-decoration: none;
}

/* ============================================================
   Front-end: Privacy Notice
   ============================================================ */
.pi9q-privacy-notice {
    font-size: 0.85rem;
    color: var(--pi9q-muted);
    margin-top: var(--pi9q-spacing);
    padding-top: var(--pi9q-spacing);
    border-top: 1px solid var(--pi9q-border);
}

/* ============================================================
   Front-end: Submit Button
   ============================================================ */
.pi9q-submit-wrap {
    margin-top: var(--pi9q-spacing);
}

.pi9q-submit-btn {
    display: inline-block;
    background: var(--pi9q-primary);
    color: #fff;
    border: none;
    border-radius: var(--pi9q-radius);
    padding: 0.65rem 1.75rem;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, box-shadow 0.15s ease;
    text-decoration: none;
}

.pi9q-submit-btn:hover,
.pi9q-submit-btn:focus {
    background: var(--pi9q-accent);
    box-shadow: 0 2px 8px rgba(242, 99, 58, 0.35);
    outline: none;
}

.pi9q-submit-btn:focus-visible {
    outline: 3px solid var(--pi9q-accent);
    outline-offset: 2px;
}

/* ============================================================
   Admin: Question Builder — Question Row Card
   ============================================================ */
.pi9q-question-row {
    background: #fff;
    border: 1px solid var(--pi9q-border, #d1d5db);
    border-radius: 6px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    transition: opacity 0.15s ease, border-color 0.15s ease;
    cursor: default;
}

.pi9q-question-row.is-dragging {
    opacity: 0.4;
}

.pi9q-question-row.drag-over {
    border-top: 3px solid #0073aa;
}

/* ============================================================
   Admin: Question Header
   ============================================================ */
.pi9q-question-header {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f6f7f7;
    border-bottom: 1px solid var(--pi9q-border, #d1d5db);
    padding: 8px 12px;
    border-radius: 6px 6px 0 0;
    user-select: none;
}

/* ============================================================
   Admin: Drag Handle
   ============================================================ */
.pi9q-drag-handle {
    cursor: grab;
    color: #999;
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
    padding: 2px 4px;
    border-radius: 3px;
    transition: color 0.1s ease, background 0.1s ease;
}

.pi9q-drag-handle:hover {
    color: #555;
    background: #e8e8e8;
}

.pi9q-drag-handle:active {
    cursor: grabbing;
}

/* ============================================================
   Admin: Question Body
   ============================================================ */
.pi9q-question-body {
    padding: 12px 16px;
}

.pi9q-question-body .form-table {
    margin: 0;
}

.pi9q-question-body .form-table th {
    width: 140px;
    padding: 8px 10px 8px 0;
    font-weight: 600;
    vertical-align: top;
}

.pi9q-question-body .form-table td {
    padding: 6px 0;
}

/* ============================================================
   Admin: Remove Button
   ============================================================ */
.pi9q-remove-question {
    font-size: 12px;
    color: #b32d2e;
    text-decoration: underline;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
}

.pi9q-remove-question:hover {
    color: #7c1f20;
}

/* ============================================================
   Admin: Responses Table — Responsive
   ============================================================ */
.pi9q-response-detail .widefat th,
.pi9q-response-detail .widefat td {
    vertical-align: top;
    padding: 10px 12px;
}

.pi9q-answers-table td:last-child {
    word-break: break-word;
}

.pi9q-delete-link {
    color: #b32d2e;
}

@media screen and (max-width: 782px) {
    .pi9q-question-body .form-table th {
        width: auto;
        display: block;
        padding-bottom: 2px;
    }

    .pi9q-question-body .form-table td {
        display: block;
        padding-top: 0;
    }

    .pi9q-answers-table {
        font-size: 13px;
    }

    .pi9q-answers-table th:nth-child(3),
    .pi9q-answers-table td:nth-child(3) {
        word-break: break-word;
        max-width: 200px;
    }

    /* Stack the details table on small screens */
    .pi9q-response-meta-table th,
    .pi9q-response-meta-table td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    .pi9q-response-meta-table th {
        border-bottom: none;
        padding-bottom: 0;
        font-weight: 700;
    }
}

@media screen and (max-width: 600px) {
    .pi9q-form-wrap {
        padding: 0 0.5rem;
    }

    .pi9q-question-block {
        padding: 0.85rem;
    }

    .pi9q-submit-btn {
        width: 100%;
        text-align: center;
    }
}
