/* SMP shared folder browser — structural styles (Library, Doctor HSMS, Field Drive) */

.smp-fb {
    outline: none;
}

.smp-fb-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    margin-bottom: 0.35rem;
}

.smp-fb-crumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    font-size: var(--smp-text-sm);
    min-width: 0;
}

.smp-fb-bc-link {
    color: var(--smp-color-brand, #2563eb);
    text-decoration: none;
    font-weight: var(--smp-font-weight-semibold, 600);
}

.smp-fb-bc-link:hover {
    text-decoration: underline;
    color: var(--smp-color-brand-hover, #1d4ed8);
}

.smp-fb-bc-sep {
    color: var(--smp-color-text-muted);
}

.smp-fb-bc-current {
    font-weight: var(--smp-font-weight-bold, 700);
    color: var(--smp-color-text);
}

.smp-fb-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.smp-fb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    font-size: var(--smp-text-sm);
    font-weight: var(--smp-font-weight-semibold, 600);
    line-height: 1.25;
    color: var(--smp-color-text);
    background: var(--smp-surface-raised, #fff);
    border: 1px solid var(--smp-border-default, rgba(0, 0, 0, 0.12));
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
}

.smp-fb-btn:hover:not(:disabled) {
    background: var(--smp-surface-hover, rgba(0, 0, 0, 0.04));
}

.smp-fb-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.smp-fb-btn--primary {
    color: #fff;
    background: var(--smp-color-brand, #2563eb);
    border-color: var(--smp-color-brand, #2563eb);
}

.smp-fb-btn--primary:hover:not(:disabled) {
    background: var(--smp-color-brand-hover, #1d4ed8);
    border-color: var(--smp-color-brand-hover, #1d4ed8);
}

.smp-fb-btn--ghost {
    background: transparent;
}

.smp-fb-status {
    min-height: 1.25rem;
    margin: 0 0 0.35rem;
    font-size: var(--smp-text-sm);
    color: var(--smp-color-text-muted);
}

.smp-fb-status.is-error {
    color: var(--smp-status-danger, #b91c1c);
}

.smp-fb-board {
    overflow: auto;
}

.smp-fb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--smp-text-sm);
}

.smp-fb-table th,
.smp-fb-table td {
    padding: 0.45rem 0.4rem;
    border-bottom: 1px solid var(--smp-border-default, rgba(0, 0, 0, 0.08));
    text-align: left;
    vertical-align: middle;
}

.smp-fb-table th {
    font-size: var(--smp-text-xs);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--smp-color-text-muted);
    font-weight: var(--smp-font-weight-semibold, 600);
}

.smp-fb-col-check {
    width: 2rem;
    text-align: center;
}

.smp-fb-name {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--smp-color-text);
    font: inherit;
    font-weight: var(--smp-font-weight-semibold, 600);
    text-align: left;
    max-width: 100%;
}

.smp-fb-name span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.smp-fb-col-actions {
    white-space: nowrap;
    text-align: right;
    width: 2.5rem;
}

.smp-fb-menu-wrap {
    position: relative;
    display: inline-flex;
    justify-content: flex-end;
}

.smp-fb-kebab {
    width: 32px;
    height: 32px;
    padding: 0;
    line-height: 1;
    color: var(--smp-color-text-muted);
    background: transparent;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0.35;
    transition: opacity 0.12s;
}

.smp-fb-row:hover .smp-fb-kebab,
.smp-fb-row:focus-within .smp-fb-kebab,
.smp-fb-kebab:focus {
    opacity: 1;
}

.smp-fb-kebab:hover {
    background: var(--smp-surface-hover, rgba(0, 0, 0, 0.06));
    color: var(--smp-color-text);
}

.smp-fb-kebab svg {
    display: block;
    width: 18px;
    height: 18px;
    margin: 0 auto;
}

/* Mount point only — do not cover the viewport (that blocked outside-click dismiss). */
#smp-fb-menu-portal {
    position: absolute;
    width: 0;
    height: 0;
    overflow: visible;
    z-index: var(--smp-z-app-overlay, 10050);
    pointer-events: none;
}

#smp-fb-menu-portal .smp-fb-menu {
    pointer-events: auto;
}

.smp-fb-menu {
    display: none;
    min-width: 15.5rem;
    padding: 8px 0;
    margin: 0;
    background: var(--smp-surface-raised, #fff);
    border: 1px solid var(--smp-border-default, #dee2e6);
    border-radius: 12px;
    box-shadow: 0 14px 36px color-mix(in srgb, var(--smp-color-text) 18%, transparent);
    overflow: visible;
    outline: none;
}

.smp-fb-menu.show {
    display: block !important;
}

.smp-fb-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    font-size: 0.84rem;
    padding: 10px 14px;
    color: var(--smp-color-text);
    cursor: pointer;
    white-space: nowrap;
}

.smp-fb-menu-item:hover:not(:disabled) {
    background: color-mix(in srgb, var(--smp-color-brand, #0d6efd) 12%, transparent);
}

.smp-fb-menu-item:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.smp-fb-menu-item--danger {
    color: var(--smp-status-danger, #dc3545);
}

.smp-fb-menu-item--danger:hover:not(:disabled) {
    background: color-mix(in srgb, var(--smp-status-danger, #dc3545) 12%, transparent);
}

.smp-fb-menu-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--smp-color-text-muted);
}

.smp-fb-menu-icon svg {
    display: block;
    width: 18px;
    height: 18px;
}

.smp-fb-menu-label {
    flex: 1;
    min-width: 0;
}

.smp-fb-menu-sep {
    height: 1px;
    background: var(--smp-border-default, rgba(0, 0, 0, 0.1));
    margin: 6px 0;
}

.smp-fb-row.is-drop-target {
    background: color-mix(in srgb, var(--smp-color-brand, #2563eb) 8%, transparent);
    outline: 1px dashed var(--smp-color-brand, #2563eb);
}

.smp-fb-row.is-cut {
    opacity: 0.45;
}

.smp-fb-row.is-cut .smp-fb-name span {
    text-decoration: line-through;
}

.smp-fb-empty-row td {
    color: var(--smp-color-text-muted);
    padding: 1rem 0.4rem;
}

.smp-fb-summary {
    margin-bottom: 0.5rem;
    font-size: var(--smp-text-sm);
    color: var(--smp-color-text-muted);
}

.smp-fb-summary strong {
    display: block;
    color: var(--smp-color-text);
    margin-bottom: 0.15rem;
}

/*
 * Dir/file tree foundation — Records look:
 * bordered shell, stacked folder rows, chevron, indent.
 */
.smp-fb-tree {
    margin: 0 0 1rem;
    padding: 0;
    border: 1px solid var(--smp-border-default, #e2e8f0);
    border-radius: 8px;
    background: var(--smp-surface-raised, #fff);
    font-family: inherit;
    font-size: var(--smp-text-sm);
    color: var(--smp-color-text);
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    --smp-fb-tree-indent: 1.35rem;
}

.smp-fb-tree-folder {
    margin: 0;
    border-bottom: 1px solid var(--smp-border-default, #e2e8f0);
}

.smp-fb-tree-folder:last-child {
    border-bottom: none;
}

.smp-fb-tree-folder > summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.55rem 0.75rem;
    padding-left: calc(
        0.75rem + var(--smp-fb-tree-depth, 0) * var(--smp-fb-tree-indent, 1.35rem)
    );
    font-weight: 600;
    font-size: var(--smp-text-sm);
    color: var(--smp-color-text, #0f172a);
    background: var(--smp-surface-muted, #f8fafc);
    user-select: none;
}

.smp-fb-tree-folder > summary::-webkit-details-marker {
    display: none;
}

.smp-fb-tree-folder > summary::before {
    content: "";
    flex: 0 0 auto;
    width: 0.4rem;
    height: 0.4rem;
    border-right: 2px solid var(--smp-color-text-muted, #64748b);
    border-bottom: 2px solid var(--smp-color-text-muted, #64748b);
    transform: rotate(-45deg);
    margin-right: 0.15rem;
    transition: transform 0.15s ease;
}

.smp-fb-tree-folder[open] > summary::before {
    transform: rotate(45deg);
}

.smp-fb-tree-folder > summary:hover {
    background: color-mix(
        in srgb,
        var(--smp-color-brand, #0d9488) 8%,
        var(--smp-surface-muted, #f8fafc)
    );
}

.smp-fb-tree-folder .smp-fb-tree-folder > summary {
    background: var(--smp-surface-raised, #fff);
}

.smp-fb-tree-folder-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    line-height: 1;
    color: #ca8a04;
}

.smp-fb-tree-folder-icon img,
.smp-fb-tree-folder-icon svg {
    display: block;
    width: 1rem;
    height: 1rem;
    object-fit: contain;
}

.smp-fb-tree-folder--root > summary {
    font-weight: 700;
    font-size: var(--smp-text-base);
    background: color-mix(
        in srgb,
        var(--smp-color-brand, #0d9488) 10%,
        var(--smp-surface-raised, #fff)
    );
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
}

/* Sidebar / outline list tree (same chevron language) */
.smp-fb-tree-row {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    min-width: 0;
    border-bottom: 1px solid var(--smp-border-default, #e2e8f0);
    background: var(--smp-surface-raised, #fff);
}

.smp-fb-tree-row:last-child {
    border-bottom: none;
}

.smp-fb-tree-toggle {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--smp-color-text-muted);
    cursor: pointer;
    font-size: 0;
    line-height: 1.25rem;
    text-align: center;
    position: relative;
}

.smp-fb-tree-toggle--spacer {
    display: inline-block;
    cursor: default;
}

.smp-fb-tree-toggle:not(.smp-fb-tree-toggle--spacer)::before {
    content: "";
    display: inline-block;
    width: 0.35rem;
    height: 0.35rem;
    border-right: 2px solid var(--smp-color-text-muted, #64748b);
    border-bottom: 2px solid var(--smp-color-text-muted, #64748b);
    transform: rotate(-45deg);
    transition: transform 0.15s ease;
}

.smp-fb-tree-toggle.is-open::before {
    transform: rotate(45deg);
}

.smp-fb-tree-link {
    flex: 1;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.55rem 0.5rem 0.15rem;
    border: 0;
    background: transparent;
    color: var(--smp-color-text);
    font: inherit;
    font-size: var(--smp-text-sm);
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    border-radius: 0;
}

.smp-fb-tree-link:hover {
    background: color-mix(
        in srgb,
        var(--smp-color-brand, #0d9488) 8%,
        transparent
    );
}

.smp-fb-tree-link.is-active {
    font-weight: 700;
    background: color-mix(
        in srgb,
        var(--smp-color-brand, #0d9488) 12%,
        transparent
    );
}

.smp-fb-tree-list--nested {
    padding-left: 0;
    margin: 0;
    list-style: none;
}

.smp-fb-tree-list--nested .smp-fb-tree-row {
    padding-left: 0.85rem;
}

.smp-fb-tree > ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Modal */
.smp-fb-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: calc(var(--smp-z-app-overlay, 10050) + 10);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: color-mix(in srgb, var(--smp-color-text) 35%, transparent);
}

.smp-fb-modal {
    width: min(28rem, 94vw);
    max-height: 90vh;
    overflow: auto;
    padding: 1.25rem;
    background: var(--smp-surface-raised, #fff);
    border: 1px solid var(--smp-border-default);
    border-radius: 10px;
    box-shadow: 0 18px 48px color-mix(in srgb, var(--smp-color-text) 22%, transparent);
}

.smp-fb-modal h3 {
    margin: 0 0 0.75rem;
    font-size: var(--smp-text-base);
    color: var(--smp-color-text);
}

.smp-fb-modal__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

/* Skin modifiers */
.smp-fb--doctor .smp-fb-bc-link {
    color: var(--smp-doctor-accent, var(--smp-color-brand));
}

.smp-fb--hsms .smp-fb-board {
    max-height: none;
}

.smp-fb--library .smp-fb-toolbar {
    padding: 0;
}

/* Collapsing card: one table row per same-document file group */
.smp-fb-row--file-card > td {
    padding: 0.4rem 0.5rem;
    vertical-align: top;
    border-bottom: 1px solid var(--smp-border-default, #e2e8f0);
}

.smp-fb-file-card {
    margin: 0;
    border: 1px solid var(--smp-border-default, #e2e8f0);
    border-radius: 8px;
    background: var(--smp-surface-raised, #fff);
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.smp-fb-file-card__summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    cursor: pointer;
    padding: 0.55rem 0.75rem;
    user-select: none;
    background: var(--smp-surface-muted, #f8fafc);
    font-weight: 600;
    font-size: var(--smp-text-sm);
    color: var(--smp-color-text, #0f172a);
}

.smp-fb-file-card__summary::-webkit-details-marker {
    display: none;
}

.smp-fb-file-card__chevron {
    flex: 0 0 auto;
    width: 0.4rem;
    height: 0.4rem;
    border-right: 2px solid var(--smp-color-text-muted, #64748b);
    border-bottom: 2px solid var(--smp-color-text-muted, #64748b);
    transform: rotate(-45deg);
    margin-right: 0.15rem;
    transition: transform 0.15s ease;
}

.smp-fb-file-card[open] > .smp-fb-file-card__summary .smp-fb-file-card__chevron {
    transform: rotate(45deg);
}

.smp-fb-file-card__summary:hover {
    background: color-mix(
        in srgb,
        var(--smp-color-brand, #0d9488) 8%,
        var(--smp-surface-muted, #f8fafc)
    );
}

.smp-fb-file-card__title {
    flex: 1 1 auto;
    min-width: 8rem;
}

.smp-fb-file-card__badges {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.smp-fb-file-card__count {
    flex: 0 0 auto;
    font-size: var(--smp-text-2xs);
    font-weight: 600;
    color: var(--smp-color-text-muted, #64748b);
    background: color-mix(in srgb, var(--smp-color-text) 6%, transparent);
    border-radius: 999px;
    padding: 0.15rem 0.5rem;
}

.smp-fb-file-card__body {
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--smp-border-default, #e2e8f0);
}

.smp-fb-file-card__item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.5rem 0.75rem;
    padding: 0.45rem 0.75rem;
    border-bottom: 1px solid var(--smp-border-default, #eef2f7);
}

.smp-fb-file-card__item:last-child {
    border-bottom: none;
}

.smp-fb-file-card__item:hover {
    background: color-mix(in srgb, var(--smp-color-brand, #0d9488) 5%, transparent);
}

.smp-fb-file-card__item-main {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
    flex-wrap: wrap;
}

.smp-fb-file-card__item-name {
    font-size: var(--smp-text-sm);
    color: var(--smp-color-text);
    word-break: break-word;
}

.smp-fb-file-card__item-role {
    font-size: var(--smp-text-2xs);
    color: var(--smp-color-text-muted, #64748b);
    font-weight: 600;
}

.smp-fb-file-card__item-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.smp-fb-file-card__item-check .smp-hsms-select-toggle--spacer {
    display: inline-block;
    width: 1.1rem;
}

/* Controls card members use shared standard file row (not legacy item grid). */
.smp-fb-file-card__body > .smp-hsms-file-row--card-item {
    --smp-fb-tree-depth: 0;
    --hsms-depth: 0;
    padding-left: 0.75rem;
    border-bottom: 1px solid var(--smp-border-default, #eef2f7);
}

.smp-fb-file-card__body > .smp-hsms-file-row--card-item:last-child {
    border-bottom: none;
}

.smp-fb-ack-dot {
    display: inline-flex;
    margin-right: 0.35rem;
    vertical-align: middle;
}

.smp-fb-name-label {
    display: block;
    font-size: var(--smp-text-sm);
    font-weight: var(--smp-font-weight-semibold, 600);
}

.smp-fb-name-input {
    display: block;
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--smp-border-default, #c9d1dc);
    border-radius: 6px;
    font: inherit;
    background: var(--bs-body-bg, #fff);
    color: var(--smp-color-text);
}

.smp-fb-row {
    cursor: default;
}
