/**
 * Toweringmedia Custom Forms — Hyvä storefront styles
 * Loaded directly (no Tailwind rebuild required).
 */

.tm-customform-shell {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 0 1rem;
    box-sizing: border-box;
}

.tm-customform-widget.tm-customform-shell,
.tm-customform-widget .tm-customform-shell {
    display: flex;
    justify-content: center;
    width: 100%;
}

/* CMS / Page Builder content often left-aligns children */
.column.main .tm-customform-shell,
.page-main .tm-customform-shell,
[data-content-type='html'] .tm-customform-shell,
.prose .tm-customform-shell {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.tm-customform--hyva {
    width: 100%;
    max-width: 42rem;
    margin: 1.5rem 0 2.5rem;
    padding: 1.5rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.06), 0 1px 2px -1px rgb(0 0 0 / 0.06);
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .tm-customform--hyva {
        padding: 2rem;
    }
}

.tm-customform--hyva .tm-customform__title {
    margin: 0 0 1.25rem;
    font-size: 1.5rem;
    line-height: 1.3;
    font-weight: 600;
    color: #111827;
    text-align: center;
}

.tm-customform--hyva .tm-customform__form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.tm-customform--hyva .tm-customform__messages {
    display: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
}

.tm-customform--hyva .tm-customform__messages.tm-customform__messages--visible {
    display: block;
    margin-bottom: 0.25rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.4;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.tm-customform--hyva .tm-customform__messages.tm-customform__messages--visible._error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

.tm-customform--hyva .tm-customform__page.legend,
.tm-customform--hyva .tm-customform__page > .legend {
    margin: 0 0 1rem;
    padding: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
}

.tm-customform--hyva .tm-customform__fields {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

@media (min-width: 768px) {
    .tm-customform--hyva .tm-customform__fields:has(.tm-customform__col--2) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .tm-customform--hyva .tm-customform__fields:has(.tm-customform__col--3) {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.tm-customform--hyva .tm-customform__field-wrap {
    min-width: 0;
}

.tm-customform--hyva .field {
    margin: 0;
}

.tm-customform--hyva .field > .label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.4;
    color: #374151;
}

/* Single required indicator via Hyvä / theme pattern */
.tm-customform--hyva .field.required > .label .tm-customform__required {
    display: none;
}

.tm-customform--hyva .field.required > .label::after {
    content: " *";
    color: #dc2626;
    font-weight: 600;
}

.tm-customform--hyva .tm-customform__choice-group .legend.tm-customform__legend::after,
.tm-customform--hyva .tm-customform__choice-group fieldset.required .legend::after {
    content: " *";
    color: #dc2626;
    font-weight: 600;
}

.tm-customform--hyva .control {
    width: 100%;
}

.tm-customform--hyva .form-input,
.tm-customform--hyva .form-select,
.tm-customform--hyva .form-textarea {
    width: 100%;
    max-width: 100%;
}

.tm-customform--hyva .tm-customform__heading {
    margin: 0.25rem 0 0.5rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
}

.tm-customform--hyva .tm-customform__heading-sub {
    margin: 0 0 0.5rem;
    font-size: 0.875rem;
    color: #6b7280;
}

.tm-customform--hyva .tm-customform__choice-group {
    margin: 0;
    padding: 0;
    border: 0;
}

.tm-customform--hyva .tm-customform__choice-group .choice {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.tm-customform--hyva .tm-customform__choice-group .choice .label {
    margin: 0;
    font-weight: 400;
}

.tm-customform--hyva .tm-customform__newsletter label.tm-customform__choice-label,
.tm-customform--hyva .tm-customform__privacy label.tm-customform__choice-label,
.tm-customform--hyva .tm-customform__choice-group .choice label.tm-customform__choice-label {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    cursor: pointer;
}

.tm-customform--hyva .tm-customform__steps {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.tm-customform--hyva .tm-customform__step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    border: 2px solid #d1d5db;
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
    background: #fff;
}

.tm-customform--hyva .tm-customform__step._active {
    border-color: var(--color-primary, #2563eb);
    background: var(--color-primary, #2563eb);
    color: #fff;
}

.tm-customform--hyva .tm-customform__step._complete {
    border-color: var(--color-primary, #2563eb);
    color: var(--color-primary, #2563eb);
}

.tm-customform--hyva .tm-customform__nav--hidden {
    display: none !important;
}

.tm-customform--hyva .tm-customform__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid #f3f4f6;
}

.tm-customform--hyva .tm-customform__actions .tm-customform__nav-prev-wrap {
    width: 100%;
    display: flex;
    justify-content: center;
}

@media (min-width: 640px) {
    .tm-customform--hyva .tm-customform__actions .tm-customform__nav-prev-wrap {
        width: auto;
    }
}

.tm-customform--hyva .tm-customform__actions .tm-customform__buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
    justify-content: center;
}

@media (min-width: 640px) {
    .tm-customform--hyva .tm-customform__actions .tm-customform__buttons {
        width: auto;
    }
}

.tm-customform--hyva .tm-customform__submit,
.tm-customform--hyva .tm-customform__next,
.tm-customform--hyva .tm-customform__prev {
    min-width: 8rem;
}

@media (max-width: 639px) {
    .tm-customform--hyva .tm-customform__submit,
    .tm-customform--hyva .tm-customform__next {
        flex: 1 1 100%;
    }
}

/* Linear layout */
.tm-customform--hyva.tm-customform--linear .field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

@media (min-width: 768px) {
    .tm-customform--hyva.tm-customform--linear .field {
        flex-direction: row;
        align-items: flex-start;
        gap: 1rem;
    }

    .tm-customform--hyva.tm-customform--linear .field > .label {
        flex: 0 0 30%;
        max-width: 30%;
        margin-bottom: 0;
        padding-top: 0.625rem;
    }

    .tm-customform--hyva.tm-customform--linear .field > .control {
        flex: 1 1 auto;
        min-width: 0;
    }
}

/* Circle layout */
.tm-customform--hyva.tm-customform--circle .form-input,
.tm-customform--hyva.tm-customform--circle .form-select,
.tm-customform--hyva.tm-customform--circle .form-textarea {
    border-radius: 9999px;
}

.tm-customform--hyva.tm-customform--circle .form-textarea {
    border-radius: 1.5rem;
}

.tm-customform--hyva.tm-customform--circle .tm-customform__submit {
    border-radius: 9999px;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

.tm-customform--hyva .tm-customform__address .tm-customform__address-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 768px) {
    .tm-customform--hyva .tm-customform__address .tm-customform__address-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .tm-customform--hyva .tm-customform__address .tm-customform__address-grid .field:last-child {
        grid-column: 1 / -1;
    }
}

.tm-customform--hyva .tm-customform__map-canvas {
    height: 17.5rem;
    margin-top: 0.75rem;
    border-radius: 0.5rem;
    background: #f3f4f6;
}

.tm-customform--hyva .tm-customform__error {
    margin-top: 0.375rem;
    font-size: 0.875rem;
    line-height: 1.4;
    color: #dc2626;
}

.tm-customform--hyva .tm-customform__note {
    margin-top: 0.375rem;
    font-size: 0.875rem;
    line-height: 1.4;
    color: #6b7280;
}

.tm-customform--hyva .tm-customform__page-title {
    margin: 0 0 1rem;
    padding: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
    text-align: center;
}

.tm-customform--hyva .tm-customform__choice-label {
    font-size: 0.875rem;
    line-height: 1.5;
    color: #374151;
}

.tm-customform--hyva .tm-customform__address-country {
    grid-column: 1 / -1;
}

@media (min-width: 768px) {
    .tm-customform--hyva .tm-customform__address .tm-customform__address-grid .tm-customform__address-country {
        grid-column: 1 / -1;
    }
}

.tm-customform-popup__content .tm-customform--hyva {
    margin: 0;
    max-width: none;
    padding: 0;
    border: 0;
    box-shadow: none;
}

/* Hyvä popup modal — standalone CSS (no Tailwind rebuild required) */
[x-cloak].tm-customform-popup__overlay {
    display: none !important;
}

.tm-customform-popup__overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    box-sizing: border-box;
}

.tm-customform-popup__backdrop {
    position: absolute;
    inset: 0;
    background: rgb(0 0 0 / 50%);
}

.tm-customform-popup__panel {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 42rem;
    max-height: 90vh;
    max-height: 90dvh;
    border-radius: 0.75rem;
    background: #fff;
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 25%);
    overflow: hidden;
}

.tm-customform-popup__header {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.tm-customform-popup__heading {
    margin: 0;
    padding-right: 2rem;
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.4;
    color: #111827;
}

.tm-customform-popup__close {
    flex-shrink: 0;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: #9ca3af;
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
}

.tm-customform-popup__close:hover {
    color: #4b5563;
}

.tm-customform-popup__content {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 1rem 1.5rem 1.5rem;
    box-sizing: border-box;
}

.tm-customform-popup__content .tm-customform-shell--in-popup,
.tm-customform-popup__content .tm-customform-shell {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
    align-items: stretch;
    align-self: stretch;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
}

.tm-customform-popup__content .tm-customform-shell--in-popup .tm-customform--in-popup,
.tm-customform-popup__content .tm-customform-shell .tm-customform--in-popup {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
    width: 100%;
}

.tm-customform-popup__content .tm-customform--hyva .tm-customform__title {
    display: none;
}

.tm-customform--in-popup.tm-customform--hyva {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
}

.tm-customform--in-popup .tm-customform__messages {
    flex: 0 0 auto;
}

.tm-customform--in-popup .tm-customform__form--popup {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
}

.tm-customform--in-popup .tm-customform__popup-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.tm-customform-popup__content .tm-customform--hyva .tm-customform__actions--popup,
.tm-customform--in-popup .tm-customform__actions--popup {
    flex: 0 0 auto;
    background: #fff;
    padding-top: 1rem;
    margin-top: 0;
    border-top: 1px solid #e5e7eb;
}
