/* ============================================
   МОДАЛЬНЫЕ ОКНА — HTML5 <dialog> + fallback
   ============================================ */

/* --- HTML5 <dialog> (основной подход) --- */
dialog.med-modal {
    /* position: fixed;
    top: 0;
    left: 0; */
    color:#333;
    width: 100vw;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    display: none;
    overflow-y: auto;
    justify-content: center;
    z-index: 99999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

dialog.med-modal::backdrop {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    animation: med-backdrop-fadein 0.3s ease forwards;
}

@keyframes med-backdrop-fadein {
    from { opacity: 0; }
    to   { opacity: 1; }
}

dialog.med-modal[open] {
    display: flex;
    opacity: 1;
}

dialog.med-modal.is-closing {
    opacity: 0;
}

dialog.med-modal.is-closing .med-modal-card {
    transform: translateY(20px) scale(0.95);
}

dialog.med-modal.is-closing::backdrop {
    animation: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Оверлей — флекс-контейнер для центрирования карточки */
dialog.med-modal .med-dialog-overlay {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100%;
    padding: clamp(.5em, 7.5vmin, 3em); clamp(.5em, 2.5vmin, 2em);
}

/* Карточка */
dialog.med-modal .med-modal-card {
    background: #fff;
    padding: clamp(.5em, 7.5vmin, 3em);
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
    width: 100%;
    max-width: max(90vw, 450px);
    box-sizing: border-box;
    position: relative;
    transform: translateY(20px) scale(0.95);
    transition: transform 0.3s ease;
    pointer-events: auto;
}

dialog.med-modal[open] .med-modal-card {
    transform: translateY(0) scale(1);
}

/* Блокировка скролла body при открытом диалоге */
body.dialog-open {
    overflow: hidden;
    padding-right: var(--med-scrollbar-compensation, 0px);
}

/* --- Fallback: overlay-подход (для старых модалок) --- */
.med-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.med-modal-overlay.is-active {
    opacity: 1;
    pointer-events: auto;
}

.med-modal-overlay .med-modal-card {
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
    width: 100%;
    max-width: 400px;
    box-sizing: border-box;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.med-modal-overlay.is-active .med-modal-card {
    transform: scale(1);
}

/* Кнопка закрытия модалки */
.med-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #94a3b8;
    line-height: 1;
    padding: 4px;
    transition: color 0.1s;
}

.med-modal-close:hover {
    color: #475569;
}

/* ============================================
   Заголовок (используется и в модалке, и на странице /login)
   ============================================ */
.med-login-title {
    margin: 0 0 24px 0;
    font-size: 24px;
    text-align: center;
    color: #1e293b;
    font-weight: 700;
}

/* ============================================
   Общая форма входа (login-form.php)
   Применяется и в модалке, и на странице /login
   ============================================ */
.med-login-form .login-username,
.med-login-form .login-password {
    margin-bottom: 16px;
    position: relative;
}

.med-login-form label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: #334155;
    font-size: 14px;
}

.med-login-form input[type="text"],
.med-login-form input[type="password"] {
    width: 100%;
    padding: 10px 40px 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 15px;
}

.med-login-form input[type="text"]:focus,
.med-login-form input[type="password"]:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,115,170,0.1);
}

.med-login-form .login-remember {
    margin-bottom: 20px;
    font-size: 14px;
    color: #64748b;
}

.med-login-form .login-submit input[type="submit"] {
    width: 100%;
    background-color: #0073aa;
    color: #fff;
    border: 0;
    padding: 12px;
    border-radius: 6px;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
}

.med-login-form .login-submit input[type="submit"]:hover {
    background-color: #005984;
}

/* ============================================
   Сообщение об ошибке входа
   ============================================ */
.med-login-error {
    background: #fef2f2;
    border-left: 4px solid #dc2626;
    color: #991b1b;
    padding: 10px 12px;
    font-size: 14px;
    border-radius: 4px;
    margin-bottom: 20px;
}

/* ============================================
   Сообщение об ошибке AJAX (в модалке)
   ============================================ */
.med-ajax-error {
    background: #fef2f2;
    border-left: 4px solid #dc2626;
    color: #991b1b;
    padding: 10px;
    font-size: 14px;
    border-radius: 4px;
    margin-top: 16px;
}

/* ============================================
   Нижние ссылки (забыли пароль / регистрация)
   ============================================ */
.med-login-footer-links {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #f1f5f9;
    font-size: 13px;
}

.med-login-footer-links__link {
    flex: 1 1 150px;
}

.med-login-footer-links a {
    color: #0073aa;
    text-decoration: none;
}

.med-login-footer-links a:hover {
    text-decoration: underline;
}

.med-login-footer-links a.lost-pass {
    color: #64748b;
}

.med-cabinet-form-submit-btn {
    font-size: 1em;
    text-transform: uppercase;
}

/* ============================================
   Заголовок модалки (только для модалки)
   ============================================ */

/* ============================================
   Личный кабинет (cabinet-view.php)
   ============================================ */

.med-cabinet-wrapper {
    max-width: 900px;
    margin: 0 auto;
    font-family: system-ui, -apple-system, sans-serif;
}

/* Верхняя панель */
.med-cabinet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 16px;
    margin-bottom: 24px;
}

.med-cabinet-header h2 {
    margin: 0;
    font-size: 24px;
}

.med-cabinet-logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #fff;
    background-color: #ef4444;
    border: 1px solid #dc2626;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 18px;
    border-radius: 6px;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.med-cabinet-logout:hover {
    background-color: #dc2626;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.35);
}

/* Уведомления */
.med-alert {
    padding: 12px 16px;
    margin-bottom: 20px;
    border-radius: 4px;
    border-left: 4px solid;
}

.med-alert-success {
    background-color: #f0fdf4;
    border-left-color: #16a34a;
    color: #166534;
}

.med-alert-error {
    background-color: #fef2f2;
    border-left-color: #dc2626;
    color: #991b1b;
}

.med-alert-error ul {
    margin: 0;
    padding-left: 20px;
}

/* Навигация по вкладкам */
.med-cabinet-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 1px;
}

.med-cabinet-tab {
    padding: 10px 20px;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    color: #64748b;
}

.med-cabinet-tab:hover {
    color: #0073aa;
}

.med-cabinet-tab.is-active {
    border-bottom-color: #0073aa;
    color: #0073aa;
}

/* Контент вкладки */
.med-cabinet-tab-content {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 24px;
}

/* Форма профиля */
.med-profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 18px;
}

.med-profile-grid > div {
    display: flex;
    flex-direction: column;
}

.med-password-field {
    position: relative;
}

.med-form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
}

.med-form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    box-sizing: border-box;
}

.med-form-input:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,115,170,0.1);
}

.med-form-divider {
    border: 0;
    border-top: 1px solid #e2e8f0;
    margin: 24px 0;
}

.med-form-hint {
    color: #64748b;
    font-size: 14px;
    margin: 10px 0;
}

.med-form-submit {
    background-color: #0073aa;
    color: #fff;
    border: 0;
    padding: 10px 24px;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
}

.med-form-submit:hover {
    background-color: #005984;
}

/* Заглушка входа */
.med-login-prompt {
    text-align: center;
    padding: 40px 20px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    max-width: 500px;
    margin: 0 auto;
}

.med-login-prompt-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.med-login-prompt h3 {
    margin-bottom: 12px;
    font-weight: 600;
}

.med-login-prompt p {
    color: #64748b;
    margin-bottom: 24px;
}

.med-login-prompt a {
    display: inline-block;
    background-color: #0073aa;
    color: #fff;
    padding: 10px 24px;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
}

/* ============================================
   Пункт меню "Выход" (SVG-иконка)
   ============================================ */
.med-menu-logout a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #64748b;
    text-decoration: none;
    transition: color 0.2s;
}

.med-menu-logout a:hover {
    color: #ef4444;
}

.med-menu-logout svg {
    flex-shrink: 0;
}

.med-menu-logout a:hover .logout-arrow {
    transform: translateX(4px);
}

/* ============================================
   ACF поля (динамические поля из ACF)
   ============================================ */
.med-cabinet-field {
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
}

.med-cabinet-field label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
}

.med-cabinet-field .required {
    color: #dc2626;
}

.med-cabinet-field input[type="text"],
.med-cabinet-field input[type="email"],
.med-cabinet-field input[type="tel"],
.med-cabinet-field input[type="number"],
.med-cabinet-field textarea,
.med-cabinet-field select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 14px;
}

.med-cabinet-field input:focus,
.med-cabinet-field textarea:focus,
.med-cabinet-field select:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,115,170,0.1);
}

.med-cabinet-field textarea {
    resize: vertical;
    min-height: 80px;
}

/* ============================================
   Форма регистрации
   ============================================ */
.med-cabinet-registration {
    max-width: 600px;
    margin: 0 auto;
    font-family: system-ui, -apple-system, sans-serif;
}

.med-cabinet-registration-title {
    margin-bottom: 1em;
    font-size: clamp(1.5rem, 10vmin, 2.5rem);
}

.med-cabinet-registration-title--light {
    color: #fff;
}

.med-cabinet-registration .med-cabinet-field {
    margin-bottom: 16px;
}

.med-cabinet-registration .med-cabinet-field small {
    display: block;
    color: #64748b;
    font-size: 12px;
    margin-top: 4px;
}

.med-cabinet-registration .button-primary {
    background-color: #0073aa;
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 10px;
    display: block;
    width: 100%;
    transition: background-color ease-in-out .2s;
}

.med-cabinet-registration .button-primary:hover {
    background-color: #005984;
}

.med-fields-wrapper {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    column-gap: 1em;
}

/* ============================================
   Админка — страница настроек ACF
   ============================================ */
.acf-fields-config-table {
    width: 100%;
    border-collapse: collapse;
}

.acf-fields-config-table th,
.acf-fields-config-table td {
    padding: 10px;
    border-bottom: 1px solid #eee;
    text-align: left;
    vertical-align: middle;
}

.acf-fields-config-table th {
    font-weight: 600;
    background: #f9fafb;
}

.acf-fields-config-table code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
}

/* ============================================
   Форма регистрации в FancyBox модалке
   ============================================ */
.med-cabinet-registration-modal {
    max-width: 500px;
    padding: 20px;
    font-family: system-ui, -apple-system, sans-serif;
    background: #00a1db;
    color: #fff;
}

.med-cabinet-registration-modal h2 {
    color: #fff;
    margin: 0 0 20px 0;
    font-size: 24px;
    text-align: center;
}

.med-cabinet-registration-modal .med-cabinet-field {
    margin-bottom: 14px;
}

.med-cabinet-registration-modal .med-cabinet-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 14px;
    color: #fff;
}

.med-cabinet-registration-modal .med-cabinet-field input,
.med-cabinet-registration-modal .med-cabinet-field textarea,
.med-cabinet-registration-modal .med-cabinet-field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 14px;
    background: rgba(255,255,255,0.9);
    color: #1e293b;
}

.med-cabinet-registration-modal .med-cabinet-field input:focus,
.med-cabinet-registration-modal .med-cabinet-field textarea:focus,
.med-cabinet-registration-modal .med-cabinet-field select:focus {
    border-color: #fff;
    outline: none;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.3);
}

.med-cabinet-registration-modal .button-primary {
    width: 100%;
    background: #fff;
    color: #00a1db;
    border: none;
    padding: 12px;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}

.med-cabinet-registration-modal .button-primary:hover {
    background: #f0f9ff;
}

/* Ошибки в модалке */
.med-cabinet-registration-modal .notice-error {
    background: #fef2f2;
    border-left: 3px solid #dc2626;
    color: #991b1b;
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 12px;
    font-size: 13px;
}

/* Radio/checkbox в модалке */
.med-cabinet-registration-modal label[style] {
    display: flex !important;
    align-items: flex-start;
    gap: 8px;
    font-weight: normal;
    margin-bottom: 6px;
    color: #fff;
}

.med-cabinet-registration-modal label[style] a {
    color: #fff;
    text-decoration: underline;
}

.med-cabinet-registration-modal label[style] a:hover {
    color: #f0f9ff;
}

.med-cabinet-registration-modal label[style] input[type="radio"],
.med-cabinet-registration-modal label[style] input[type="checkbox"] {
    width: auto;
    margin-top: 3px;
}

/* Подсказка под формой */
.med-form-hint {
    color: #64748b;
    font-size: 13px;
    margin: 10px 0;
}

/* Ссылка в чекбоксе */
.med-cabinet-field a {
    color: #0073aa;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.med-cabinet-field a:hover {
    color: #005984;
}

/* ============================================
   Страница успешной регистрации
   ============================================ */
.med-cabinet-success {
    text-align: center;
    padding: 40px 20px;
    max-width: 500px;
    margin: 0 auto;
}

.med-success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #dcfce7;
    color: #16a34a;
    font-size: 40px;
    margin-bottom: 20px;
}

.med-cabinet-success h2 {
    margin-bottom: 16px;
    color: #1e293b;
}

.med-cabinet-success p {
    color: #475569;
    margin-bottom: 12px;
}

.med-cabinet-success ul {
    text-align: left;
    color: #475569;
    margin: 16px 0;
    padding-left: 24px;
}

.med-cabinet-success ul li {
    margin-bottom: 6px;
}

.med-cabinet-success .button-primary {
    display: inline-block;
    background: #0073aa;
    color: #fff;
    padding: 12px 24px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    margin-top: 16px;
}

.med-cabinet-success .button-primary:hover {
    background: #005984;
}

/* ============================================
   AJAX-контейнеры для форм регистрации
   ============================================ */
.med-cabinet-form-errors .notice-error {
    background: #fef2f2;
    border-left: 3px solid #dc2626;
    color: #991b1b;
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 16px;
}

.med-cabinet-form-errors .notice-error ul {
    margin: 0;
    padding-left: 20px;
}

.med-cabinet-form-errors .notice-error li {
    margin-bottom: 4px;
}

.med-cabinet-form-success {
    text-align: center;
    padding: 30px 20px;
}

.med-cabinet-form-success .med-success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #dcfce7;
    color: #16a34a;
    font-size: 32px;
    margin-bottom: 16px;
}

.med-cabinet-form-success h3 {
    margin: 0 0 12px 0;
    color: #1e293b;
}

.med-cabinet-form-success p {
    color: #475569;
    margin-bottom: 8px;
}

/* Успех в модалке с синим фоном */
.med-cabinet-registration-modal .med-cabinet-form-success {
    text-align: center;
    padding: 30px 20px;
    color: #fff;
}

.med-cabinet-registration-modal .med-cabinet-form-success .med-success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    color: #fff;
    font-size: 32px;
    margin-bottom: 16px;
}

.med-cabinet-registration-modal .med-cabinet-form-success h3 {
    color: #fff;
    margin: 0 0 12px 0;
}

.med-cabinet-registration-modal .med-cabinet-form-success p {
    color: rgba(255,255,255,0.9);
    margin-bottom: 8px;
}

.modal .med-cabinet-field a {
    color: #ffc107;
}

.modal .med-cabinet-field a:hover {
    color: #ffa000;
}

/* ============================================
   Защищённый контент (шорткод [med_cabinet_protected])
   ============================================ */
.med-protected-content-prompt {
    text-align: center;
    padding: 40px 20px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    margin: 0 auto;
}

.med-protected-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.med-protected-text {
    color: #64748b;
    margin-bottom: 24px;
}

.med-protected-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.med-protected-buttons .button {
    display: inline-block;
    padding: 10px 24px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.med-protected-buttons .button-primary {
    background-color: #0073aa;
    color: #fff;
    border: none;
}

.med-protected-buttons .button-primary:hover {
    background-color: #005984;
}

.med-protected-buttons .button:not(.button-primary) {
    background-color: #fff;
    color: #0073aa;
    border: 1px solid #0073aa;
}

.med-protected-buttons .button:not(.button-primary):hover {
    background-color: #f0f9ff;
}
