/* ═══════════════════════════════════════════════════════════
   DayReady — Reusable detail modal.

   Used by every "View" button in the app: teacher absences,
   admin absences, admin approvals, admin/sub job postings, etc.
   The modal is auto-injected into <body> by dr-detail-modal.js
   on first use; pages just call DRDetailModal.open(url, title).

   Centered card on desktop. Bottom sheet on phones (slides up
   from the bottom edge, rounded top corners, safe-area inset).
   ═══════════════════════════════════════════════════════════ */

.dr-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.2s ease;
}
.dr-modal-overlay.is-open {
    display: flex;
    opacity: 1;
}

.dr-modal-card {
    background: #fff;
    border-radius: 16px;
    width: 92%;
    max-width: 880px;
    max-height: 90vh;
    max-height: 90dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow:
        0 30px 80px rgba(15, 23, 42, 0.45),
        0 4px 12px rgba(15, 23, 42, 0.12);
    animation: drModalIn 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes drModalIn {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.dr-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
    background: linear-gradient(135deg, var(--primary-bg) 0%, #fff 100%);
    flex-shrink: 0;
}
.dr-modal-head h3 {
    margin: 0;
    font-size: 1.0625rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-dark);
    min-width: 0;
}
.dr-modal-head h3 i {
    color: var(--primary);
    font-size: 1.25rem;
}
.dr-modal-head .dr-modal-title-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dr-modal-close {
    width: 36px;
    height: 36px;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    border-radius: 8px;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}
@media (hover: hover) {

.dr-modal-close:hover,
.dr-modal-close:focus-visible {
    background: var(--bg-subtle);
    color: var(--text-dark);
    outline: none;
}
}

.dr-modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-height: 0;
    scroll-behavior: smooth;
    /* Custom scrollbar — slim and unobtrusive on long modals. */
    scrollbar-width: thin;
    scrollbar-color: rgba(91, 79, 199, 0.25) transparent;
}
.dr-modal-body::-webkit-scrollbar { width: 8px; }
.dr-modal-body::-webkit-scrollbar-thumb {
    background: rgba(91, 79, 199, 0.22);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
@media (hover: hover) {

.dr-modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(91, 79, 199, 0.40);
    background-clip: padding-box;
    border: 2px solid transparent;
}
}
.dr-modal-body::-webkit-scrollbar-track { background: transparent; }

/* Fade gradients at the top + bottom of the scroll body so the user
   knows there's more content above/below. The gradients are sticky
   pseudo-elements painted into the scroll container. */
.dr-modal-card {
    position: relative;
}
.dr-modal-card::after,
.dr-modal-card::before {
    content: '';
    position: absolute;
    left: 0; right: 12px;   /* leave room for the scrollbar */
    height: 18px;
    pointer-events: none;
    z-index: 2;
    transition: opacity 0.15s;
}
.dr-modal-card::before {
    top: 60px;              /* sits just under the .dr-modal-head */
    background: linear-gradient(to bottom, #fff 0%, rgba(255,255,255,0) 100%);
    opacity: 0;             /* JS toggles this when scrollTop > 0 */
}
.dr-modal-card.is-scrolled::before { opacity: 1; }
.dr-modal-card::after {
    bottom: 0;
    background: linear-gradient(to top, #fff 0%, rgba(255,255,255,0) 100%);
    opacity: 1;
}
.dr-modal-card.is-scrolled-end::after { opacity: 0; }
.dr-modal-loading {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.dr-modal-loading i {
    font-size: 1.5rem;
    margin-right: 0.5rem;
}
.dr-modal-error {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--danger);
}
.dr-modal-error i {
    font-size: 1.5rem;
    margin-right: 0.5rem;
}

/* Phone: dock as iOS-native bottom sheet for thumb reach. */
@media (max-width: 768px) {
    .dr-modal-overlay { align-items: flex-end; }
    .dr-modal-card {
        width: 100%;
        max-width: none;
        max-height: 92dvh;
        border-radius: 18px 18px 0 0;
        animation: drModalSlideUp 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .dr-modal-close { width: 44px; height: 44px; }
    .dr-modal-body {
        padding: 1rem;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }
}
@keyframes drModalSlideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}
