/*
 * Folder Monitor modal — the clinic's view of its scanning PC.
 * Base modal chrome comes from site.css (.modal-window-*); this only adds what is specific to it.
 */

.folder-monitor-modal-container {
    width: min(1200px, calc(100vw - 40px));
    height: min(760px, calc(100dvh - 40px));
}

.folder-monitor-modal {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

/* ---------- summary ---------- */

.fmm-summary {
    padding: 12px 16px;
    border-bottom: 1px solid #e3e8e8;
    background: #fafbfb;
}

.fmm-summary-head {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.fmm-details {
    margin-top: 6px;
    font-size: 12px;
    color: #666;
}

/* In the header row it is the content, not a footnote under it — so it takes the space and pushes
   the connection pill and Refresh to the right. */
.fmm-summary-head .fmm-details {
    flex: 1 1 auto;
    margin-top: 0;
}

.fmm-sep {
    margin: 0 8px;
    opacity: .5;
}

.fmm-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.fmm-pill-ok {
    background: #dcfce7;
    color: #166534;
}

/* Offline is a normal state, not a fault — the monitor may simply be a PC that is switched off. */
.fmm-pill-idle {
    background: #eef2f2;
    color: #556;
}

/* The monitor is running but DocDeliver is refusing it — unlike offline, this needs someone to act. */
.fmm-pill-blocked {
    background: #fee2e2;
    color: #991b1b;
}

.fmm-warning {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 6px 12px;
    border-radius: 6px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    font-size: 12px;
}

/* ---------- blocked (IP not accepted) ---------- */

/* Explanation on the left, the files it is holding on the right; stacked on narrow screens. */
.fmm-blocked {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px;
    margin-top: 10px;
    padding: 14px 16px;
    border-radius: 10px;
    background: linear-gradient(180deg, #fff5f5 0%, #fef2f2 100%);
    border: 1px solid #fecaca;
    color: #7f1d1d;
    font-size: 13px;
}

.fmm-blocked-top {
    display: flex;
    gap: 12px;
    min-width: 0;
}

.fmm-blocked-badge {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #fee2e2;
    color: #dc2626;
    font-size: 16px;
}

.fmm-blocked-text {
    min-width: 0;
}

.fmm-blocked-title {
    font-size: 14px;
    font-weight: 700;
    color: #991b1b;
}

.fmm-blocked-desc {
    margin-top: 2px;
    line-height: 1.45;
    color: #7f1d1d;
}

.fmm-blocked-ips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.fmm-ip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 4px 3px 10px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid #fecaca;
}

.fmm-ip-label {
    font-size: 12px;
    font-weight: 600;
    color: #b91c1c;
}

.fmm-ip-value {
    padding: 1px 8px;
    border-radius: 999px;
    background: #fee2e2;
    color: #7f1d1d;
    font-size: 12px;
}

.fmm-ip-allowed {
    border-color: #d1d5db;
}

.fmm-ip-allowed .fmm-ip-label {
    color: #4b5563;
}

.fmm-ip-allowed .fmm-ip-value {
    background: #f3f4f6;
    color: #1f2937;
}

.fmm-ip-arrow {
    color: #f87171;
    font-size: 12px;
}

.fmm-blocked-action {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    font-weight: 600;
    color: #991b1b;
}

.fmm-blocked-section {
    display: flex;
    flex-direction: column;
    min-width: 0;
    border-radius: 8px;
    background: #fff;
    border: 1px solid #fecaca;
    overflow: hidden;
}

.fmm-blocked-section-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid #fee2e2;
    font-size: 13px;
    font-weight: 600;
    color: #991b1b;
}

.fmm-blocked-count {
    padding: 0 8px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 11px;
    line-height: 18px;
}

/* Shrinks on short screens: the summary doesn't, so a tall list would squeeze out the tabs below. */
.fmm-blocked-files {
    max-height: min(168px, 22dvh);
    overflow-y: auto;
    margin: 0;
    padding: 0;
    list-style: none;
}

.fmm-blocked-file {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 12px;
}

.fmm-blocked-file + .fmm-blocked-file {
    border-top: 1px solid #fef2f2;
}

.fmm-blocked-file:hover {
    background: #fffafa;
}

.fmm-blocked-file-icon {
    margin-top: 2px;
    color: #ef4444;
    font-size: 15px;
}

.fmm-blocked-file-body {
    min-width: 0;
}

.fmm-blocked-file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
    color: #1f2937;
}

.fmm-blocked-file-meta {
    margin-top: 1px;
    font-size: 12px;
    color: #6b7280;
}

.fmm-blocked-file-reason {
    margin-top: 2px;
    font-size: 12px;
    color: #b91c1c;
}

.fmm-blocked-empty {
    align-self: center;
    padding: 12px;
    border-radius: 8px;
    background: #fff;
    border: 1px dashed #fecaca;
    color: #7f1d1d;
    text-align: center;
}

@media (max-width: 900px) {
    .fmm-blocked {
        grid-template-columns: minmax(0, 1fr);
    }
}

.fmm-error {
    color: #991b1b;
    font-size: 13px;
}

.fmm-loading {
    color: #666;
    font-size: 13px;
}

.fmm-summary .btn-actions,
.fmm-row-actions .btn-actions {
    font-size: 12px;
    padding: 4px 12px;
}

/* The modal renders outside any page scope that zeroes this, so the button paragraph would
   otherwise keep its default margin and unbalance the button. */
.folder-monitor-modal .btn > p {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

/* ---------- tabs ---------- */

.fmm-tabs {
    display: flex;
    gap: 2px;
    padding: 0 12px;
    border-bottom: 1px solid #e3e8e8;
    background: #fff;
}

.fmm-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    color: #667;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.fmm-tab:hover {
    color: #005f5f;
}

.fmm-tab.active {
    color: #005f5f;
    border-bottom-color: #008080;
}

.fmm-tab-count {
    min-width: 18px;
    padding: 0 6px;
    border-radius: 9px;
    background: #eef2f2;
    color: #556;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
}

/* Unprocessed is the tab with something to act on, so its count is the one thing that shouts. */
.fmm-tab-count.has-items {
    background: #fee2e2;
    color: #991b1b;
}

/* ---------- panels ---------- */

.fmm-panels {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
}

.fmm-panel {
    display: none;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
    padding: 14px 16px;
    overflow-y: auto;
}

.fmm-panel.active {
    display: flex;
}

/* SmartTable measures the box it is given, so its panel must not scroll or pad around it. */
.fmm-panel[data-fmm-panel="processed"] {
    padding: 0;
    overflow: hidden;
}

.fmm-table-mount {
    flex: 1 1 auto;
    min-height: 0;
}

.fmm-blurb {
    margin: 0 0 10px;
    font-size: 13px;
    color: #555;
}

.fmm-empty {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 24px;
    color: #667;
    font-size: 13px;
}

.fmm-note {
    margin-top: 8px;
    font-size: 12px;
    color: #556;
    min-height: 16px;
}

.fmm-note-error {
    color: #991b1b;
}

/* ---------- tables ---------- */

.fmm-table-wrap {
    overflow-x: auto;
    border: 1px solid #e3e8e8;
    border-radius: 6px;
}

.fmm-table {
    width: 100%;
    border-collapse: collapse;
}

.fmm-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f5f7f7;
    padding: 8px 12px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #005f5f;
    border-bottom: 2px solid #e3e8e8;
}

.fmm-table tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid #eef2f2;
    font-size: 13px;
    color: #333;
}

.fmm-table tbody tr:hover {
    background: #f8fafa;
}

.fmm-file {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
}

.fmm-when {
    color: #888;
    white-space: nowrap;
}

/* Under the timestamp rather than beside it: the column is already the widest thing in the row. */
.fmm-ago {
    display: block;
    font-size: 11px;
    opacity: .75;
}

.fmm-row-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

.fmm-row-actions .btn + .btn {
    margin-left: 4px;
}

/* Struck out the moment the monitor confirms the file is gone. The list itself is a snapshot of the
   last report, so it only truly rebuilds on Refresh. */
.fmm-row-removed {
    opacity: .45;
    text-decoration: line-through;
}

.fmm-status {
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 12px;
}

.fmm-status-ok {
    background: #dcfce7;
    color: #166534;
}

.fmm-status-bad {
    background: #fee2e2;
    color: #991b1b;
}

.fmm-blocked-action-hint {
    font-weight: 400;
    font-size: 12px;
    color: #7f1d1d;
}

/* ---------- whitelisted IPs ---------- */

/* The panel is a scrolling flex column; without this the list would shrink instead of the panel scrolling. */
.fmm-ip-list,
.fmm-ip-add,
.fmm-ip-readonly {
    flex: 0 0 auto;
}

.fmm-ip-list {
    margin: 0 0 16px;
    padding: 0;
    list-style: none;
    border: 1px solid #e3e8e8;
    border-radius: 8px;
    overflow: hidden;
}

.fmm-ip-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: #fff;
}

.fmm-ip-row + .fmm-ip-row {
    border-top: 1px solid #eef2f2;
}

.fmm-ip-row-icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e6f4f3;
    color: #0f766e;
    font-size: 13px;
}

.fmm-ip-row-body {
    flex: 1 1 auto;
    min-width: 0;
}

.fmm-ip-row-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
}

.fmm-ip-row-value {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
}

.fmm-ip-row-label {
    color: #4b5563;
}

.fmm-ip-row-meta {
    margin-top: 2px;
    font-size: 12px;
    color: #6b7280;
}

.fmm-ip-tag {
    padding: 0 8px;
    border-radius: 999px;
    background: #dcfce7;
    color: #166534;
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
}

.fmm-ip-tag-muted {
    background: #eef2f2;
    color: #556;
}

.fmm-ip-row .fmm-ip-remove {
    flex: 0 0 auto;
    font-size: 12px;
    padding: 4px 12px;
}

.fmm-ip-add {
    padding: 12px 14px;
    border: 1px solid #e3e8e8;
    border-radius: 8px;
    background: #fafbfb;
}

.fmm-ip-add-title {
    margin-bottom: 8px;
    font-weight: 600;
    color: #1f2937;
}

.fmm-ip-add-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.fmm-input {
    min-width: 0;
    padding: 6px 10px;
    border: 1px solid #cfd8d8;
    border-radius: 6px;
    background: #fff;
    color: #1f2937;
    font: inherit;
    font-size: 13px;
}

.fmm-input:focus {
    outline: none;
    border-color: #0f766e;
    box-shadow: 0 0 0 3px rgba(15, 118, 110, .15);
}

.fmm-ip-add-value {
    flex: 1 1 220px;
}

.fmm-ip-add-label {
    flex: 1 1 200px;
}

.fmm-ip-add-row .btn-actions {
    font-size: 12px;
    padding: 4px 14px;
}

.fmm-ip-suggest {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    font-size: 12px;
    color: #6b7280;
}

.fmm-ip-suggest-btn {
    padding: 2px 10px;
    border: 1px solid #b8dcd9;
    border-radius: 999px;
    background: #fff;
    color: #0f766e;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.fmm-ip-suggest-btn:hover {
    background: #e6f4f3;
}

.fmm-ip-limit {
    margin-top: 8px;
    font-size: 12px;
    color: #9a3412;
}

.fmm-ip-readonly {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 8px;
    background: #f3f4f6;
    color: #4b5563;
    font-size: 12px;
}

/* ---------- import ---------- */

.fmm-unprocessed-head {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    flex: 0 0 auto;
}

.fmm-unprocessed-head .fmm-blurb {
    flex: 1 1 auto;
}

.fmm-unprocessed-head .fmm-import-all {
    flex: 0 0 auto;
    font-size: 12px;
    padding: 4px 14px;
}

.fmm-import-strip {
    flex: 0 0 auto;
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid #b8dcd9;
    background: #f0f9f8;
    color: #134e4a;
    font-size: 13px;
}

.fmm-import-strip-ok {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #166534;
}

.fmm-import-strip-warn {
    border-color: #fed7aa;
    background: #fff7ed;
    color: #9a3412;
}

.fmm-import-strip-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 4px 12px;
    font-weight: 600;
}

.fmm-import-strip-by {
    font-weight: 400;
    font-size: 12px;
    opacity: .8;
}

.fmm-import-bar {
    height: 4px;
    margin-top: 8px;
    border-radius: 999px;
    background: #d5ecea;
    overflow: hidden;
}

.fmm-import-bar span {
    display: block;
    height: 100%;
    background: #0f766e;
    transition: width .3s ease;
}

.fmm-import-problems {
    margin: 8px 0 0;
    padding-left: 18px;
    font-size: 12px;
}

.fmm-import-state {
    display: inline-block;
    margin-left: 6px;
    padding: 0 8px;
    border-radius: 999px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    vertical-align: middle;
    background: #eef2f2;
    color: #556;
}

.fmm-import-importing,
.fmm-import-queued {
    background: #e6f4f3;
    color: #0f766e;
}

.fmm-import-imported {
    background: #dcfce7;
    color: #166534;
}

.fmm-import-skipped {
    background: #fef3c7;
    color: #92400e;
}

.fmm-import-failed {
    background: #fee2e2;
    color: #991b1b;
}
