.form-control.is-invalid {
    border-color: var(--color-states-color-error, #EF4444) !important;
}

.form-control.is-invalid:focus {
    border-color: var(--color-states-color-error, #EF4444) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18) !important;
}

.form-error {
    margin: 0;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.35;
    color: var(--color-states-color-error, #EF4444) !important;
}

.phone-field.form-control {
    display: flex;
    align-items: stretch;
    padding: 0;
    overflow: hidden;
}

.phone-field.form-control.is-country-open {
    overflow: visible;
}

.phone-field.form-control:focus-within {
    border-color: var(--primary-primary);
}

.phone-field.form-control.is-invalid,
.phone-field.form-control.is-invalid:focus-within {
    border-color: var(--color-states-color-error, #EF4444) !important;
}

.phone-field.is-disabled {
    background-color: #F7F7F7;
    pointer-events: none;
}

.phone-field .phone-field-code-trigger,
.phone-field .phone-field-number {
    margin: 0;
    border: 0 !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
    height: 100%;
    min-height: 0;
    font-weight: 400;
    font-size: 14px;
    line-height: 20px;
    color: var(--input-input-text);
}

.phone-field .phone-field-code-wrap {
    position: relative;
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    min-width: 5.5rem;
    z-index: 2;
}

.phone-field .phone-field-code-trigger,
.phone-field .phone-field-code-option {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    border: 0;
    outline: none;
    box-shadow: none;
    background: transparent;
    font: inherit;
    color: var(--input-input-text);
    cursor: pointer;
}

.phone-field .phone-field-code-trigger {
    width: 100%;
    min-width: 5.5rem;
    padding: 0 28px 0 14px;
    height: 100%;
    min-height: 44px;
}

.phone-field .phone-field-code-trigger:disabled {
    cursor: not-allowed;
}

.phone-field .phone-field-flag-inline {
    width: 20px;
    height: 15px;
    object-fit: cover;
    border-radius: 2px;
    flex-shrink: 0;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.phone-field .phone-field-code-value {
    font-weight: 400;
    font-size: 14px;
    line-height: 20px;
    white-space: nowrap;
}

.phone-field .phone-field-chevron {
    position: absolute;
    right: 10px;
    top: 50%;
    width: 12px;
    height: 8px;
    transform: translateY(-50%);
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%239A9898' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 12px 8px;
}

.phone-field .phone-field-code-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 30;
    min-width: 100%;
    width: max-content;
    max-height: 240px;
    margin: 0;
    padding: 6px;
    list-style: none;
    overflow-y: auto;
    border: 1px solid var(--border-border-default, #E5E5E5);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.phone-field .phone-field-code-option {
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    text-align: left;
}

.phone-field .phone-field-code-option:hover,
.phone-field .phone-field-code-option:focus-visible {
    background: #F5F5F5;
}

.phone-field .phone-field-code-option.is-selected {
    background: #F0FDF4;
}

.phone-field .phone-field-divider {
    width: 1px;
    height: 22px;
    align-self: center;
    flex-shrink: 0;
    background: var(--border-border-default);
}

.phone-field .phone-field-number {
    flex: 1;
    min-width: 0;
    padding: 0 16px 0 12px;
    -webkit-appearance: none;
    appearance: none;
}

.phone-field .phone-field-code-trigger:focus,
.phone-field .phone-field-number:focus {
    border: 0 !important;
    outline: none !important;
    box-shadow: none !important;
}

.phone-field .phone-field-number::placeholder {
    color: var(--input-input-placeholder);
}

.form-control[disabled],
.form-control:disabled {
    background-color: #F7F7F7;
    color: var(--text-text-body);
    cursor: not-allowed;
}

/*
 * Buttons default to auto width (inline actions / headers).
 * Full-width only in known containers or via .w-full / .btn-block.
 */
.btn {
    width: auto;
    display: inline-flex;
}

.btn.btn-block,
.btn.w-full,
a.btn.w-full,
button.btn.w-full {
    width: 100%;
    display: flex;
}

/* Compact profile / toolbar action pills (Html my-profile: w-fit / h-[38px]) */
.btn.profile-edit-btn,
.btn.btn-compact {
    width: fit-content !important;
    min-width: fit-content !important;
    max-width: fit-content !important;
    height: 38px !important;
    padding: 0 16px !important;
    flex-shrink: 0;
}

@media (min-width: 640px) {
    .btn.profile-edit-btn {
        width: 120px !important;
        min-width: 120px !important;
    }
}

/* Places that still expect full-width CTAs after .btn became auto */
.mobile-menu__actions .btn,
.coach-filters__bottom .btn,
.mobile-drawer-actions .btn,
dialog.modal .modal__panel > .btn,
dialog.modal .modal__panel .btn.btn-block {
    width: 100%;
    display: flex;
}

/* React <dialog> modals — Html-ezyfiit look, above dashboard chrome */
dialog.modal {
    border: 0;
    padding: 0;
    max-width: min(560px, calc(100% - 30px));
    background: transparent;
    z-index: 80;
}

dialog.modal::backdrop {
    background: rgba(0, 0, 0, 0.45);
}

/* Toasts inside native <dialog> top layer (above modal backdrop) */
dialog.modal .modal-toast-container.Toastify__toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    width: auto;
    padding: 0;
    z-index: 1;
}

dialog.modal .modal__panel {
    width: 100%;
}

/* Exercise library filter drawer open state (React sets data-open) */
@media (max-width: 1279px) {
    .coach-filters[data-filter-drawer][data-filter-breakpoint="xl"][data-open="true"] {
        z-index: 60;
    }
}

/* Messages — match ezyfiit-fitness/messages.php (full viewport, no page scroll) */
html:has(.messages-page),
body:has(.messages-page) {
    overflow: hidden;
    height: 100dvh;
    min-height: 0;
}

body:has(.messages-page) #root {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

body:has(.messages-page) > #root > main {
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

body:has(.messages-page) > #root > main > .flex {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    height: 100%;
}

.dashboard-shell--messages {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    padding-bottom: 0;
}

.dashboard-shell--messages .dashboard-container {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    padding-top: 1rem;
    padding-bottom: 1rem;
}

@media (min-width: 640px) {
    .dashboard-shell--messages .dashboard-container {
        padding-top: 1.25rem;
        padding-bottom: 1.25rem;
    }
}

.dashboard-shell--messages .dashboard-container > .flex.flex-col {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    gap: 1rem;
}

@media (min-width: 640px) {
    .dashboard-shell--messages .dashboard-container > .flex.flex-col {
        gap: 1.5rem;
    }
}

.dashboard-shell--messages .dashboard-container > .flex.flex-col > header,
.dashboard-shell--messages .dashboard-container > .flex.flex-col > .shrink-0 {
    flex-shrink: 0;
}

.messages-page {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.messages-page [data-messages-list],
.messages-page [data-chat-thread] {
    scrollbar-width: thin;
    scrollbar-color: #e3e2e2 transparent;
}

.messages-page [data-messages-list]::-webkit-scrollbar,
.messages-page [data-chat-thread]::-webkit-scrollbar {
    width: 6px;
}

.messages-page [data-messages-list]::-webkit-scrollbar-thumb,
.messages-page [data-chat-thread]::-webkit-scrollbar-thumb {
    background: var(--border-border-default);
    border-radius: 9999px;
}

/* Community comment composer — match ezyfiit-fitness/community.php */
.community-comment-form {
    display: flex;
    align-items: center;
    gap: 12px;
    align-self: stretch;
    width: 100%;
    padding-top: 8px;
}

.community-comment-form--edit {
    flex-direction: column;
    align-items: stretch;
    padding-top: 0;
    gap: 8px;
}

.community-comment-field {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

.community-comment-form .community-comment-field .form-control {
    width: 100%;
    height: 48px;
    min-width: 0;
}

.community-comment-form .community-comment-post {
    width: auto;
    min-width: 90px;
    height: 48px;
    flex-shrink: 0;
    box-shadow: none;
}

.community-comment-form .community-comment-post:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.community-comments-preview {
    display: flex;
    flex-direction: column;
    align-self: stretch;
    gap: 16px;
    padding-top: 20px;
    border-top: 1px solid #f2f2f2;
}

.community-view-more {
    align-self: flex-start;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    line-height: 1.4;
    color: #fe8819;
}

.community-view-more:hover {
    text-decoration: underline;
}

.community-view-more:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    text-decoration: none;
}

dialog.modal .community-comments-modal-panel {
    max-height: min(720px, 90vh);
}

.community-comments-modal-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
    max-height: min(420px, 50vh);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 4px;
}

.community-comments-modal-list::-webkit-scrollbar {
    width: 6px;
}

.community-comments-modal-list::-webkit-scrollbar-thumb {
    background: var(--border-border-default);
    border-radius: 9999px;
}

/* FAQ accordion — match ezyfiit-fitness/faq.php */
.faq-item .faq-icon-minus {
    display: none;
}

.faq-item.is-open .faq-icon-plus {
    display: none;
}

.faq-item.is-open .faq-icon-minus {
    display: block;
}

.faq-item .faq-icons {
    position: relative;
}

.faq-panel {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.35s ease;
}

.faq-item.is-open .faq-panel {
    grid-template-rows: 1fr;
}

.faq-panel-inner {
    overflow: hidden;
    min-height: 0;
}

@media (prefers-reduced-motion: reduce) {
    .faq-panel {
        transition: none;
    }
}

/* Product details thumbs — match ezyfiit-fitness/product-details.php */
.product-thumbs-swiper .swiper-slide {
    width: 80px;
}

@media (min-width: 640px) {
    .product-thumbs-swiper .swiper-slide {
        width: 100px;
    }
}

/* ── Modal with a pinned header/footer and a scrollable body ──────────────
   Default `.modal` puts `overflow-y: auto` on the <dialog> itself, so a tall
   form scrolls the whole card — the title scrolls out of view and the browser
   scrollbar runs down the full height of the modal. Opt into this modifier to
   keep the header and the submit button fixed and scroll only the fields. */
dialog.modal.modal--scroll-body {
    overflow: visible;
}

dialog.modal.modal--scroll-body .modal__panel {
    max-height: calc(100vh - 2rem);
    max-height: calc(100dvh - 2rem);
    overflow: hidden;
}

/* The <form> sits between the panel and the body, so it has to flex too. */
dialog.modal.modal--scroll-body .modal__form {
    flex: 1 1 auto;
    min-height: 0;
}

dialog.modal.modal--scroll-body .modal__body {
    flex: 1 1 auto;
    min-height: 0;           /* lets a flex child actually shrink and scroll */
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.18) transparent;
    /* keep fields clear of the scrollbar without shifting layout when absent */
    padding-right: 6px;
    margin-right: -6px;
}

dialog.modal.modal--scroll-body .modal__body::-webkit-scrollbar {
    width: 6px;
}

dialog.modal.modal--scroll-body .modal__body::-webkit-scrollbar-track {
    background: transparent;
}

dialog.modal.modal--scroll-body .modal__body::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.18);
    border-radius: 9999px;
}

dialog.modal.modal--scroll-body .modal__body::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.3);
}

/* Short viewports (landscape phones): trim padding so more form is visible. */
@media (max-height: 640px) {
    dialog.modal.modal--scroll-body .modal__panel {
        padding: 16px;
    }
}
