/* Pay4All WIN - frontend styles.
 * Scoped under .pay4all-win-* / .pay4all-win-form-wrap to avoid leaking
 * into merchant themes. All colours are neutral by default ; the submit
 * button colour is set inline from the contest style meta.
 */

/* ---- Standalone entry page (?p4all_win=...) --------------------------
 * Rendered by Endpoint::render_page() outside the theme. Background /
 * text colour are attached at runtime via wp_add_inline_style() from
 * the merchant's Settings, so no inline <style> block is emitted.
 */
body.pay4all-win-endpoint {
    margin: 0;
    padding: 24px 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body.pay4all-win-endpoint .pay4all-win-endpoint-wrap {
    max-width: 640px;
    margin: 0 auto;
}

.pay4all-win-form-wrap {
    max-width: 640px;
    margin: 24px 0;
    font-family: inherit;
    line-height: 1.5;
    /* --pay4all-win-text is injected inline from Settings > General
       (see Frontend\Assets::enqueue). Falls back to inherit so the
       host theme colour still applies when the setting is missing. */
    color: var(--pay4all-win-text, inherit);
}

.pay4all-win-form-title {
    font-size: 1.6em;
    margin: 0 0 8px;
    color: var(--pay4all-win-text, inherit);
}

.pay4all-win-desc {
    margin-bottom: 18px;
    color: var(--pay4all-win-text, inherit);
}

.pay4all-win-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: transparent;
    border: none;
    padding: 0;
}

.pay4all-win-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: var(--pay4all-win-text, inherit);
}

.pay4all-win-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--pay4all-win-text, inherit);
}

.pay4all-win-form input[type="text"],
.pay4all-win-form input[type="email"],
.pay4all-win-form input[type="tel"],
.pay4all-win-form input[type="number"],
.pay4all-win-form input[type="date"],
.pay4all-win-form select,
.pay4all-win-form textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #c9ccd1;
    border-radius: 5px;
    font-size: 15px;
    font-family: inherit;
    background: #fff;
    color: #222;
    box-sizing: border-box;
    transition: border-color .15s;
}

.pay4all-win-form input:focus,
.pay4all-win-form select:focus,
.pay4all-win-form textarea:focus {
    border-color: #2271b1;
    outline: none;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, .15);
}

.pay4all-win-form .is-invalid {
    border-color: #d63638;
    background: #fdf3f3;
}

/* Highlight the whole field wrapper (label + input) when a required
   field fails validation on submit, so the visitor sees which row to
   fix even for tiny controls like a checkbox / radio where the input's
   own red border would be barely visible. Left border + soft red tint
   + red label text - readable on both dark and light themes. */
.pay4all-win-form .pay4all-win-field.is-invalid,
.pay4all-win-form .pay4all-win-checkbox.is-invalid {
    border-left: 3px solid #d63638;
    background: rgba(214, 54, 56, 0.06);
    padding-left: 10px;
    border-radius: 4px;
}
.pay4all-win-form .pay4all-win-field.is-invalid .pay4all-win-label,
.pay4all-win-form .pay4all-win-checkbox.is-invalid > span {
    color: #d63638;
}
/* The inner control's own red border is redundant once the whole
   wrapper is tinted - drop the double frame for a calmer look. */
.pay4all-win-form .pay4all-win-field.is-invalid .is-invalid,
.pay4all-win-form .pay4all-win-checkbox.is-invalid .is-invalid {
    background: transparent;
}

.pay4all-win-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.pay4all-win-grid--npa {
    grid-template-columns: 130px 1fr;
}

@media (max-width: 480px) {
    .pay4all-win-grid,
    .pay4all-win-grid--npa {
        grid-template-columns: 1fr;
    }
}

/* ---- Column widths (merchant-controlled per field: 25 / 50 / 75 / 100 %) ---
 * Uses a 4-column grid so widths align cleanly on tablet+. Each field row
 * spans a slice of that grid ; on mobile every field falls back to full
 * width for legibility.
 */
.pay4all-win-form__grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.pay4all-win-form__grid > .pay4all-win-field { grid-column: span 4; }

.pay4all-win-form__grid > .pay4all-win-w25   { grid-column: span 1; }
.pay4all-win-form__grid > .pay4all-win-w50   { grid-column: span 2; }
.pay4all-win-form__grid > .pay4all-win-w75   { grid-column: span 3; }
.pay4all-win-form__grid > .pay4all-win-w100  { grid-column: span 4; }

/* Terms + marketing checkbox always take the full row. */
.pay4all-win-form__grid > .pay4all-win-checkbox { grid-column: span 4; }

@media (max-width: 600px) {
    .pay4all-win-form__grid {
        grid-template-columns: 1fr;
    }
    .pay4all-win-form__grid > .pay4all-win-w25,
    .pay4all-win-form__grid > .pay4all-win-w50,
    .pay4all-win-form__grid > .pay4all-win-w75,
    .pay4all-win-form__grid > .pay4all-win-w100 {
        grid-column: 1;
    }
}

.pay4all-win-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    color: var(--pay4all-win-text, inherit);
    line-height: 1.4;
}

.pay4all-win-checkbox input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
}

.pay4all-win-radios {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    padding-top: 4px;
}

.pay4all-win-radio {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: normal;
}

/* Multi-choice checkbox group : one option per row, stacked vertically.
   Each label uses the shared `.pay4all-win-checkbox` class but we
   override the flex-start alignment (meant for the terms paragraph)
   since these are short one-line labels. */
.pay4all-win-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 4px;
}
.pay4all-win-checkboxes .pay4all-win-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: normal;
}
.pay4all-win-checkboxes .pay4all-win-checkbox input[type="checkbox"] {
    margin-top: 0;
}

.pay4all-win-submit {
    padding: 12px 22px;
    border: none;
    border-radius: 5px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: filter .15s, transform .05s;
}

.pay4all-win-submit:hover:not([disabled]) {
    filter: brightness(1.1);
}

.pay4all-win-submit:active:not([disabled]) {
    transform: translateY(1px);
}

.pay4all-win-submit[disabled] {
    opacity: .6;
    cursor: not-allowed;
}

.pay4all-win-status {
    min-height: 1.4em;
    margin: 6px 0 0;
    font-size: 14px;
}

.pay4all-win-status.is-success { color: #007a2f; }
.pay4all-win-status.is-error   { color: #b32d2e; }

.pay4all-win-notice {
    padding: 14px 16px;
    background: #f6f7f7;
    border-left: 4px solid #2271b1;
    color: #333;
    border-radius: 3px;
}

/* ---- Ended / Scheduled panels ---- */

.pay4all-win-panel {
    max-width: 640px;
    margin: 24px 0;
    padding: 20px;
    background: #fff;
    border: 1px solid #e0e2e6;
    border-radius: 8px;
}

.pay4all-win-panel--ended {
    border-left: 4px solid #d63638;
}

.pay4all-win-panel--scheduled {
    border-left: 4px solid #2271b1;
}

/* Shown after the AJAX submission succeeds, in place of the whole form. */
.pay4all-win-panel--done {
    border-left: 4px solid #007a2f;
    color: #007a2f;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
}

.pay4all-win-status-line {
    margin: 12px 0;
    font-weight: 600;
}

.pay4all-win-winners {
    list-style: none;
    padding: 0;
    margin: 8px 0 0;
}

.pay4all-win-winners li {
    padding: 6px 0;
    border-bottom: 1px dashed #e0e2e6;
}

/* ---- QR shortcode ---- */

.pay4all-win-qr {
    display: inline-block;
    text-align: center;
    margin: 12px 0;
}

.pay4all-win-qr__title {
    font-size: 1.1em;
    margin: 0 0 8px;
}

.pay4all-win-qr__img {
    display: block;
    max-width: 100%;
    height: auto;
    border: 1px solid #eee;
    background: #fff;
}
