/**
 * Vacatures - Frontend Forms Base Styles
 *
 * Styles for job submission and edit forms.
 * Originally from jobs-fields plugin.
 *
 * @package Vacatures
 * @since 1.0.0
 */

/* ==========================================================================
   Form Container
   ========================================================================== */

.jb-form-container {
    max-width: 100%;
    margin: 0;
    padding: 0;
}

.jb-form-container * {
    box-sizing: border-box;
}

/* ==========================================================================
   Form Errors
   ========================================================================== */

.jb-form-errors {
    background-color: #fef2f2;
    border: 1px solid #D4090C;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 24px;
}

.jb-form-errors ul {
    margin: 0;
    padding: 0 0 0 20px;
    list-style-type: disc;
}

.jb-form-errors li {
    color: #D4090C;
    font-size: 13px;
    margin-bottom: 4px;
    font-family: Poppins, sans-serif;
}

.jb-form-errors li:last-child {
    margin-bottom: 0;
}

.jb-form-error-container {
    padding: 20px;
}

.jb-form-error-message {
    color: #D4090C;
    font-size: 16px;
    text-align: center;
    padding: 40px 20px;
    background-color: #f1f1f1;
    border: 1px solid #D4090C;
    border-radius: 8px;
    font-family: Poppins, sans-serif;
}

/* ==========================================================================
   Form Fields Layout
   ========================================================================== */

.jb-form-fields {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.jb-form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Side by side field rows */
.jb-form-row {
    display: flex;
    flex-direction: row;
    gap: 32px;
}

.jb-form-row .jb-form-field {
    flex: 1;
    min-width: 0;
}

/* Last row (uren and date) should have 100px margin-bottom */
.jb-form-row:last-of-type {
    margin-bottom: 100px;
}

/* ==========================================================================
   Labels
   ========================================================================== */

.jb-form-label {
    font-size: 14px;
    font-weight: 500;
    color: #181818;
    font-family: Poppins, sans-serif;
    display: block;
    margin-bottom: 4px;
}

.jb-required {
    color: #D4090C;
    margin-left: 2px;
}

/* ==========================================================================
   Input Fields - Base Styles (Inactive Empty)
   ========================================================================== */

.jb-form-input,
.jb-form-textarea,
.jb-form-select {
    width: 100%;
    height: 60px !important;
    min-height: 60px !important;
    max-height: 60px !important;
    padding: 17px 18px !important;
    padding-top: 17px !important;
    padding-right: 18px !important;
    padding-bottom: 17px !important;
    padding-left: 18px !important;
    font-size: 16px;
    line-height: 163%;
    background-color: #F3F4F6 !important;
    border: 2px solid transparent !important;
    border-radius: 8px !important;
    box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25) inset !important;
    transition: border-color 0.15s ease-in-out;
    font-family: Poppins, sans-serif;
    color: #181818;
    box-sizing: border-box;
}

/* Placeholder styling */
.jb-form-input::placeholder,
.jb-form-textarea::placeholder {
    font-family: Poppins, sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 163%;
    color: rgba(24, 24, 24, 0.5);
}

/* Select placeholder styling - needs special handling */
.jb-form-select {
    color: #181818;
}

.jb-form-select option {
    color: #181818;
}

.jb-form-select option:disabled,
.jb-form-select option[value=""] {
    color: rgba(24, 24, 24, 0.5);
}

/* When select has empty value, show placeholder color */
.jb-form-select:invalid,
.jb-form-select[value=""] {
    color: rgba(24, 24, 24, 0.5);
}

/* ==========================================================================
   Field States
   ========================================================================== */

/* Active (Focus) - Black border */
.jb-form-input:focus,
.jb-form-textarea:focus,
.jb-form-select:focus {
    outline: none;
    border: 2px solid #181818 !important;
    box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25) inset !important;
}

/* Inactive Filled (Valid) - Green border - ONLY when has-value class is present */
.jb-form-input.has-value:not(:focus),
.jb-form-textarea.has-value:not(:focus),
.jb-form-select.has-value:not(:focus) {
    border: 2px solid #10B981 !important;
}

/* Error state - Red border */
.jb-form-field.has-error .jb-form-input,
.jb-form-field.has-error .jb-form-textarea,
.jb-form-field.has-error .jb-form-select {
    border: 2px solid #D4090C !important;
    background-color: #F3F4F6;
}

.jb-form-field.has-error .jb-form-input:focus,
.jb-form-field.has-error .jb-form-textarea:focus,
.jb-form-field.has-error .jb-form-select:focus {
    border: 2px solid #D4090C !important;
    box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25) inset !important;
}

/* ==========================================================================
   Textarea - Description Field (230px height)
   ========================================================================== */

.jb-form-textarea {
    height: 230px !important;
    min-height: 230px !important;
    max-height: none !important;
    resize: vertical;
    padding-top: 17px !important;
}

/* ==========================================================================
   Select Fields
   ========================================================================== */

.jb-form-select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: #F3F4F6 !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 18px center;
    background-repeat: no-repeat;
    background-size: 20px 20px;
    padding-right: 50px !important;
    padding-top: 17px !important;
    padding-bottom: 17px !important;
    padding-left: 18px !important;
    height: 60px !important;
    min-height: 60px !important;
    max-height: 60px !important;
    line-height: 163%;
}

/* Categories Multi-select (230px height, checkbox-style) */
.jb-form-select-multiple,
.jb-form-field-categories .jb-form-select {
    height: 230px;
    min-height: 230px;
    background-image: none;
    padding-right: 18px;
}

/* Category Checkboxes Container */
.jb-category-checkboxes {
    height: 230px;
    overflow-y: auto;
    background-color: #F3F4F6;
    border: 2px solid transparent !important;
    border-radius: 8px;
    box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25) inset !important;
    padding: 17px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.jb-category-checkboxes:focus-within {
    border: 2px solid #181818 !important;
}

.jb-category-checkboxes.has-value:not(:focus-within) {
    border: 2px solid #10B981 !important;
}

.jb-category-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-family: Poppins, sans-serif;
    font-size: 16px;
    color: #181818;
}

.jb-category-checkbox:hover {
    color: #181818;
}

.jb-category-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #10B981;
    border-radius: 4px;
}

.jb-category-checkbox input[type="checkbox"]:hover {
    accent-color: #169168;
}

.jb-category-checkbox input[type="checkbox"]:checked {
    accent-color: #10B981;
}

.jb-category-checkbox input[type="checkbox"]:checked:hover {
    accent-color: #169168;
}

/* ==========================================================================
   Input with Prefix (Currency)
   ========================================================================== */

.jb-input-with-prefix {
    position: relative;
    display: flex;
    align-items: center;
}

.jb-input-prefix {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: #181818;
    font-size: 16px;
    font-weight: 400;
    font-family: Poppins, sans-serif;
    pointer-events: none;
    z-index: 1;
    line-height: 1;
}

.jb-input-with-prefix .jb-form-input {
    padding-left: 40px !important;
}

/* Read-only fields */
.jb-form-input-readonly {
    background-color: #F3F4F6;
    color: rgba(24, 24, 24, 0.60);
    cursor: not-allowed;
}

/* ==========================================================================
   Field Error Messages
   ========================================================================== */

.jb-field-error {
    font-size: 13px;
    color: #D4090C;
    margin-top: 4px;
    font-family: Poppins, sans-serif;
}

/* ==========================================================================
   Field Help Text
   ========================================================================== */

.jb-field-help {
    font-size: 12px;
    color: #6b7280;
    margin: 4px 0 0 0;
    font-family: Poppins, sans-serif;
}

/* Hide Ctrl tip for categories */
.jb-field-help-categories {
    display: none;
}

/* ==========================================================================
   Form Actions (Buttons)
   ========================================================================== */

.jb-form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 0;
    padding-top: 32px;
    border-top: 2px solid rgba(24, 24, 24, 0.10);
}

/* Button group for draft and publish */
.jb-form-buttons-right {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
}

/* Base button styles */
.jb-form-button {
    padding: 12px 30px;
    font-family: Poppins, sans-serif;
    font-weight: 500;
    font-size: 20px;
    line-height: 100%;
    border-radius: 350px;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    border: 2px solid transparent;
    text-align: center;
    display: inline-block;
}

.jb-form-button:hover:not(.jb-form-button-cancel) {
    transform: translateY(-1px);
}

.jb-form-button:active:not(.jb-form-button-cancel) {
    transform: translateY(0);
}

.jb-form-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Cancel Button - Plain text link (left aligned) */
.jb-form-button-cancel {
    background: none !important;
    border: none !important;
    color: #181818 !important;
    padding: 0 !important;
    font-family: Poppins, sans-serif !important;
    font-weight: 400 !important;
    font-size: 16px !important;
    line-height: 163% !important;
    letter-spacing: 0 !important;
    text-decoration: underline !important;
    text-decoration-style: solid !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    cursor: pointer;
    margin-right: auto;
    min-width: auto !important;
    height: auto !important;
}

.jb-form-button-cancel:hover {
    background: none !important;
    border: none !important;
    text-decoration: none !important;
    transform: none !important;
    color: #181818 !important;
}

/* Draft Button - Secondary (white background with border) */
.jb-form-button-draft {
    background-color: #FFFFFF !important;
    color: #181818 !important;
    border: 2px solid rgba(24, 24, 24, 0.10) !important;
}

.jb-form-button-draft:hover {
    background-color: #F9FAFB !important;
    border-color: rgba(24, 24, 24, 0.20) !important;
}

/* Publish Button - Primary (green background) */
.jb-form-button-publish {
    background-color: #10B981 !important;
    color: #FFFFFF !important;
    border: 2px solid #10B981 !important;
}

.jb-form-button-publish:hover {
    background-color: #169168 !important;
    border-color: #169168 !important;
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.jb-form-container.is-loading {
    pointer-events: none;
    opacity: 0.7;
}

.jb-form-button.is-loading {
    position: relative;
    color: transparent !important;
}

.jb-form-button.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: jb-spin 0.6s linear infinite;
}

@keyframes jb-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   Responsive Styles - Mobile
   ========================================================================== */

@media (max-width: 640px) {
    .jb-form-container {
        padding: 0;
    }

    /* Stack side-by-side fields on mobile */
    .jb-form-row {
        flex-direction: column;
        gap: 20px;
    }

    .jb-form-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    .jb-form-buttons-right {
        flex-direction: column;
        width: 100%;
        gap: 6px;
    }

    .jb-form-button {
        width: 100%;
        text-align: center;
        height: 37px !important;
        min-height: 37px !important;
        padding: 8px 20px !important;
        padding-top: 8px !important;
        padding-right: 20px !important;
        padding-bottom: 8px !important;
        padding-left: 20px !important;
        font-size: 14px !important;
        font-weight: 500 !important;
        line-height: 100% !important;
        letter-spacing: 0 !important;
        border-radius: 350px !important;
    }

    .jb-form-button-cancel {
        text-align: center;
        margin-right: 0;
        order: 3; /* Move cancel to bottom on mobile */
        height: auto !important;
        min-height: auto !important;
        padding: 0 !important;
        font-size: 16px !important;
        line-height: 163% !important;
    }

    .jb-form-input,
    .jb-form-textarea,
    .jb-form-select {
        padding: 14px 16px;
        font-size: 16px; /* Prevent iOS zoom */
    }

    .jb-form-textarea,
    .jb-category-checkboxes {
        height: 200px;
        min-height: 200px;
    }
}

/* ==========================================================================
   Elementor Popup Compatibility
   ========================================================================== */

.elementor-popup-modal .jb-form-container {
    max-width: 100%;
}

.elementor-popup-modal .jb-form-actions {
    justify-content: space-between;
}

/* ==========================================================================
   Form Loading Spinner
   ========================================================================== */

.jb-form-container-wrapper {
    position: relative;
    min-height: 300px;
}

.jb-form-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    padding: 40px 20px;
}

.jb-form-loader-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #F3F4F6;
    border-top-color: #10B981;
    border-radius: 50%;
    animation: jb-form-loader-spin 0.8s linear infinite;
}

@keyframes jb-form-loader-spin {
    to {
        transform: rotate(360deg);
    }
}

.jb-form-loader-text {
    margin-top: 16px;
    font-family: Poppins, sans-serif;
    font-size: 16px;
    color: #181818;
    opacity: 0.7;
}

.jb-form-content {
    /* Form content container - initially hidden via inline style */
}

