/**
 * WP One Global Forms Styles (V82.4.9)
 * Features:
 * - Green Success Message (Alert Style)
 * - Non-shrinking Checkbox (RWD Fix)
 */

/* --- ZMIENNE --- */
.wpone-form-container {
    width: 100%;
    --wpone-brand: var(--wp--preset--color--primary, #1e1d3e);
    --wpone-action: var(--wp--preset--color--contrast, #ff2d48);
    --wpone-input-bg: var(--wp--preset--color--white, #ffffff);
    --wpone-text-passive: var(--wp--preset--color--secondary, #666666);

    /* Zmienne dla alertów */
    --wpone-success-bg: #d4edda;
    --wpone-success-text: #155724;
    --wpone-success-border: #c3e6cb;
}

.wpone-form {
    display: flex;
    flex-direction: column;
    gap: var(--wp--style--block-gap, 1.5rem);
}

/* --- Success / Error Messages --- */
/* Stylowanie komunikatów zwrotnych */
.wpone-form-message,
.wpone-message-success,
div.wpone-form-container > p:not([class]), /* Fallback dla prostych tekstów */
div.wpone-form-container > div:not([class^="wp-block"]) {
    padding: 15px 20px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 1rem;
    line-height: 1.5;
}

/* Stan Sukcesu (Zielony) */
/* Szukamy słów kluczowych lub klas dodawanych przez PHP */
.wpone-form-container:has(form) + div, /* Czasem plugin zamienia form na div */
.wpone-msg.success,
.wpone-form-message--success {
    color: var(--wpone-success-text);
    background-color: var(--wpone-success-bg);
    border-color: var(--wpone-success-border);
}

/* Stan Błędu (Czerwony - ogólny banner) */
.wpone-msg.error {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

/* --- Wrapper --- */
.wp-block-acf-form-field {
    position: relative;
    width: 100%;
    border: 1px solid var(--wp--preset--color--custom-light-grey, #ccc);
    border-radius: var(--wp--custom--border-radius, 4px);
    background-color: var(--wpone-input-bg);
    display: flex;
    flex-direction: column;
    overflow: visible !important;
    padding: 0 !important;
    transition: border-color 0.3s ease;
}
.wp-block-acf-form-field:focus-within {
    border-color: var(--wpone-brand);
    z-index: 1;
}

/* --- Inputy --- */
.wpone-field-wrapper {
    position: relative;
    width: 100%;
}

.wpone-field-wrapper input:not([type="checkbox"]):not([type="file"]),
.wpone-field-wrapper textarea,
.wpone-field-wrapper select {
    width: 100%;
    display: block;
    box-sizing: border-box;
    outline: none;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    border-radius: inherit;
    font-family: inherit;
    font-size: 1rem;
    color: var(--wpone-brand);
    padding: 16px 12px;
    margin: 0;
    line-height: 1.5;
    min-height: 56px;
}
.wpone-field-wrapper textarea {
    resize: vertical;
    min-height: 120px;
}

/* --- File Input --- */
.wpone-file-label {
    display: block;
    font-size: 0.9em;
    font-weight: inherit;
    padding: 1rem;
    color: var(--wpone-text-passive);
}
.wpone-input-file {
    width: 100%;
    display: block;
    padding: 1rem;
    font-size: 0.9em;
    border: none;
    background: transparent;
    color: var(--wpone-brand);
}

/* --- Floating Label --- */
.wpone-form-label {
    position: absolute;
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
    font-family: inherit;
    font-size: 1rem;
    color: var(--wpone-text-passive);
    opacity: 0.7;
    background-color: var(--wpone-input-bg);
    padding: 0 4px;
    pointer-events: none;
    transition: 0.2s ease all;
    line-height: 1;
    transform-origin: left center;
    border-radius: 2px;
}
.wpone-field-wrapper textarea + .wpone-form-label {
    top: 20px;
    transform: none;
}

.wpone-form-control:focus + .wpone-form-label,
.wpone-form-control:not(:placeholder-shown) + .wpone-form-label,
.wpone-field-wrapper select:valid + .wpone-form-label {
    top: -8px;
    left: 10px;
    transform: none;
    font-size: 0.8rem;
    font-weight: 500;
    opacity: 1;
    color: var(--wpone-brand);
    z-index: 2;
}

/* --- Checkbox --- */
.wp-block-acf-form-field:has(.wpone-check-group) {
    border: none !important;
    background: transparent !important;
}

.wpone-check-group {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 5px 0;
    font-size: 0.9em;
    line-height: 1.4;
    color: var(--wpone-text-passive);
}

.wpone-check-input {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    border: 1px solid #ccc !important;
    background: var(--wpone-input-bg) !important;
    border-radius: 4px !important;
    cursor: pointer;
    appearance: none;
    display: grid;
    place-content: center;

    /* FIX V82.4.9: RWD Checkbox Shrink Prevention */
    flex-shrink: 0;
    min-width: 20px; /* Zabezpieczenie */
}

.wpone-check-input::before {
    content: "";
    width: 10px;
    height: 10px;
    transform: scale(0);
    transition: 120ms transform ease-in-out;
    box-shadow: inset 1em 1em var(--wpone-brand);
    transform-origin: center;
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
.wpone-check-input:checked::before {
    transform: scale(1);
}
.wpone-check-input:checked {
    border-color: var(--wpone-brand) !important;
}

/* --- Walidacja (Touched) --- */
.wpone-form-control.wpone-touched:invalid {
    border-color: var(--wpone-action) !important;
    color: var(--wpone-action) !important;
}
.wpone-form-control.wpone-touched:invalid + .wpone-form-label {
    color: var(--wpone-action) !important;
}
.wpone-check-input.wpone-touched:invalid {
    border-color: var(--wpone-action) !important;
}

/* --- Button --- */
button.wpone-form-submit {
    cursor: pointer;
    width: auto;
}

.editor-styles-wrapper .wpone-form-control {
    pointer-events: none;
}

/* --- V82.7.0: Modern File Input Styling --- */

/* Reset i podstawowy wygląd przycisku wyboru pliku */
.wpone-input-file::file-selector-button,
.wpone-input-file::-webkit-file-upload-button {
    appearance: none;
    -webkit-appearance: none;
    background-color: #f6f7f7;
    border: 1px solid #dcdcde;
    color: var(--wpone-brand, #1e1d3e);
    padding: 8px 16px;
    margin-right: 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
    line-height: 1.2;
    vertical-align: middle;
}

/* Stan Hover */
.wpone-input-file::file-selector-button:hover,
.wpone-input-file::-webkit-file-upload-button:hover {
    background-color: #f0f0f1;
    border-color: #c3c4c7;
    color: #111;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* Stan Active/Focus (kliknięcie) */
.wpone-input-file::file-selector-button:active,
.wpone-input-file::-webkit-file-upload-button:active {
    background-color: #e6e7e8;
    transform: translateY(1px);
}

/* Dopasowanie tekstu "Nie wybrano pliku" */
.wpone-input-file {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    color: var(--wpone-text-passive);
    cursor: pointer; /* Kursor na całej strefie */
}

/* --- V82.7.0: Modern File Input Styling --- */

/* Reset i podstawowy wygląd przycisku wyboru pliku */
.wpone-input-file::file-selector-button,
.wpone-input-file::-webkit-file-upload-button {
    appearance: none;
    -webkit-appearance: none;
    background-color: #f6f7f7;
    border: 1px solid #dcdcde;
    color: var(--wpone-brand, #1e1d3e);
    padding: 8px 16px;
    margin-right: 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
    line-height: 1.2;
    vertical-align: middle;
}

/* Stan Hover */
.wpone-input-file::file-selector-button:hover,
.wpone-input-file::-webkit-file-upload-button:hover {
    background-color: #f0f0f1;
    border-color: #c3c4c7;
    color: #111;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* Stan Active/Focus (kliknięcie) */
.wpone-input-file::file-selector-button:active,
.wpone-input-file::-webkit-file-upload-button:active {
    background-color: #e6e7e8;
    transform: translateY(1px);
}

/* Dopasowanie tekstu "Nie wybrano pliku" */
.wpone-input-file {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    color: var(--wpone-text-passive);
    cursor: pointer; /* Kursor na całej strefie */
}
