/* Fortress AMS — Import & Map wizard (Slice 2). Self-contained overlay
   styling; confidence colors match the agreed flagging model:
   exact = green, approx = amber, unmapped = red. */

.imw-overlay {
    position: fixed;
    inset: 0;
    z-index: 4000;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
}

.imw-modal {
    background: #fff;
    border-radius: 10px;
    width: min(1180px, 94vw);
    height: min(780px, 92vh);
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    font-size: 13px;
    color: #1e293b;
    /* User-resizable via the native bottom-right handle (works with
       overflow: hidden); floors keep the footer buttons reachable. */
    resize: both;
    min-width: 720px;
    min-height: 480px;
    max-width: 98vw;
    max-height: 96vh;
}

.imw-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}
.imw-header h2 { margin: 0; font-size: 16px; flex: 0 0 auto; }

.imw-steps { display: flex; gap: 6px; flex: 1; }
.imw-step {
    padding: 4px 10px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #64748b;
    font-size: 11.5px;
    white-space: nowrap;
}
.imw-step.active { background: #1d4ed8; color: #fff; }
.imw-step.done { background: #bbf7d0; color: #166534; }

.imw-close {
    border: none; background: none; font-size: 20px; line-height: 1;
    cursor: pointer; color: #64748b; padding: 4px 8px;
}
.imw-close:hover { color: #0f172a; }

.imw-body { flex: 1; overflow: auto; padding: 16px 18px; }
.imw-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}
.imw-footer .imw-status { flex: 1; color: #475569; }

.imw-btn {
    padding: 7px 16px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: #fff;
    /* Explicit text color: the app's global `button { color: white }`
       (overlays-controls.css) otherwise renders these white-on-white —
       user hit unreadable Back/Earlier/Later buttons in preview testing. */
    color: #334155;
    cursor: pointer;
    font-size: 13px;
}
.imw-btn:hover { background: #f1f5f9; }
.imw-btn.primary { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.imw-btn.primary:hover { background: #1e40af; }
.imw-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---- Step 1: upload ---- */
.imw-drop {
    border: 2px dashed #94a3b8;
    border-radius: 10px;
    padding: 42px 20px;
    text-align: center;
    color: #475569;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.imw-drop:hover, .imw-drop.dragover { border-color: #1d4ed8; background: #eff6ff; }
.imw-drop input { display: none; }
.imw-drop .imw-drop-title { font-size: 15px; font-weight: 600; color: #1e293b; }

.imw-source-row { display: flex; gap: 14px; margin: 14px 0; align-items: center; flex-wrap: wrap; }
.imw-source-row label { font-weight: 600; color: #334155; }
.imw-source-row select { padding: 5px 8px; border: 1px solid #cbd5e1; border-radius: 6px; }
.imw-file-chip {
    background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8;
    border-radius: 999px; padding: 3px 12px; font-weight: 600;
}

/* Raw grid preview */
.imw-grid-wrap { overflow: auto; max-height: 380px; border: 1px solid #e2e8f0; border-radius: 8px; }
.imw-grid { border-collapse: collapse; width: max-content; min-width: 100%; }
.imw-grid td, .imw-grid th {
    border: 1px solid #eef2f7; padding: 3px 8px; font-size: 12px;
    max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.imw-grid tr.imw-header-row td { background: #dbeafe; font-weight: 600; }
.imw-grid td.imw-rownum { background: #f8fafc; color: #94a3b8; cursor: pointer; }
.imw-grid td.imw-rownum:hover { background: #e0e7ff; color: #3730a3; }

/* ---- Step 2: mapping ---- */
/* flex-basis 0 + min-width 0: the two panels split the AVAILABLE width
   instead of growing to their widest cell — one long header/sample on a
   sheet must never stretch the whole step sideways (user report, PR #41:
   second workbook tab pushed the layout into a horizontal scroll).
   The headers panel carries a native drag handle (resize: horizontal)
   so the split is user-adjustable. */
.imw-map-layout { display: flex; gap: 16px; align-items: flex-start; min-width: 0; }
.imw-map-headers {
    flex: 1.2 1 0; min-width: 260px; max-width: 75%;
    resize: horizontal; overflow: auto; padding-right: 6px;
}
.imw-map-fields { flex: 1 1 0; min-width: 240px; position: sticky; top: 0; }

.imw-header-chip {
    display: flex; align-items: center; gap: 8px;
    border: 1px solid #e2e8f0; border-radius: 8px;
    padding: 6px 10px; margin-bottom: 6px; background: #fff; cursor: pointer;
    min-width: 0;
}
.imw-header-chip:hover { border-color: #94a3b8; }
.imw-header-chip.selected { border-color: #1d4ed8; box-shadow: 0 0 0 2px #bfdbfe; }
.imw-header-chip .imw-h-name { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.imw-header-chip .imw-h-sample { color: #94a3b8; font-size: 11px; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imw-header-chip .imw-h-field {
    background: #dcfce7; color: #166534; border-radius: 999px;
    padding: 2px 9px; font-size: 11px; white-space: nowrap;
}
.imw-header-chip .imw-h-field.suggested { background: #fef9c3; color: #854d0e; }
.imw-header-chip .imw-h-unmap { border: none; background: none; color: #94a3b8; cursor: pointer; }

.imw-field-group { margin-bottom: 10px; }
.imw-field-group h4 { margin: 0 0 5px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: #64748b; }
.imw-field-pill {
    display: inline-block; margin: 0 5px 5px 0; padding: 4px 11px;
    border: 1px solid #cbd5e1; border-radius: 999px; cursor: pointer;
    background: #fff; font-size: 12px;
}
.imw-field-pill:hover { border-color: #1d4ed8; color: #1d4ed8; }
.imw-field-pill.assigned { background: #dcfce7; border-color: #86efac; color: #166534; }
.imw-field-pill.disabled { opacity: 0.4; pointer-events: none; }

/* ---- Step 3: resolve & preview ---- */
.imw-progress { height: 8px; border-radius: 999px; background: #e2e8f0; overflow: hidden; margin: 8px 0 14px; }
.imw-progress > div { height: 100%; background: #1d4ed8; width: 0; transition: width 0.2s; }

.imw-summary { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.imw-sum-pill { border-radius: 8px; padding: 8px 14px; font-weight: 700; font-size: 14px; }
.imw-sum-pill span { display: block; font-weight: 400; font-size: 11px; }
.imw-sum-exact { background: #dcfce7; color: #166534; }
.imw-sum-approx { background: #fef3c7; color: #92400e; }
.imw-sum-unmapped { background: #fee2e2; color: #991b1b; }

.imw-results-wrap { overflow: auto; max-height: 420px; border: 1px solid #e2e8f0; border-radius: 8px; }
.imw-results { border-collapse: collapse; width: 100%; }
.imw-results th {
    position: sticky; top: 0; background: #f8fafc; text-align: left;
    padding: 6px 8px; font-size: 11px; text-transform: uppercase; color: #64748b;
    border-bottom: 1px solid #e2e8f0;
}
.imw-results td { padding: 5px 8px; border-bottom: 1px solid #f1f5f9; font-size: 12px; }
.imw-results tr:hover td { background: #f8fafc; }

.imw-pill { border-radius: 999px; padding: 2px 10px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.imw-pill.exact { background: #dcfce7; color: #166534; }
.imw-pill.approx { background: #fef3c7; color: #92400e; }
.imw-pill.unmapped { background: #fee2e2; color: #991b1b; }

.imw-notes { color: #64748b; font-size: 11px; max-width: 380px; }

.imw-filter-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.imw-filter-row .imw-chip-toggle {
    border: 1px solid #cbd5e1; border-radius: 999px; padding: 3px 11px;
    cursor: pointer; background: #fff; font-size: 12px;
    color: #475569;   /* global button rule would make the off state white-on-white */
}
.imw-filter-row .imw-chip-toggle.on { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }

/* Preview window navigation (header rows beyond the first 30) */
.imw-preview-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
}

.imw-default-state {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding: 8px 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}
.imw-default-state input {
    width: 70px;
    margin-left: 6px;
    padding: 3px 6px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    text-transform: uppercase;
}

/* ---- Slice 3: destination + import steps ---- */
.imw-dest { display: flex; flex-direction: column; gap: 10px; max-width: 720px; }
.imw-dest-option {
    display: flex; gap: 12px; align-items: flex-start;
    border: 1px solid #cbd5e1; border-radius: 8px; padding: 12px 14px;
    cursor: pointer; background: #fff;
}
.imw-dest-option.selected { border-color: #2563eb; box-shadow: 0 0 0 1px #2563eb inset; background: #f8fafc; }
.imw-dest-option.disabled { opacity: 0.55; cursor: not-allowed; }
.imw-dest-option input[type="radio"] { margin-top: 3px; }
.imw-dest-title { font-weight: 600; color: #0f172a; }
.imw-dest-hint { color: #64748b; font-size: 12px; margin-top: 2px; }
.imw-group-list {
    margin-top: 8px; max-height: 180px; overflow: auto;
    border: 1px solid #e2e8f0; border-radius: 6px; background: #fff;
}
.imw-group-row {
    display: flex; justify-content: space-between; gap: 12px;
    padding: 4px 10px; border-bottom: 1px solid #f1f5f9; font-size: 12px; color: #334155;
}
.imw-group-row:last-child { border-bottom: none; }
.imw-dest-form { display: flex; flex-direction: column; gap: 8px; padding: 6px 2px 0; }
.imw-dest-form label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: #475569; max-width: 420px; }
.imw-dest-form input[type="text"], .imw-dest-form input:not([type]), .imw-dest-form select {
    padding: 6px 8px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 13px; color: #0f172a; background: #fff;
}
.imw-merge-toggle { flex-direction: row !important; align-items: center; gap: 8px !important; color: #334155 !important; }
.imw-outcome { max-width: 760px; color: #0f172a; }
.imw-outcome h3 { margin: 0 0 10px; }
.imw-plan-list { margin: 6px 0; padding-left: 20px; color: #334155; font-size: 13px; }
.imw-import-error { color: #b91c1c; font-weight: 600; }
