/*
 * Modern form styling.
 * Enabled per organization in system settings (modern_form_style) or per page with ?style=modern.
 * The frontend layout (application/master/frontend/header.blade.php) puts .style-modern on <body>,
 * the form builder (application/builder/form_template_editable.blade.php) puts it on #form_background.
 * Only styling is changed, never the markup. --yc-accent is set from the form's submit color.
 * Rules scoped to body.style-modern are frontend page layout only and must not reach the builder.
 */

.style-modern {
    --yc-accent: #2563eb;
    --yc-accent-soft: color-mix(in srgb, var(--yc-accent) 10%, #ffffff);
    --yc-accent-ring: color-mix(in srgb, var(--yc-accent) 22%, transparent);
    --yc-text: #111827;
    --yc-text-muted: #6b7280;
    --yc-border: #d1d5db;
    --yc-border-hover: #9ca3af;
    --yc-surface: #ffffff;
    --yc-surface-muted: #f9fafb;
    --yc-danger: #dc2626;
    --yc-radius: 10px;
    --yc-radius-lg: 18px;
    --yc-font: "Inter", "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    font-family: var(--yc-font);
    color: var(--yc-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.style-modern #formular,
.style-modern #formular input,
.style-modern #formular textarea,
.style-modern #formular button,
.style-modern #formular select,
.style-modern .dropdown-menu {
    font-family: var(--yc-font);
}

/* ---------- Card layout ---------- */

body.style-modern:not(.embeded) #form_background {
    padding: 48px 16px;
}

body.style-modern:not(.embeded) #formular {
    max-width: 840px;
    min-height: 0;
    border-radius: var(--yc-radius-lg);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 12px 40px -8px rgba(16, 24, 40, .14);
}

.style-modern #cover {
    border-radius: var(--yc-radius-lg) var(--yc-radius-lg) 0 0;
    box-shadow: none;
}

.style-modern #cover #logo {
    border: none;
    border-radius: 14px;
    padding: 6px;
    box-shadow: 0 4px 16px rgba(16, 24, 40, .14);
}

.style-modern #cover #logo img {
    border-radius: 10px;
}

body.style-modern:not(.embeded) #fields {
    padding-top: 16px;
}

body.style-modern:not(.embeded) #fields .field_item {
    padding: 0 48px;
}

.style-modern #form {
    padding-bottom: 48px;
}

.style-modern #cookie_privacy_btn a {
    color: var(--yc-text-muted);
}

@media only screen and (max-width: 640px) {
    body.style-modern:not(.embeded) #form_background {
        padding: 0;
    }

    body.style-modern:not(.embeded) #formular {
        border-radius: 0;
        box-shadow: none;
    }

    .style-modern #cover {
        border-radius: 0;
    }

    body.style-modern:not(.embeded) #fields .field_item {
        padding: 0 20px;
    }
}

/* ---------- Typography ---------- */

.style-modern .text {
    color: var(--yc-text);
}

.style-modern .text h1,
.style-modern .text h2,
.style-modern .text h3 {
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.style-modern .text h4,
.style-modern .text h5 {
    font-weight: 600;
}

.style-modern .text h1 {
    font-size: 32px;
}

.style-modern .text p {
    color: #374151;
}

.style-modern .text a {
    color: var(--yc-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ---------- Fields ---------- */

.style-modern .form_field {
    padding-top: 20px;
}

.style-modern .form_field .title {
    font-size: 14px;
    font-weight: 600;
    line-height: 20px;
    color: var(--yc-text);
    padding-bottom: 8px;
}

.style-modern .form_field.radiobutton .title,
.style-modern .form_field.checkbox .title {
    padding-bottom: 10px;
}

.style-modern .form_field .title span {
    color: var(--yc-text-muted);
    font-weight: 400;
}

.style-modern .form_field .title .optional {
    opacity: 1;
    font-style: normal;
    font-size: 12px;
    font-weight: 500;
    margin-left: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    background-color: #f3f4f6;
    color: var(--yc-text-muted);
    vertical-align: 1px;
}

.style-modern .form_field[data-required='1'] .validation {
    color: var(--yc-danger);
}

/* Text inputs, textareas */

.style-modern #formular input[type=text],
.style-modern #formular input[type=url],
.style-modern #formular input[type=number],
.style-modern #formular input[type=date],
.style-modern #formular input[type=time],
.style-modern #formular input[type=password],
.style-modern #formular input[type=email],
.style-modern #formular input[type=tel],
.style-modern #formular textarea {
    min-height: 48px;
    padding: 12px 14px;
    font-size: 15px;
    line-height: 22px;
    color: var(--yc-text);
    background-color: var(--yc-surface);
    border: 1px solid var(--yc-border);
    border-radius: var(--yc-radius);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
    transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

.style-modern #formular textarea {
    min-height: 120px !important;
    resize: vertical;
}

.style-modern #formular input[type=text]:hover,
.style-modern #formular input[type=url]:hover,
.style-modern #formular input[type=number]:hover,
.style-modern #formular input[type=date]:hover,
.style-modern #formular input[type=time]:hover,
.style-modern #formular input[type=password]:hover,
.style-modern #formular input[type=email]:hover,
.style-modern #formular input[type=tel]:hover,
.style-modern #formular textarea:hover {
    border-color: var(--yc-border-hover);
}

.style-modern #formular input[type=text]:focus,
.style-modern #formular input[type=url]:focus,
.style-modern #formular input[type=number]:focus,
.style-modern #formular input[type=date]:focus,
.style-modern #formular input[type=time]:focus,
.style-modern #formular input[type=password]:focus,
.style-modern #formular input[type=email]:focus,
.style-modern #formular input[type=tel]:focus,
.style-modern #formular textarea:focus {
    border-color: var(--yc-accent);
    box-shadow: 0 0 0 4px var(--yc-accent-ring);
}

.style-modern #formular input[readonly],
.style-modern #formular input:disabled {
    background-color: #f3f4f6 !important;
    color: var(--yc-text-muted) !important;
    box-shadow: none;
}

.style-modern #formular ::placeholder {
    color: #9ca3af;
}

.style-modern .digits,
.style-modern .textarea_remaining {
    color: #9ca3af;
    font-size: 12px;
}

/* Prefix addon inputs (e.g. url fields) */

.style-modern .input-group-addon {
    border-color: var(--yc-border);
    background-color: #f3f4f6;
    color: var(--yc-text-muted);
    border-radius: var(--yc-radius) 0 0 var(--yc-radius);
}

/* Selects (bootstrap-select) */

.style-modern .bootstrap-select button,
.style-modern .bootstrap-select button.dropdown-toggle {
    min-height: 48px;
    padding: 12px 40px 12px 14px;
    font-size: 15px;
    line-height: 22px;
    color: var(--yc-text);
    background-color: var(--yc-surface);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none' stroke='%236b7280' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M5 7.5l5 5 5-5'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
    border: 1px solid var(--yc-border);
    border-radius: var(--yc-radius);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.style-modern .bootstrap-select button:after {
    display: none;
}

.style-modern .bootstrap-select button:hover {
    border-color: var(--yc-border-hover);
}

.style-modern .bootstrap-select.open button,
.style-modern .bootstrap-select button:focus {
    border-color: var(--yc-accent);
    box-shadow: 0 0 0 4px var(--yc-accent-ring);
}

.style-modern .bootstrap-select .filter-option {
    color: inherit;
}

.style-modern .dropdown-menu {
    top: 54px;
    padding: 6px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 12px 32px -6px rgba(16, 24, 40, .18);
    color: var(--yc-text);
}

.style-modern .dropdown-menu.inner {
    top: 0;
    padding: 0;
    border: none;
    box-shadow: none;
}

.style-modern .dropdown-menu.inner li a {
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--yc-text);
}

.style-modern .dropdown-menu > li > a:hover,
.style-modern .dropdown-menu > li > a:focus {
    background-color: #f3f4f6;
    color: var(--yc-text);
}

.style-modern .dropdown-menu.inner li.selected a {
    background-color: var(--yc-accent-soft);
    color: var(--yc-text);
    font-weight: 500;
}

.style-modern .dropdown-menu .bs-searchbox {
    padding: 6px 6px 8px;
}

.style-modern .dropdown-menu .bs-searchbox input {
    border-radius: 8px;
    border-color: var(--yc-border);
}

.style-modern .date-dropdowns .bootstrap-select {
    margin-right: 10px;
}

/* Checkboxes and radio buttons: shown as selectable option rows */

.style-modern .mdl-checkbox.is-upgraded,
.style-modern .mdl-radio.is-upgraded {
    padding-left: 30px;
}

.style-modern .mdl_list .mdl-checkbox,
.style-modern .mdl_list .mdl-radio,
.style-modern .mdl_list .disabled-label {
    display: flex;
    align-items: center;
    height: auto;
    min-height: 48px;
    margin: 0 0 8px;
    padding: 12px 14px 12px 46px;
    box-sizing: border-box;
    background-color: var(--yc-surface);
    border: 1px solid var(--yc-border);
    border-radius: var(--yc-radius);
    transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
}

.style-modern .mdl_list .disabled-label {
    padding-left: 14px;
    background-color: var(--yc-surface-muted);
    border-style: dashed;
    color: #9ca3af;
}

.style-modern .mdl_list .mdl-checkbox:hover,
.style-modern .mdl_list .mdl-radio:hover {
    border-color: var(--yc-border-hover);
    background-color: var(--yc-surface-muted);
}

.style-modern .mdl_list .mdl-checkbox.is-checked,
.style-modern .mdl_list .mdl-radio.is-checked {
    border-color: var(--yc-accent);
    background-color: var(--yc-accent-soft);
    box-shadow: 0 0 0 1px var(--yc-accent);
}

.style-modern .mdl_list .mdl-checkbox.is-focused,
.style-modern .mdl_list .mdl-radio.is-focused {
    box-shadow: 0 0 0 4px var(--yc-accent-ring);
}

.style-modern .mdl_list .mdl-checkbox.is-checked.is-focused,
.style-modern .mdl_list .mdl-radio.is-checked.is-focused {
    box-shadow: 0 0 0 1px var(--yc-accent), 0 0 0 5px var(--yc-accent-ring);
}

.style-modern .mdl_list .mdl-checkbox__label,
.style-modern .mdl_list .mdl-radio__label {
    font-size: 15px;
    line-height: 22px;
    color: var(--yc-text);
}

.style-modern .mdl-checkbox__box-outline,
.style-modern .mdl-checkbox__focus-helper,
.style-modern .mdl-radio__outer-circle {
    width: 20px;
    height: 20px;
    top: 2px;
    border: 1.5px solid var(--yc-border-hover);
    background-color: var(--yc-surface);
}

.style-modern .mdl-checkbox__box-outline {
    border-radius: 6px;
}

.style-modern .mdl_list .mdl-checkbox__box-outline,
.style-modern .mdl_list .mdl-checkbox__focus-helper,
.style-modern .mdl_list .mdl-radio__outer-circle {
    top: 50%;
    left: 14px;
    margin-top: -10px;
}

.style-modern .mdl-checkbox__focus-helper,
.style-modern .mdl-checkbox.is-focused .mdl-checkbox__focus-helper,
.style-modern .mdl-checkbox.is-focused.is-checked .mdl-checkbox__focus-helper {
    border: none;
    background: transparent;
    box-shadow: none;
}

.style-modern .mdl-checkbox.is-checked .mdl-checkbox__box-outline {
    background-color: var(--yc-accent);
    border-color: var(--yc-accent);
}

.style-modern .mdl-checkbox__tick-outline {
    background-size: 14px 14px !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
}

.style-modern .mdl-radio.is-checked .mdl-radio__outer-circle {
    border: 6px solid var(--yc-accent);
}

.style-modern .mdl-radio__inner-circle {
    display: none;
}

.style-modern .mdl-checkbox__ripple-container,
.style-modern .mdl-radio__ripple-container {
    display: none;
}

@media (min-width: 800px) {
    .style-modern .mdl_list.mdl_flex {
        gap: 0 8px;
    }

    .style-modern .mdl_list.mdl_flex label,
    .style-modern .mdl_list.mdl_flex .disabled-label {
        flex: 1 1 calc(50% - 8px);
        padding-right: 14px;
        height: auto;
    }
}

/* Sub fields */

.style-modern .form_field.sub_field,
.style-modern .design_field.sub_field {
    padding-left: 16px;
}

.style-modern .form_field.sub_field:after,
.style-modern .design_field.sub_field:after {
    border-left: 2px solid var(--yc-accent-ring);
    border-radius: 2px;
}

/* File upload */

.style-modern .file_uploader.upload-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 64px;
    max-width: none;
    padding: 16px;
    background-color: var(--yc-surface-muted);
    border: 1.5px dashed var(--yc-border) !important;
    border-radius: 12px;
    color: var(--yc-text-muted);
    font-size: 15px;
    font-weight: 500;
    transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease;
}

.style-modern .file_uploader.upload-icon::before {
    position: static;
    width: 20px;
    height: 20px;
    margin: 0 10px 0 0;
    padding: 0;
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M12 16V4M7 9l5-5 5 5M4 20h16'/></svg>") no-repeat center / 20px;
    flex-shrink: 0;
}

.style-modern .file_uploader.upload-icon div:first-child {
    padding-right: 0;
}

.style-modern .file_uploader.upload-icon input[type=file] {
    height: 100%;
}

.style-modern .file_uploader.upload-icon:hover {
    border-color: var(--yc-accent) !important;
    background-color: var(--yc-accent-soft);
    color: var(--yc-text);
}

.style-modern .upload.form_field .selected_files .upload_file_list {
    max-width: none;
    padding: 10px 14px;
    margin-bottom: 6px;
    border: 1px solid #e5e7eb;
    border-radius: var(--yc-radius);
    background-color: var(--yc-surface-muted);
}

.style-modern .form_field .file_uploader_btn,
.style-modern .form_field .button {
    border-radius: var(--yc-radius);
    box-shadow: none;
}

.style-modern .level-wrap {
    border-color: var(--yc-border);
    border-radius: var(--yc-radius);
    overflow: hidden;
}

/* ---------- Submit ---------- */

.style-modern .submit_button {
    padding-top: 12px;
}

body.style-modern:not(.embeded) .submit_button {
    padding-left: 48px;
    padding-right: 48px;
    max-width: 896px;
    box-sizing: border-box;
}

.style-modern .submit_button button[type=submit] {
    min-height: 50px;
    padding: 14px 32px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: .01em;
    line-height: 22px;
    border: none;
    border-radius: var(--yc-radius);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .08), 0 6px 16px -6px color-mix(in srgb, var(--yc-accent) 60%, transparent);
    transition: transform 150ms ease, box-shadow 150ms ease, filter 150ms ease;
}

.style-modern .submit_button button[type=submit]:hover {
    filter: brightness(1.06);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(16, 24, 40, .08), 0 10px 22px -8px color-mix(in srgb, var(--yc-accent) 70%, transparent);
}

.style-modern .submit_button button[type=submit]:active {
    transform: translateY(0);
    filter: brightness(.97);
}

.style-modern .submit_button button[type=submit]:focus-visible {
    box-shadow: 0 0 0 4px var(--yc-accent-ring);
}

.style-modern .submit_button button[type=submit]:disabled {
    transform: none;
    box-shadow: none;
    filter: none;
}

@media only screen and (max-width: 640px) {
    body.style-modern:not(.embeded) .submit_button {
        padding-left: 20px;
        padding-right: 20px;
    }

    .style-modern .submit_button button[type=submit] {
        width: 100%;
    }
}

/* ---------- Disclaimer ---------- */

.style-modern .disclaimer {
    color: var(--yc-text-muted);
    line-height: 20px;
}

.style-modern .disclaimer a {
    color: var(--yc-accent);
}

/* ---------- Validation ---------- */

.style-modern #fields .error,
.style-modern #fields .error:hover,
.style-modern #fields .error:focus {
    border-color: var(--yc-danger) !important;
}

.style-modern #fields .error:focus {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--yc-danger) 18%, transparent) !important;
}

.style-modern #fields .error_text,
.style-modern .form_error .error_text {
    color: var(--yc-danger);
    font-size: 13px;
    line-height: 18px;
    padding-top: 6px;
}

.style-modern .errors {
    border: 1px solid color-mix(in srgb, var(--yc-danger) 25%, transparent);
    border-radius: 12px;
    background-color: #fef2f2;
    color: #991b1b;
}

/* ---------- Status pages (success, closed, deadline) ---------- */

.style-modern #formular h1 {
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.style-modern #formular .max_width_600 p {
    color: #374151;
    line-height: 1.6;
}

/* ---------- Form builder ---------- */

#form_background.style-modern #formular {
    border-radius: var(--yc-radius-lg);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 12px 40px -8px rgba(16, 24, 40, .14);
}

#form_background.style-modern #cover #logo.no_logo {
    box-shadow: none;
}

#form_background.style-modern .field_item:hover .hover,
#form_background.style-modern .field_item.active .hover,
#form_background.style-modern .field_item.ui-sortable-helper .hover {
    border-color: #e5e7eb;
    border-radius: 12px;
}

/* Preview fields are disabled in the builder, but should look like the live form */
#form_background.style-modern .bootstrap-select button.disabled,
#form_background.style-modern .bootstrap-select button:disabled,
#form_background.style-modern #formular select:disabled {
    opacity: 1;
    color: var(--yc-text);
    background-color: var(--yc-surface);
}

#form_background.style-modern #cover #logo:not(.no_logo) {
    overflow: hidden;
}

#form_background.style-modern .submit_button button[type=submit] {
    height: auto;
    text-transform: none;
}

#form_background.style-modern #edit_logo {
    left: 6px;
    right: 6px;
    bottom: 6px;
    border-radius: 0 0 10px 10px;
}

#form_background.style-modern #edit_cover {
    border-radius: 10px 0 0 0;
}
