﻿/*
 * dr-import-modal.css
 * Styles for the POS PDF import modal, post-import form highlights,
 * and the attention banner shown when fields need manual entry.
 *
 * Naming convention: pos-* for modal internals, dr-* for form-level elements.
 * All colours use explicit hex values — no reliance on CSS variables from
 * the parent theme so this file is portable across page contexts.
 */

/* ── Import button (in card header) ──────────────────────────────────────── */
.dr-pos-import-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.85rem;
    font-size: 0.73rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: #1d4ed8;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    white-space: nowrap;
    margin-left: auto;
    margin-right: 0.5rem;
    line-height: 1.4;
}

    .dr-pos-import-btn:hover:not(:disabled) {
        background: #dbeafe;
        border-color: #93c5fd;
        box-shadow: 0 1px 3px rgba(29,78,216,0.1);
    }

    .dr-pos-import-btn:active:not(:disabled) {
        background: #bfdbfe;
    }

    .dr-pos-import-btn:disabled {
        opacity: 0.45;
        cursor: not-allowed;
    }

/* ── Field needs-entry highlight ─────────────────────────────────────────── */
.dr-input--needs-entry {
    border-color: #d97706 !important;
    background-color: #fffbeb !important;
    box-shadow: 0 0 0 3px rgba(217,119,6,0.12) !important;
    transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}

    .dr-input--needs-entry:focus {
        border-color: #b45309 !important;
        box-shadow: 0 0 0 3px rgba(180,83,9,0.18) !important;
        background-color: #fef3c7 !important;
    }

    .dr-input--needs-entry::placeholder {
        color: #b45309;
        opacity: 0.7;
    }

/* ── Attention banner (inside form card, post-import) ────────────────────── */
.pos-attention-banner {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.8rem 1rem;
    margin-bottom: 1.1rem;
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-left: 4px solid #d97706;
    border-radius: 8px;
    font-size: 0.82rem;
    color: #78350f;
    line-height: 1.5;
}

.pos-attention-icon {
    flex-shrink: 0;
    font-size: 1rem;
    margin-top: 0.1rem;
}

.pos-attention-text {
    flex: 1;
}

.pos-attention-dismiss {
    flex-shrink: 0;
    background: none;
    border: 1px solid #fcd34d;
    border-radius: 4px;
    cursor: pointer;
    color: #92400e;
    font-size: 0.72rem;
    padding: 0.15rem 0.4rem;
    opacity: 0.8;
    transition: opacity 0.14s, background 0.14s;
    line-height: 1.4;
    white-space: nowrap;
}

    .pos-attention-dismiss:hover {
        opacity: 1;
        background: #fef3c7;
    }

/* ══════════════════════════════════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Overlay ── */
.pos-modal-overlay {
    position: fixed;
    inset: 0;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(2,6,23,0.5);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1.25rem;
}

    .pos-modal-overlay[hidden] {
        display: none;
    }

/* ── Card ── */
.pos-modal {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 0 0 1px rgba(2,6,23,0.06), 0 4px 6px rgba(2,6,23,0.04), 0 24px 48px rgba(2,6,23,0.16), 0 48px 80px rgba(2,6,23,0.08);
    width: 100%;
    max-width: 720px;
    max-height: 96vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    animation: posModalIn 0.2s cubic-bezier(0.16,1,0.3,1);
}

@keyframes posModalIn {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.975);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.pos-modal::-webkit-scrollbar {
    width: 5px;
}

.pos-modal::-webkit-scrollbar-track {
    background: transparent;
}

.pos-modal::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 99px;
}

/* ── Header ── */
.pos-modal-header {
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
    padding: 1.35rem 1.6rem 1.1rem;
    border-bottom: 1px solid #f1f5f9;
    position: sticky;
    top: 0;
    z-index: 2;
    border-radius: 12px 12px 0 0;
}

.pos-modal-icon {
    font-size: 1.35rem;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 0.15rem;
    opacity: 0.85;
}

.pos-modal-header-text {
    flex: 1;
    min-width: 0;
}

.pos-modal-title {
    font-size: 1.2rem;
    font-weight: 500;
    color: #0f172a;
    line-height: 1.55;
    letter-spacing: -0.01em;
}

.pos-modal-subtitle {
    font-size: 1rem;
    color: #64748b;
    margin-top: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pos-modal-close {
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 1.1rem;
    cursor: pointer;
    color: #94a3b8;
    padding: 0.2rem 0.35rem;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.14s, background 0.14s, border-color 0.14s;
    margin-top: -0.05rem;
}

    .pos-modal-close:hover {
        color: #0f172a;
        background: #f1f5f9;
        border-color: #e2e8f0;
    }

/* ── Body ── */
.pos-modal-body {
    padding: 1.35rem 1.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.95rem;
    flex: 1;
}

/* ── Date / match row ── */
.pos-date-row {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.9rem 1.1rem;
}

.pos-date-cell {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.pos-date-label {
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #777;
}

.pos-date-value {
    font-size: 1rem;
    font-weight: 500;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pos-date-divider {
    font-size: 1.4rem;
    color: #555;
    flex-shrink: 0;
}

.pos-match-badge-wrap {
    flex-shrink: 0;
}

/* ── Match badge ── */
.pos-match-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.9rem;
    font-weight: 450;
    padding: 0.25rem 0.7rem;
    border-radius: 6px;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.pos-match-high {
    background: #f0fdf4;
    color: #555;
    border: 1px solid #bbf7d0;
}

.pos-match-mid {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.pos-match-low {
    background: #fff1f2;
    color: #be123c;
    border: 1px solid #fecdd3;
}

/* ══════════════════════════════════════════════════════════════════════════
   SMART DATE CONTEXT PANEL
   Replaces the old duplicate warning + date mismatch warning.
   Three states: gap-offer, already-filed, off-schedule.
   Each is a self-contained block shown/hidden by JS.
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Shared date context base ── */
.pos-date-context {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

/* ── Gap offer — PDF date is a missing gap, offer to switch ── */
.pos-date-context--gap {
    border-color: #6366f1;
    background: #eef2ff;
}

    .pos-date-context--gap .pos-dc-header {
        background: #eef2ff;
        border-bottom: 1px solid #c7d2fe;
        padding: 0.75rem 1rem;
        display: flex;
        align-items: center;
        gap: 0.55rem;
    }

    .pos-date-context--gap .pos-dc-icon {
        font-size: 1rem;
        flex-shrink: 0;
    }

    .pos-date-context--gap .pos-dc-message {
        flex: 1;
        font-size: 0.84rem;
        font-weight: 500;
        color: #3730a3;
        line-height: 1.4;
    }

    .pos-date-context--gap .pos-dc-action {
        flex-shrink: 0;
        display: inline-flex;
        align-items: center;
        gap: 0.3rem;
        padding: 0.3rem 0.75rem;
        font-size: 0.8rem;
        font-weight: 600;
        color: #fff;
        background: #4f46e5;
        border: none;
        border-radius: 6px;
        cursor: pointer;
        transition: background 0.15s;
        font-family: inherit;
        white-space: nowrap;
    }

        .pos-date-context--gap .pos-dc-action:hover {
            background: #4338ca;
        }

/* ── Already filed — PDF date has an existing report ── */
.pos-date-context--filed {
    border-color: #fecdd3;
    background: #fff1f2;
}

    .pos-date-context--filed .pos-dc-header {
        background: #fff1f2;
        padding: 0.75rem 1rem;
        display: flex;
        align-items: flex-start;
        gap: 0.55rem;
    }

    .pos-date-context--filed .pos-dc-icon {
        font-size: 1rem;
        flex-shrink: 0;
        margin-top: 0.1rem;
    }

    .pos-date-context--filed .pos-dc-message {
        flex: 1;
        font-size: 0.84rem;
        color: #881337;
        line-height: 1.5;
    }

        .pos-date-context--filed .pos-dc-message strong {
            display: block;
            font-weight: 600;
            margin-bottom: 0.2rem;
            color: #9f1239;
        }

/* ── Off schedule — PDF date not expected for this account ── */
.pos-date-context--offschedule {
    border-color: #fcd34d;
    background: #fffbeb;
}

    .pos-date-context--offschedule .pos-dc-header {
        background: #fffbeb;
        padding: 0.75rem 1rem;
        display: flex;
        align-items: flex-start;
        gap: 0.55rem;
    }

    .pos-date-context--offschedule .pos-dc-icon {
        font-size: 1rem;
        flex-shrink: 0;
        margin-top: 0.05rem;
    }

    .pos-date-context--offschedule .pos-dc-message {
        flex: 1;
        font-size: 0.84rem;
        color: #78350f;
        line-height: 1.5;
    }

/* ── Date mismatch note (shown below context panel when dates differ but no action needed) ── */
.pos-date-note {
    font-size: 0.8rem;
    color: #64748b;
    padding: 0.5rem 0.75rem;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    line-height: 1.45;
}

/* ── Section label (above matched grid) ── */
.pos-section-label {
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #777;
    padding-bottom: 0.1rem;
    border-bottom: 1px solid #f1f5f9;
}

/* ── Matched values — outer container ── */
.pos-values-grid {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0 1rem;
}

/* ── Group label ── */
.pos-group-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: #777;
    margin-top: 0.9rem;
    margin-bottom: 0.3rem;
    padding-left: 0.1rem;
}

    .pos-group-label:first-child {
        margin-top: 0;
    }

/* ── Group inner grid ── */
.pos-group-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0 1.75rem;
}

/* ── Individual field row ── */
.pos-value-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.3rem 0;
    border-bottom: 1px solid #eee;
    font-size: 1rem;
    color: #444;
}

    .pos-value-item:last-child {
        border-bottom: none;
    }

.pos-value-label {
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1;
}

.pos-value-num {
    font-weight: 550;
    color: #444;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 1rem;
}

/* ── Missing fields section ── */
.pos-missing-block {
    background: #fafafa;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.pos-missing-header {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.7rem 1rem;
    background: #fffbeb;
    border-bottom: 1px solid #fcd34d;
}

.pos-missing-icon {
    font-size: 0.9rem;
    flex-shrink: 0;
}

.pos-missing-title {
    font-size: 0.81rem;
    font-weight: 600;
    color: #78350f;
    line-height: 1.3;
}

.pos-missing-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.75rem 1rem;
}

.pos-missing-chip {
    font-size: 0.75rem;
    font-weight: 600;
    color: #92400e;
    background: #fff;
    border: 1px solid #fcd34d;
    border-radius: 5px;
    padding: 0.2rem 0.65rem;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

/* ── Learning engine note ── */
.pos-learning-note {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.8rem 1rem;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    font-size: 0.79rem;
    color: #166534;
    line-height: 1.55;
}

.pos-learning-icon {
    font-size: 0.95rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

/* ── Footer ── */
.pos-modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.65rem;
    padding: 1rem 1.6rem;
    border-top: 1px solid #f1f5f9;
    background: #fafafa;
    position: sticky;
    bottom: 0;
    z-index: 2;
    border-radius: 0 0 12px 12px;
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .pos-modal {
        max-width: 100%;
        max-height: 94vh;
        border-radius: 12px 12px 0 0;
    }

    .pos-modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .pos-modal-header {
        border-radius: 12px 12px 0 0;
        padding: 1.1rem 1.2rem 0.9rem;
    }

    .pos-modal-body {
        padding: 1.1rem 1.2rem;
    }

    .pos-modal-footer {
        padding: 0.9rem 1.2rem;
        border-radius: 0;
    }

    .pos-group-grid {
        grid-template-columns: 1fr;
    }

    .pos-date-row {
        flex-wrap: wrap;
        gap: 0.6rem;
    }

    .pos-match-badge-wrap {
        width: 100%;
    }

    .pos-match-badge {
        width: 100%;
        justify-content: center;
    }

    .pos-date-context--gap .pos-dc-header {
        flex-wrap: wrap;
    }

    .pos-date-context--gap .pos-dc-action {
        width: 100%;
        justify-content: center;
    }
}

/* ── Gap chip — claimed by posImport (date is now selected for import) ── */
/* Applied by syncGapChipSelection() in pos-import.js alongside             */
/* dr-gap-chip-selected. Visually signals the date is no longer missing.   */
.dr-gap-chip.dr-gap-chip-claimed {
    opacity: 0.5;
    text-decoration: line-through;
    cursor: default;
    pointer-events: none;
}
