/**
 * Ordotype Conseils Patients Page - Non-critical Styles
 *
 * These styles can load after the initial render.
 * Critical styles (.rc-html-fcp, .qr-code-fcp-div-block-wrapper opacity)
 * should remain inline in Webflow.
 *
 * Usage in Webflow:
 * <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/william-ordotype/ordotype-scripts@main/conseils-patients/styles.css">
 */

/* Paragraph spacing */
p:not(table p) {
    margin-bottom: 10px !important;
}

/* The rule above is unscoped, so it also hits UI components on the page.
   The copy toast centers its text with flexbox; the forced bottom margin
   shifts the glyphs ~5px above center. Re-zero it there. */
.toast-message-copy p {
    margin-bottom: 0 !important;
}

/* Copy toast: bottom-center instead of over the logo and title.
   The Webflow component is fixed to the top and its message is absolute;
   make the message relative so the wrapper takes its size. */
.toast_component.centered {
    top: auto;
    bottom: calc(1.5rem + env(safe-area-inset-bottom));
    left: 0;
    right: 0;
    pointer-events: none;
}

/* In the pathology iframe (600px, stuck 70px below the top of the screen),
   the bottom of the iframe falls below the fold on short laptop screens. */
html.is-embed .toast_component.centered {
    bottom: 5rem;
}

.toast_component.centered .toast-message-copy {
    position: relative;
}

/* copy-handler.js fades the toast in; slide it up as it appears. */
.toast_component.centered [x-ordo-utils="toast-component-common"] {
    animation: copy-toast-slide-up 0.2s ease;
}

@keyframes copy-toast-slide-up {
    from { transform: translateY(1rem); }
    to { transform: none; }
}

/* Arabic text direction */
.rich-text-ar {
    direction: rtl;
}

/* Print button area */
.print-btn-area {
    background-color: #153cf5;
    color: white;
    padding: 7px;
    border-radius: 4px;
}

/* Print styles */
@media print {
    @page {
        margin-top: 0;
        margin-bottom: 0;
    }

    body {
        margin-top: 0;
        margin-bottom: 0;
        font-size: 20pt;
        line-height: 1.3;
    }

    .rich-text-ar {
        font-size: 20pt;
        line-height: 1.3;
        direction: rtl;
        unicode-bidi: bidi-override;
    }

    table {
        border-collapse: collapse;
        width: 100%;
    }

    td,
    th {
        border: 1px solid black !important;
        padding: 8px;
        background-color: #ffffff !important;
    }

    td[style*="background-color: #2bc48a"] {
        background-color: #2bc48a !important;
    }

    td[style*="background-color: #fcb151"] {
        background-color: #fcb151 !important;
    }

    td[style*="background-color: #e03623"] {
        background-color: #e03623 !important;
    }
}

/* Desktop and tablet (480px+) */
@media only screen and (min-width: 480px) {
    table {
        border-style: hidden;
        border-collapse: collapse;
        border-radius: 6px;
        box-shadow: 0 0 0 1px #CCC;
        margin: 0.5em;
        width: 100% !important;
        margin-left: auto;
        margin-right: auto;
    }

    td {
        border: 1px solid #ccc;
        padding: .75em;
    }

    th {
        font-weight: bold;
        text-align: center;
        border: 1px solid #ccc;
    }

    tr:first-child td:first-child,
    tr:first-child th:first-child {
        border-top-left-radius: 6px;
    }

    tr:first-child td:last-child,
    tr:first-child th:last-child {
        border-top-right-radius: 6px;
    }

    tr:last-child th:first-child {
        border-bottom-left-radius: 6px;
    }

    tr:last-child th:last-child {
        border-bottom-right-radius: 6px;
    }

    tr th:only-child {
        background-color: #d8f2ff;
        color: black;
        font-weight: bold;
        text-align: center;
        margin: .25em;
        padding-bottom: 1em;
        padding-top: 1em;
    }

    tr th:not(:only-of-type) {
        background-color: #d8f2ff;
        color: black;
        font-weight: bold;
        text-align: center;
        margin: .25em;
        padding-bottom: .5em;
        padding-top: .5em;
    }

    table caption {
        font-weight: bold;
        padding-bottom: .75em;
    }

    span:not(.tooltiptext):not([style*="underline"]) {
        text-decoration: none !important;
        background-color: transparent !important;
    }

    strong.rc-html {
        background-color: transparent !important;
    }

    ul {
        padding-left: 1.5em;
    }
}

/* Mobile (max 479px) */
@media only screen and (max-width: 479px) {
    strong {
        font-size: 12px;
    }

    table {
        border-style: hidden;
        border-collapse: collapse;
        border-radius: 6px;
        box-shadow: 0 0 0 1px #ccc;
        margin: 0.25em;
        width: 90% !important;
        margin-left: auto;
        margin-right: auto;
    }

    td {
        border: 1px solid #ccc;
        padding: .5em;
    }

    th {
        font-weight: bold;
        text-align: center;
        border: 1px solid #ccc;
    }

    tr:first-child td:first-child,
    tr:first-child th:first-child {
        border-top-left-radius: 6px;
    }

    tr:first-child td:last-child,
    tr:first-child th:last-child {
        border-top-right-radius: 6px;
    }

    tr:last-child th:first-child {
        border-bottom-left-radius: 6px;
    }

    tr:last-child th:last-child {
        border-bottom-right-radius: 6px;
    }

    tr th:only-child {
        background-color: #d8f2ff;
        color: black;
        font-weight: bold;
        text-align: center;
        margin: .25em;
        padding-bottom: 1em;
        padding-top: 1em;
    }

    tr th:not(:only-of-type) {
        background-color: #d8f2ff;
        color: black;
        font-weight: bold;
        text-align: center;
        margin: .25em;
        padding-bottom: .5em;
        padding-top: .5em;
    }

    table caption {
        font-weight: bold;
        padding-bottom: .5em;
    }

    span:not(.tooltiptext) {
        text-decoration: none !important;
        background-color: transparent !important;
    }

    strong.rc-html {
        background-color: transparent !important;
    }

    ul {
        padding-left: 1.5em;
    }
}
