html {
    font-size: 17px;
    scroll-behavior: auto;
}

select[readonly] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    pointer-events: none;
    touch-action: none;
}

[x-cloak] {
    display: none !important;
}

.exam-values-latest-only [data-latest="false"] {
    display: none;
}

@layer base {

    *,
    ::after,
    ::before,
    ::backdrop,
    ::file-selector-button {
        border-color: var(--color-gray-200, currentcolor);
    }
}

html {
    /* font-size: 17px; */
}

/* Slightly smaller UI type on phones (rem-based spacing/type). */
@media (max-width: 767px) {
    html {
        font-size: 14px;
    }
}

/* iOS / notched devices — keep chrome and scroll content out of the home
   indicator and status bar. Requires viewport-fit=cover on the meta viewport. */
:root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
}

.safe-pt {
    padding-top: var(--safe-top);
}

.safe-pb {
    padding-bottom: var(--safe-bottom);
}

.safe-px {
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
}

.safe-inset-bottom {
    bottom: max(1rem, var(--safe-bottom));
}

.safe-fab-bottom {
    bottom: calc(1rem + var(--safe-bottom));
}

.safe-bar-pb {
    padding-bottom: calc(0.75rem + var(--safe-bottom));
}

/* Scrollable main areas — keep last controls above the iOS home indicator */
.main-safe-pb {
    padding-bottom: calc(5rem + var(--safe-bottom));
}

@media (min-width: 1024px) {
    .main-safe-pb {
        padding-bottom: 7rem;
    }
}

.admin-main-safe-pb {
    padding-bottom: calc(4rem + var(--safe-bottom));
}

@media (min-width: 1024px) {
    .admin-main-safe-pb {
        padding-bottom: 4rem;
    }
}

/* Default matches former py-4; extra room for the iOS home indicator only on phones */
.patient-shell-safe-pb {
    padding-bottom: 1rem;
}

@media (max-width: 767px) {
    .patient-shell-safe-pb {
        padding-bottom: calc(5rem + var(--safe-bottom));
    }
}

.consultation-mobile-safe-pb {
    padding-bottom: calc(6rem + var(--safe-bottom));
}

@media (min-width: 768px) {
    .consultation-mobile-safe-pb {
        padding-bottom: 0;
    }
}

/* Memed host: JS sets height to the remaining viewport and applies desktop
   zoom. Layout options live in a cross-origin iframe and are disabled via
   MdHub setFeatureToggle({ optionsPrescription: false }); these rules only
   cover a same-document fallback.
   Host stays above the patient header (z-30) so MdHub fullscreen modals
   remain clickable. The tabs dropdown raises the header only while open. */
.memed-host,
.memed-desktop-fit {
    position: relative;
    z-index: 50;
    overflow: hidden;
}

[data-patient-shell-header].is-tabs-open {
    z-index: 90;
}

html.memed-overlay-open [data-patient-shell-header] {
    z-index: 0;
}

html.memed-overlay-open .memed-host,
html.memed-overlay-open .memed-desktop-fit,
html.memed-overlay-open .memed-mobile-fit,
html.memed-overlay-open #iframe-container {
    position: relative;
    z-index: 80;
}

.memed-lock-layout #opcoesReceituarios,
.memed-lock-layout #opcoesReceituario,
.memed-lock-layout [name="opcoesReceituarios"],
.memed-lock-layout [name="opcoesReceituario"] {
    display: none !important;
}

@media (max-width: 767px) {
    .memed-mobile-fit {
        position: relative;
        z-index: 50;
        overflow: hidden;
        margin-bottom: calc(-1 * (5rem + var(--safe-bottom)));
        border-bottom-width: 0;
    }
}



.inline-field {
    display: none;
}

.inline-edit .inline-field {
    display: initial;
}

.scrollbar::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.scrollbar::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 10px;
    margin: 10px;
}

.scrollbar::-webkit-scrollbar-thumb {
    background: #b0b0b0;
    border-radius: 10px;
}

.scrollbar::-webkit-scrollbar-thumb:hover {
    background: #909090;
}


.ai_message p {
    @apply mb-4;
}

.ai_message h1 {
    @apply text-2xl font-medium mt-6 mb-4;
}

.ai_message h2 {
    @apply text-xl font-medium mt-5 mb-3;
}

.ai_message h3 {
    @apply text-lg font-medium mt-4 mb-2;
}

.ai_message ul {
    @apply list-disc list-inside my-4;
}

.ai_message ol {
    @apply list-decimal list-inside my-4;
}

.ai_message li {
    @apply mb-1;
}

.ai_message a {
    @apply text-blue-500 hover:underline;
}

.ai_message blockquote {
    @apply border-l-4 border-gray-300 pl-4 italic text-gray-600 my-4;
}

.ai_message pre {
    @apply bg-gray-900 text-white p-4 rounded-sm overflow-x-auto;
}

.ai_message code {
    @apply bg-gray-100 text-red-600 px-1 py-0.5 rounded-sm;
}

.ai_message table {
    @apply w-full border-collapse border border-gray-300 my-4;
}

.ai_message th {
    @apply bg-gray-200 font-medium text-left p-2 border border-gray-300;
}

.ai_message td {
    @apply p-2 border border-gray-300;
}

.ai_message img {
    @apply max-w-full rounded-sm  my-4;
}

.ai_message strong {
    @apply font-medium;
}

.ai_message li>p {
    @apply mb-0 inline;
}

.ai_message li>ul {
    @apply mt-0;
}

.fullscreen {
    @apply fixed top-0 left-0 w-full h-full z-50 bg-white;
}

label.required::after {
    @apply content-['*'] ml-1 text-red-500;
}

label.optional::after {
    @apply content-['(opcional)'] ml-1 text-gray-500;
}

.markdown {
    @apply leading-relaxed text-sm;

    p {
        @apply mb-4;
    }

    p:last-child {
        @apply mb-0;
    }

    h1 {
        @apply text-xl font-bold mb-6 mt-8 border-b border-gray-300 pb-2;
    }

    h2 {
        @apply text-lg font-bold mb-4 mt-6;
    }

    h3 {
        @apply text-lg font-bold mb-3 mt-5;
    }

    h4 {
        @apply text-lg font-semibold mb-2 mt-4;
    }

    h5 {
        @apply text-base font-semibold mb-2 mt-3;
    }

    h6 {
        @apply text-sm font-semibold mb-2 mt-3 text-gray-600 uppercase tracking-wide;
    }

    ul {
        @apply list-disc pl-6 mb-4 space-y-1;
    }

    ol {
        @apply list-decimal pl-6 mb-4 space-y-1;
    }

    li {
        @apply text-gray-700;
    }

    a {
        @apply text-blue-600 hover:text-blue-800 underline decoration-blue-600/30 hover:decoration-blue-600 transition-colors;
    }

    strong,
    b {
        @apply font-bold;
    }

    em,
    i {
        @apply italic text-gray-800;
    }

    code {
        @apply bg-gray-100 text-blue-900 px-1.5 py-0.5 rounded-sm text-sm font-mono font-medium border border-gray-300;
    }

    pre {
        @apply bg-gray-50 border border-gray-300 rounded-sm  p-4 overflow-x-auto mb-4;

        code {
            @apply bg-transparent border-none px-0 py-0 text-gray-800;
        }
    }

    .mermaid {
        @apply my-3 overflow-x-auto;
    }

    blockquote {
        @apply border-l-4 border-blue-500 pl-4 py-2 my-4 bg-blue-50 text-gray-700 italic;
    }

    hr {
        @apply my-8 border-t-2 border-gray-300;
    }

    img {
        @apply max-w-full h-auto rounded-sm  shadow-xs my-4;
    }

    table {
        @apply w-full border-collapse border border-gray-300 my-4 rounded-sm  overflow-hidden;
    }

    th {
        @apply bg-gray-100 border border-gray-300 px-4 py-2 text-left font-semibold;
    }

    td {
        @apply border border-gray-300 px-4 py-2 text-gray-700;
    }

    tr:nth-child(even) {
        @apply bg-gray-50;
    }

    /* Nested lists */
    ul ul,
    ol ol,
    ul ol,
    ol ul {
        @apply mt-1 mb-0;
    }

    /* Code syntax highlighting support */
    .highlight {
        @apply rounded-sm  overflow-hidden;
    }
}

/* Dragula */
.gu-mirror {
    position: fixed !important;
    margin: 0 !important;
    z-index: 9999 !important;
    opacity: 0.8;
    -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";
    filter: alpha(opacity=80);
}

.gu-hide {
    display: none !important;
}

.gu-unselectable {
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
}

.gu-transit {
    opacity: 0.2;
    -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=20)";
    filter: alpha(opacity=20);
}
