/* a[target="_blank"]::after {
  content: "\00a0\00a0\00a0";
  background-image: url(../img/External.svg);
  background-position: center;
  background-size: contain;
  display: inline-block;
  background-repeat: no-repeat;
  margin-left: 0.15em;
} */

#grp-user-tools .grp-sso-item {
    display: flex;
    align-items: center;
}

#grp-user-tools #grp-sso-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 34px;
    margin: 0;
    padding: 0 10px;
    border: 0;
    background: transparent;
    color: #42b6e9;
    text-decoration: none;
    cursor: pointer;
}

#grp-user-tools #grp-sso-trigger:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: -3px;
}

#grp-user-tools #grp-sso-trigger[aria-disabled="true"] {
    opacity: 0.5;
    cursor: wait;
}

#grp-user-tools #grp-sso-error:not([hidden]) {
    max-width: 220px;
    padding-right: 8px;
    color: #ffb9b9;
    white-space: normal;
}

/* AccessLogEntry(handles very long URLs with word break) */
#result_list td.field-get_actual_url {
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

/* Sticky headings on Analysis Reports only (/admin_reports/...) */
body.report #result_list {
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid #ccc;
}

body.report #result_list thead th {
    position: sticky;
    top: 80px;
    z-index: 5;
    background: #f8f8f8;
    /* opaque so rows don't show through */
    background-clip: padding-box;
    border: 1px solid #ccc;
    box-shadow: 0 1px 0 #ccc;
    /* keeps the header bottom line while stuck */
}

body.report #result_list tbody td,
body.report #result_list tbody th {
    border: 1px solid #ccc;
}

table.crf-table-field>thead>tr>th {
    font-size: 110%;
    line-height: 110%;
}

table.crf-table-field>tbody>tr>td {
    vertical-align: middle;
}

.loading {
    cursor: wait !important;
}

/* Use sans-serif instead of Arial in grappelli/stylesheets/screen.css */
.grp-font-family,
.grp-button,
input[type="submit"],
a.grp-button,
button.grp-button,
input[type=button].grp-button,
.ui-datepicker,
#ui-timepicker,
.ui-autocomplete,
body,
fieldset.grp-module .grp-row label,
input[type="text"],
input[type="password"],
input[type="url"],
input[type="email"],
input[type="number"],
input[type="submit"],
input[type="reset"],
select,
input,
button,
textarea,
grp-autocomplete-wrapper-m2m,
.grp-autocomplete-wrapper-fk input.ui-autocomplete-input,
.grp-filter .grp-row label,
.ui-datepicker input,
.ui-datepicker select,
.ui-datepicker textarea,
.ui-datepicker button,
#ui-timepicker input,
#ui-timepicker select,
#ui-timepicker textarea,
#ui-timepicker button,
ui-autocomplete input,
.ui-autocomplete select,
.ui-autocomplete textarea,
.ui-autocomplete button,
body[class*="grp"] .select2-container--admin-autocomplete .select2-selection--single,
body[class*="grp"] .select2-container--admin-autocomplete .select2-selection--multiple,
body[class*="grp"] .select2-container--admin-autocomplete .select2-search--dropdown .select2-search__field {
    font-family: sans-serif !important;
}

/* <<< Reduce FK autocomplete (select2) width.
Eg, prescription medicines inline, AR invoice medicines inline. */
.crf-mw-50 {
    max-width: 50%;
}

/* CRF Prescription non-pm inline uses `td` while... */
td:has(> div > div > select.crf-mw-50) {
    max-width: 104px;
}

/* ...AR Invoice medicine inline uses `div` */
div:has(> div > div > select.crf-mw-50) {
    max-width: 104px;
}

/* Styles for Bootstrap style message tags */
.grp-messagelist li.grp-alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.grp-messagelist li.grp-alert-error,
.grp-messagelist li.grp-alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.grp-messagelist li.grp-alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa5;
}

.grp-messagelist li.grp-alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* >>> */

/* martor-grappelli-fix.css */

/* Restore proper legend positioning for Grappelli */
div.c-1 legend.inline,
fieldset .form-row legend,
.martor legend {
    display: block !important;
    float: none !important;
    width: auto !important;
    margin: 0 0 6px 0 !important;
    padding: 0 !important;
    font-size: 11px;
    line-height: 1.3;
}

/* Only make required fields bold (exactly like default Grappelli/Django admin) */
div.c-1 legend.inline.required,
fieldset .form-row legend.required,
.martor legend.required,
legend.required {
    font-weight: bold !important;
}

/* Non-required labels remain normal weight */
div.c-1 legend.inline,
fieldset .form-row legend,
.martor legend {
    font-weight: normal !important;
}

/* Martor editor width (50% as you wanted) */
.martor {
    width: 50% !important;
    max-width: 50% !important;
    margin-right: auto;
}

.martor .martor-container,
.martor .CodeMirror {
    width: 100% !important;
}

/* Grappelli layout fixes */
/* div.c-1 {
    width: auto !important;
    float: none !important;
} */

.grp-module .form-row .fieldBox {
    clear: both;
}

/* Hide gutter + line numbers in Ace Editor (Martor) */
.ace_editor .ace_gutter {
    display: none !important;
    width: 0 !important;
    min-width: 0 !important;
}

/* Optional: Remove the vertical separator line as well */
.ace_editor .ace_gutter-cell {
    border-right: none !important;
}

/* Give back some left padding so text doesn't touch the edge */
.ace_editor .ace_scroller {
    left: 4px !important;
    /* or 6px-8px depending on your preference */
}

/* === FIX ORDERED LISTS IN MARTOR LIVE PREVIEW === */
.martor-preview ol,
.martor .martor-preview ol,
.martor-preview ol ol,
.martor-preview ol ul,
.martor-preview ul ol {
    list-style-type: decimal !important;
    list-style-position: outside !important;
    padding-left: 2em !important;
    /* margin-bottom: 1em !important; */
}

/* .martor-preview ol li,
.martor .martor-preview ol li {
    margin-bottom: 0.5em !important;
} */

/* Nested ordered lists */
.martor-preview ol ol {
    list-style-type: lower-alpha !important;
    /* or decimal, lower-roman, etc. */
}

.martor-preview ol ol ol {
    list-style-type: lower-roman !important;
}

/* Unordered lists (for consistency) */
.martor-preview ul,
.martor .martor-preview ul {
    list-style-type: disc !important;
    padding-left: 2em !important;
}

.martor-preview ul ul {
    list-style-type: circle !important;
}

/* Force it inside Grappelli/Django admin containers */
.grp-module .martor-preview ol,
fieldset .martor-preview ol,
.form-row .martor-preview ol,
.c-1 .martor-preview ol {
    list-style-type: decimal !important;
    padding-left: 2em !important;
}

/* Invoice page: visually disable save buttons that JS marks as inactive */
input.grp-button.invoice-btn-disabled {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
    background: #999 !important;
    color: #fff !important;
    box-shadow: none !important;
    pointer-events: none !important;
}

/* === Protocol Email page === */
.pe-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    max-width: 780px;
    margin: 24px 0;
    overflow: hidden;
}

.pe-card-header {
    background: linear-gradient(135deg, #417690 0%, #2c5364 100%);
    color: #fff;
    padding: 20px 28px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.pe-card-header h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #fff;
}

.pe-card-header .pe-patient {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 3px;
}

.pe-patient-emails {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.75);
    margin-top: 4px;
}

.pe-patient-emails.pe-no-email {
    color: rgba(255, 200, 200, 0.9);
}

.pe-card-header svg {
    flex-shrink: 0;
    opacity: 0.9;
}

.pe-card-body {
    padding: 28px;
}

.pe-field {
    margin-bottom: 20px;
}

.pe-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.pe-select {
    width: 100% !important;
    padding: 9px 36px 9px 12px !important;
    border: 1px solid #ccc !important;
    border-radius: 6px !important;
    font-size: 14px !important;
    color: #333 !important;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 12px center !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    cursor: pointer !important;
    box-sizing: border-box !important;
    transition: border-color 0.15s, box-shadow 0.15s;
    height: auto !important;
    line-height: normal !important;
}

.pe-select:focus {
    outline: none;
    border-color: #417690;
    box-shadow: 0 0 0 3px rgba(65, 118, 144, 0.15);
}

.pe-subject {
    padding: 9px 12px;
    background: #f5f7f9;
    border: 1px solid #dde2e7;
    border-radius: 5px;
    font-size: 14px;
    color: #444;
}

.pe-textarea {
    width: 100%;
    min-height: 260px;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.6;
    resize: vertical;
    box-sizing: border-box;
    color: #333;
    transition: border-color 0.15s;
}

.pe-textarea:focus {
    outline: none;
    border-color: #417690;
    box-shadow: 0 0 0 3px rgba(65, 118, 144, 0.15);
}

.pe-divider {
    border: none;
    border-top: 1px solid #eee;
    margin: 24px 0;
}

.pe-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.pe-btn-send {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 28px;
    background: #417690;
    color: #fff;
    border: none;
    border-radius: 5px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s, transform 0.1s;
    letter-spacing: 0.2px;
    width: 177px;
}

.pe-btn-send:hover:not(:disabled) {
    background: #417690;
    color: #fff;
    transform: translateY(-1px);
}

.pe-btn-send:active {
    transform: translateY(0);
}

.pe-btn-send:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.pe-loading {
    display: none;
    font-size: 13px;
    color: #888;
    align-items: center;
    gap: 6px;
}

.pe-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #ccc;
    border-top-color: #417690;
    border-radius: 50%;
    animation: pe-spin 0.7s linear infinite;
}

@keyframes pe-spin {
    to {
        transform: rotate(360deg);
    }
}

.pe-messages {
    margin-bottom: 20px;
}

.pe-msg {
    padding: 10px 14px;
    border-radius: 5px;
    font-size: 13px;
    margin-bottom: 8px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.pe-msg.success {
    background: #eaf5ea;
    border-left: 4px solid #5aad5a;
    color: #2d6a2d;
}

.pe-msg.error {
    background: #fdf0f0;
    border-left: 4px solid #c0392b;
    color: #922b21;
}

.pe-draft-hint {
    font-size: 12px;
    color: #888;
    margin-top: 5px;
}

.pe-attachments-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pe-attachment-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: #f0f4f8;
    border: 1px solid #d0dae4;
    border-radius: 20px;
    font-size: 13px;
    color: #3a5068;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.pe-attachment-item:hover {
    background: #dce8f3;
    border-color: #417690;
}

.pe-attachment-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: inherit;
    text-decoration: none;
}
