/* ============================================
   MODALS
   ============================================ */

/* ─── MODAL ─────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; opacity: 0; pointer-events: none;
    transition: opacity 0.25s ease;
    backdrop-filter: blur(4px);
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal {
    background: var(--bg-1); border: 1px solid var(--border);
    border-radius: 16px; padding: 0 32px;   /* no top/bottom padding: see note below */
    width: 480px; max-width: 95vw; max-height: 85vh; overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0,0,0,0.5);
    transform: scale(0.95); transition: transform 0.25s ease;
}
.modal-overlay.active .modal { transform: scale(1); }

/* Sticky header — title stays visible while the form scrolls */
.modal h2 {
    font-family: var(--font-mono); font-size: 18px; font-weight: 700;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 3;
    margin: 0 -32px 20px; padding: 24px 32px 14px;
    background: var(--bg-1);
    border-bottom: 1px solid var(--border);
}
.modal h2 .close-btn {
    width: 30px; height: 30px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--bg-2);
    color: var(--text-2); cursor: pointer; font-size: 18px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.modal h2 .close-btn:hover { background: var(--bg-3); color: var(--text-0); }
.modal .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
/* Let fields shrink to their column — date/time pickers otherwise push past the edge on phones */
.modal .form-row > *, .modal .form-cols > * { min-width: 0; }
.modal input, .modal select, .modal textarea { max-width: 100%; min-width: 0; }
.modal textarea.autogrow { resize: vertical; min-height: 0; line-height: 1.45; }

/* Why the modal has no top/bottom padding (v3.18.1): browsers pin a sticky
   header/footer inside the scroll box's *padding*, so with 32px of padding the
   title slid 32px down and Save/Cancel 32px up, covering the first and last
   lines of every short form. The space now comes from the header/footer
   themselves, or from these margins when a modal has no header or footer. */
.modal > :first-child:not(h2) { margin-top: 32px; }
.modal > :last-child:not(.form-actions) { margin-bottom: 32px; }
.modal > input[type=hidden]:last-child { margin: 0; }

/* Sticky footer — Save/Cancel always reachable */
.modal .form-actions {
    display: flex; gap: 10px; justify-content: flex-end; align-items: center;
    position: sticky; bottom: 0; z-index: 3;
    margin: 24px -32px 0; padding: 16px 32px 20px;
    background: var(--bg-1);
    border-top: 1px solid var(--border);
}

/* ─── WIDE FORM MODALS (desktop) ────────────────────
   Data-entry forms get a wide centered modal with the
   fields laid out in two columns, so everything is
   visible at once instead of one long scroll.          */
.form-cols { display: grid; grid-template-columns: 1fr; gap: 0 28px; }
.form-section-title {
    font-size: 11px; font-weight: 700; letter-spacing: 1px;
    text-transform: uppercase; color: var(--text-2);
    padding-bottom: 8px; margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

@media (min-width: 1000px) {
    #modal-overlay .modal { width: 900px; }
    #quote-modal-overlay .modal,
    #wo-modal-overlay .modal { width: 1080px; }
    #cust-modal-overlay .modal { width: 760px; }

    #modal-overlay .form-cols,
    #quote-modal-overlay .form-cols,
    #wo-modal-overlay .form-cols,
    #cust-modal-overlay .form-cols {
        grid-template-columns: 1fr 1fr;
    }
    /* Line-item columns get a bit more room on the left */
    #quote-modal-overlay .form-cols-lines,
    #wo-modal-overlay .form-cols-lines {
        grid-template-columns: 1fr 1.15fr;
        gap: 0 24px;
    }
    .modal { max-height: 90vh; }
}

/* Very wide screens — give the quote form even more room */
@media (min-width: 1500px) {
    #quote-modal-overlay .modal,
    #wo-modal-overlay .modal { width: 1240px; }
}

/* ─── MOBILE: bottom sheet ──────────────────────── */
@media (max-width: 899px) {
    .modal-overlay { align-items: flex-end; }
    .modal {
        width: 100% !important; max-width: 100%;
        max-height: 92vh; padding: 0 24px;
        border-radius: 16px 16px 0 0;
        border-left: none; border-right: none; border-bottom: none;
        transform: translateY(100%); transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    }
    .modal-overlay.active .modal { transform: translateY(0); }
    .modal h2 { margin: 0 -24px 18px; padding: 20px 24px 12px; }
    .modal .form-actions { margin: 20px -24px 0; padding: 14px 24px 18px; }
    .modal > :first-child:not(h2) { margin-top: 24px; }
    .modal > :last-child:not(.form-actions) { margin-bottom: 24px; }
    /* Grab handle */
    .modal h2::before {
        content: ''; position: absolute; top: 8px; left: 50%;
        transform: translateX(-50%);
        width: 36px; height: 4px; border-radius: 2px;
        background: var(--border-light);
    }
}

/* ─── REMINDER POPUP ───────────────────────────── */
.reminder-popup-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.65);
    display: flex; align-items: center; justify-content: center;
    z-index: 1500; backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.reminder-popup {
    background: var(--bg-1); border: 1px solid var(--border);
    border-radius: 16px; padding: 32px;
    width: 520px; max-height: 80vh; overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0,0,0,0.5);
    animation: fadeUp 0.4s ease;
}
.reminder-popup h2 {
    font-family: var(--font-mono); font-size: 18px; font-weight: 700;
    margin-bottom: 20px; display: flex; align-items: center; gap: 10px;
}
.rp-section { margin-bottom: 20px; }
.rp-section-title {
    font-size: 12px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 1px; padding: 6px 12px; border-radius: var(--radius-sm);
    margin-bottom: 10px; display: inline-block;
}
.rp-today-title { background: var(--red-dim); color: var(--red); }
.rp-tomorrow-title { background: var(--yellow-dim); color: var(--yellow); }
.rp-week-title { background: var(--accent-glow); color: var(--accent); }
.rp-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px; background: var(--bg-2); border-radius: var(--radius-sm);
    margin-bottom: 6px; border-left: 3px solid var(--accent);
}
.rp-item-left { display: flex; flex-direction: column; gap: 2px; }
.rp-item-name { font-weight: 600; font-size: 14px; }
.rp-item-detail { font-size: 12px; color: var(--text-2); }
.rp-item-right { text-align: right; }
.rp-item-time { font-family: var(--font-mono); font-size: 13px; color: var(--text-1); }
.rp-item-date { font-size: 11px; color: var(--text-2); }
.rp-close {
    display: flex; justify-content: center; margin-top: 8px;
}

