/**
 * Consent UI Styles
 *
 * File: wp-content/plugins/rca-api/assets/css/consent-ui.css
 * What: Styling for consent status banners and action buttons
 * Why: V1.5.9 UX enhancement - professional consent status display
 * Related: step-3-completion.php, results-page-template.php, consent-actions.js
 *
 * @package RCA_API
 * @since 1.5.9
 * @version 1.0.0
 */

/* ==================================================
   Consent Status Confirmed (Step 3)
   ================================================== */

.consent-status-confirmed {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border: 2px solid #4caf50;
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.15);
    animation: slideIn 0.4s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.consent-status-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(76, 175, 80, 0.2);
}

.consent-status-icon {
    font-size: 36px;
    line-height: 1;
}

.consent-status-header h3 {
    margin: 0 !important;
    color: #fff !important;
    font-size: 22px !important;
    font-weight: 600;
}

.consent-status-body {
    color: #1b5e20;
}

.consent-status-body > p {
    margin: 0;
    padding-top: 0;
    font-size: 15px;
    line-height: 1.6;
}

.consent-status-body strong {
    font-weight: 600;
}

#consent-time-remaining {
    color: #2e7d32;
    font-weight: 700;
}

.consent-status-details {
    background: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
}

.consent-status-details p {
    margin: 8px 0;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.consent-status-details strong {
    color: #2e7d32;
    min-width: 120px;
}

.consent-status-actions {
    display: flex;
    gap: 12px;
    margin: 20px 0 12px 0;
    flex-wrap: wrap;
}

.btn-consent-action {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-view-consent {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
}

.btn-view-consent:hover {
    background: linear-gradient(135deg, #45a049 0%, #3d8b40 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.3);
}

.btn-reset-consent {
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
    color: white;
}

.btn-reset-consent:hover {
    background: linear-gradient(135deg, #f57c00 0%, #ef6c00 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(255, 152, 0, 0.3);
}

.btn-consent-action:active {
    transform: translateY(0);
}

.btn-consent-action:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.consent-status-note {
    margin: 12px 0 0 0;
    padding-top: 12px;
    border-top: 1px solid rgba(76, 175, 80, 0.2);
}

.consent-status-note small {
    color: #558b2f;
    font-size: 13px;
    font-style: italic;
}

/* ==================================================
   Auto-filled Answers (pre-populated from Step 1/2)
   ================================================== */

/*
 * Questions whose answers were pre-populated from Step 1/2 form values are hidden
 * entirely so the user is not shown or asked to confirm them. The radio inputs
 * remain in the DOM (display:none does NOT prevent serialisation) so their values
 * are still included in the consent submission request.
 */
.consent-question.consent-question-autofilled {
    display: none !important;
}

/**
 * Hide question groups that have no visible questions.
 * Applied by ConsentHandler._hideEmptyGroups() when a group has either
 * zero questions or all questions are auto-filled (hidden).
 * The group and its children remain in the DOM for form submission.
 * @since 1.5.9
 */
.consent-question-group.consent-group-empty {
    display: none !important;
}

/*
 * Transition lives on the base rule so it fires in BOTH directions:
 * - class added   → label animates TO blue italic
 * - class removed → label animates BACK to normal (JS strips .consent-auto-filled on user change)
 * Target only the direct answer label, NOT the extra field's descriptive label.
 */
.consent-answer > label {
    transition: color 0.25s ease, font-style 0.25s ease;
}

.consent-auto-filled > label {
    color: #1565c0;
    font-style: italic;
}

.consent-auto-filled > label::after {
    content: ' (auto-completat)';
    font-size: 0.8em;
    opacity: 0.7;
    font-weight: 400;
}

/* ==================================================
   Answer Row — layout only
   ================================================== */

/*
 * flex-wrap: wrap is required so .consent-extra-field (width:100%)
 * breaks onto its own line below the radio + label pair.
 */
.consent-answer {
    flex-wrap: wrap;
}

/*
 * Extra field container — rendered inline with the answer, sits below
 * the radio + label row once JS sets display: block.
 */
.consent-extra-field {
    display: none; /* default hidden; toggled by toggleExtraFields() */
    width: 100%;
    margin-top: 10px;
    padding: 12px 14px 14px;
    background: #f0f4ff;
    border: 1px solid #c5cae9;
    border-left: 3px solid #3f51b5;
    border-radius: 0 6px 6px 0;
    animation: extraFieldSlideIn 0.22s ease-out;
    box-sizing: border-box;
}

@keyframes extraFieldSlideIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Descriptive label inside the extra field */
.consent-extra-field > label {
    display: block;
    margin: 0 0 8px 0;
    font-size: 0.82em;
    color: #3949ab;
    font-weight: 500;
    font-style: normal;
    letter-spacing: 0.01em;
}

/* Reset the auto-filled badge/style for the extra field's own label */
.consent-auto-filled .consent-extra-field > label {
    color: #3949ab;
    font-style: normal;
}

.consent-auto-filled .consent-extra-field > label::after {
    content: none;
}

/* Text input inside the extra field */
.consent-extra-input {
    display: block;
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #9fa8da;
    border-radius: 5px;
    font-size: 0.95em;
    color: #1a237e;
    background: #ffffff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
    line-height: 1.5;
}

.consent-extra-input:focus {
    outline: none;
    border-color: #3f51b5;
    box-shadow: 0 0 0 3px rgba(63, 81, 181, 0.12);
}

.consent-extra-input::placeholder {
    color: #9fa8da;
    font-style: italic;
}

/* ==================================================
   Validation Error State
   ================================================== */

/*
 * Applied by ConsentHandler.validateAnswers() to every visible question that
 * has no answer selected. Provides a clear red visual indicator without
 * removing the question from the DOM (so re-validation works correctly).
 */
.consent-question.consent-error {
    border: 1px solid #e53935;
    border-radius: 8px;
    padding: 12px 14px;
    background-color: rgba(229, 57, 53, 0.04);
    animation: shakeError 0.35s ease-in-out;
}

.consent-question.consent-error .consent-question-text {
    color: #b71c1c;
}

@keyframes shakeError {
    0%   { transform: translateX(0); }
    20%  { transform: translateX(-5px); }
    40%  { transform: translateX(5px); }
    60%  { transform: translateX(-4px); }
    80%  { transform: translateX(4px); }
    100% { transform: translateX(0); }
}

/* ==================================================
   Mandatory Question Indicator
   ================================================== */

.consent-required {
    color: #c62828;
    font-weight: 700;
    margin-left: 3px;
    font-size: 1.1em;
    line-height: 1;
    vertical-align: middle;
    cursor: help;
}

.consent-question[data-mandatory="true"] .consent-question-text {
    font-weight: 600;
}

/* ==================================================
   Consent Messages (Error/Success)
   ================================================== */

#consent-messages {
    margin: 16px 0;
    padding: 12px 16px;
    border-radius: 6px;
    display: none;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

#consent-messages.success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

#consent-messages.error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

#consent-messages.info {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

#consent-messages p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

/* ==================================================
   Responsive Design
   ================================================== */

@media (max-width: 768px) {
    .consent-status-confirmed {
        padding: 16px;
        margin: 16px 0;
    }

    .consent-status-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .consent-status-header h3 {
        font-size: 20px;
    }

    .consent-status-icon {
        font-size: 28px;
    }

    .consent-status-details {
        padding: 12px;
    }

    .consent-status-details p {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .consent-status-details strong {
        min-width: auto;
    }

    .consent-status-actions {
        flex-direction: column;
        width: 100%;
    }

    .btn-consent-action {
        width: 100%;
        justify-content: center;
        padding: 14px 20px;
    }
}

@media (max-width: 480px) {
    .consent-status-confirmed {
        padding: 12px;
        border-radius: 8px;
    }

    .consent-status-header h3 {
        font-size: 18px;
    }

    .btn-consent-action {
        font-size: 14px;
        padding: 12px 16px;
    }
}

/* ==================================================
   Dark Mode Support (Optional)
   ================================================== */

@media (prefers-color-scheme: dark) {
    .consent-status-confirmed {
        background: linear-gradient(135deg, #49b150 0%, #4f8b51 100%);
        border: none;
    }

    .consent-status-header h3 {
        color: #c8e6c9;
    }

    .consent-status-body {
        color: #e8f5e9;
    }

    #consent-time-remaining {
        color: #a5d6a7;
    }

    .consent-status-details {
        background: rgba(0, 0, 0, 0.2);
    }

    .consent-status-details strong {
        color: #c8e6c9;
    }

    .consent-status-note small {
        color: #fff;
    }
}

/* ==================================================
   Print Styles
   ================================================== */

@media print {
    .consent-status-actions {
        display: none;
    }

    .consent-status-confirmed {
        background: white;
        border: 2px solid #000;
        page-break-inside: avoid;
    }
}
