/* Email management styles, migrated from fcs-blazor-email-management's app.css.
 *
 * The original file's five GLOBAL rules are deliberately omitted: `html, body`, `*`, `a` and `h1`.
 * They set the standalone app's dark theme (background #111418, colour #e6edf3) and a box-sizing
 * reset, and FCSSite is themed light/dark by the user's own toggle — applying them here would
 * repaint the entire site. Everything kept below is class-scoped.
 *
 * Verified before adopting: none of the 127 class names here collide with any selector in
 * FCSSite's existing stylesheets, so this can be loaded site-wide without affecting other pages.
 */


.fcs-email-layout {
    min-height: 100vh;
    background: #111418;
}

.fcs-email-header {
    border-bottom: 1px solid #26313d;
    background: #0d1117;
    color: #e6edf3;
}

.fcs-email-nav {
    min-height: 60px;
    padding: 0 18px;
}

.brand-cluster {
    min-width: 0;
}

.brand-copy {
    min-width: 0;
}

.brand {
    overflow: hidden;
    color: #f5f7fa;
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.subtle,
.muted {
    color: #8b98a5;
    font-size: 0.875rem;
}

.brand-copy .subtle {
    overflow: hidden;
    color: #aab6c3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-actions {
    padding-right: 4px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 30px;
    padding: 5px 10px;
    border: 1px solid #2f3c49;
    border-radius: 8px;
    background: #161d24;
    color: #c9d6e3;
    font-size: 0.83rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #96c93d;
    box-shadow: 0 0 0 3px rgba(150, 201, 61, 0.14);
}

.fcs-email-sidebar {
    --rz-sidebar-width: 274px;
    border-right: 1px solid #26313d;
    background: #0d1117;
    color: #dbe6ec;
}

.fcs-email-menu.rz-panel-menu {
    padding: 10px 8px;
    background: transparent;
}

.fcs-email-menu .rz-navigation-item-wrapper,
.fcs-email-menu .rz-navigation-item-link {
    min-height: 38px;
    border-radius: 7px;
    color: #9db2c8;
}

.fcs-email-menu .rz-navigation-item-link:hover,
.fcs-email-menu .rz-navigation-item-active > .rz-navigation-item-wrapper,
.fcs-email-menu .rz-navigation-item-active > .rz-navigation-item-link {
    background: #151b23;
    color: #58a6ff;
}

.fcs-email-body {
    background:
        linear-gradient(180deg, rgba(37, 170, 225, 0.05), rgba(37, 170, 225, 0) 220px),
        #111418;
}

.page-shell {
    width: 100%;
    max-width: 1540px;
    min-height: calc(100vh - 60px);
    margin: 0 auto;
    padding: 26px;
}

.search-panel,
.detail-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.search-row {
    flex: 1 1 560px;
    justify-content: flex-end;
}

.query-input {
    width: min(680px, 100%);
}

.mailbox-select {
    width: min(380px, 100%);
}

.direction-select {
    width: 155px;
}

.query-example-select {
    width: 190px;
}

.tag-filter-select {
    width: 230px;
}

.limit-input {
    width: 112px;
}

.active-filters {
    flex-wrap: wrap !important;
}

.results-grid,
.embedded-grid {
    overflow: hidden;
    border: 1px solid #2b3742;
    border-radius: 8px;
    background: #171c22;
}

.rz-data-grid {
    --rz-grid-cell-padding: 0.65rem 0.75rem;
}

.rz-grid-table td,
.rz-grid-table th {
    border-color: #26313d !important;
}

.link-button {
    appearance: none;
    border: 0;
    padding: 0;
    background: transparent;
    color: #58a6ff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    text-align: left;
}

.link-button:hover {
    color: #86c5da;
    text-decoration: underline;
}

.snippet {
    display: -webkit-box;
    overflow: hidden;
    margin-top: 4px;
    color: #8b98a5;
    font-size: 0.84rem;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.stat-box,
.activity-shell,
.labels-panel,
.decision-editor,
.feedback-editor,
.roc-panel,
.threshold-panel,
.review-range-panel,
.review-list-panel,
.logo-toolbar,
.sample-toolbar,
.rule-editor,
.email-body,
.raw-facts {
    border: 1px solid #2b3742;
    border-radius: 8px;
    background: #171c22;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.16);
}

.stat-box {
    padding: 14px;
}

.stat-box span {
    display: block;
    margin-bottom: 6px;
    color: #9db2c8;
    font-size: 0.82rem;
}

.stat-box strong {
    color: #f5f7fa;
    font-size: 1.22rem;
}

.stat-button {
    appearance: none;
    color: inherit;
    cursor: pointer;
    text-align: left;
}

.stat-button:hover {
    border-color: #58a6ff;
    background: #10243a;
}

.activity-shell,
.labels-panel {
    margin-top: 18px;
    padding: 16px;
}

.activity-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.activity-header h2,
.labels-panel h2,
.editor-header h2,
.section-heading {
    margin: 0;
    color: #f5f7fa;
    font-size: 1.02rem;
    font-weight: 700;
}

.section-heading {
    margin: 18px 0 10px;
}

.activity-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: wrap;
}

.activity-grid {
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: repeat(7, 12px);
    gap: 3px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.activity-cell {
    width: 12px;
    height: 12px;
    border: 1px solid rgba(230, 237, 243, 0.08);
    border-radius: 2px;
}

.rule-editor {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 180px minmax(260px, 1.5fr) auto;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
    padding: 14px;
}

.rule-email-input,
.rule-select,
.rule-reason-input {
    width: 100%;
}

.rule-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.classification-page {
    display: grid;
    grid-template-columns: 242px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.classification-page-collapsed {
    grid-template-columns: 58px minmax(0, 1fr);
}

.classification-side-menu {
    position: sticky;
    top: 18px;
    overflow: hidden;
    min-height: 320px;
    border: 1px solid #2b3742;
    border-radius: 8px;
    background: #171c22;
}

.classification-side-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border-bottom: 1px solid #26313d;
    color: #e6edf3;
    font-weight: 700;
}

.classification-menu {
    display: grid;
    gap: 2px;
    padding: 8px;
}

.classification-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    padding: 8px 10px;
    border-radius: 7px;
    color: #9db2c8;
    text-decoration: none;
    white-space: nowrap;
}

.classification-menu-item:hover,
.classification-menu-item.active {
    background: #10243a;
    color: #58a6ff;
}

.classification-menu-group {
    display: grid;
    gap: 2px;
}

.classification-submenu {
    display: grid;
    gap: 2px;
    margin-left: 16px;
}

.classification-submenu-item {
    min-height: 34px;
    font-size: 0.9rem;
}

.classification-page-collapsed .classification-side-header span,
.classification-page-collapsed .classification-menu-item span {
    display: none;
}

.classification-page-collapsed .classification-side-header,
.classification-page-collapsed .classification-menu-item {
    justify-content: center;
}

.classification-page-collapsed .classification-submenu {
    margin-left: 0;
}

.classification-content {
    min-width: 0;
}

.classification-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(380px, 0.82fr);
    gap: 16px;
    align-items: start;
}

.decision-editor,
.feedback-editor,
.roc-panel,
.threshold-panel,
.review-range-panel,
.review-list-panel,
.logo-toolbar,
.sample-toolbar {
    padding: 14px;
}

.ai-score-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.ai-run-toolbar {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(260px, 360px);
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

.ai-run-select {
    width: 100%;
}

.run-metadata {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
}

.run-metadata span {
    overflow: hidden;
    padding: 8px 10px;
    border: 1px solid #2b3742;
    border-radius: 6px;
    color: #c9d7e4;
    background: #111820;
    font-size: 0.82rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-score-layout {
    display: grid;
    grid-template-columns: minmax(360px, 1.25fr) minmax(320px, 0.75fr);
    gap: 16px;
    align-items: stretch;
    margin-bottom: 16px;
}

.roc-panel,
.threshold-panel {
    border: 1px solid #2b3742;
    border-radius: 8px;
    background: #171c22;
}

.roc-chart {
    display: block;
    width: 100%;
    min-height: 300px;
}

.roc-grid-line {
    stroke: #26313d;
    stroke-width: 1;
}

.roc-diagonal {
    stroke: #6b7785;
    stroke-dasharray: 5 5;
    stroke-width: 1.5;
}

.roc-line {
    fill: none;
    stroke: #7cc06f;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 3;
}

.roc-point {
    fill: #111418;
    stroke: #7cc06f;
    stroke-width: 2;
}

.roc-axis-label,
.roc-tick {
    fill: #9db2c8;
    font-size: 12px;
}

.roc-axis-label {
    font-weight: 700;
    text-anchor: middle;
}

.roc-axis-label-y {
    transform-box: fill-box;
    transform: rotate(-90deg);
    transform-origin: center;
}

.confusion-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.confusion-grid div {
    min-height: 76px;
    padding: 12px;
    border: 1px solid #2b3742;
    border-radius: 8px;
    background: #111820;
}

.confusion-grid span,
.threshold-notes span {
    display: block;
    color: #9db2c8;
    font-size: 0.82rem;
}

.confusion-grid strong {
    display: block;
    margin-top: 6px;
    color: #f5f7fa;
    font-size: 1.28rem;
}

.threshold-notes {
    display: grid;
    gap: 6px;
    margin-top: 12px;
}

.review-range-panel {
    margin-bottom: 16px;
    border: 1px solid #2b3742;
    border-radius: 8px;
    background: #171c22;
}

.score-range-grid {
    display: grid;
    grid-template-columns: 230px minmax(240px, 1fr);
    gap: 18px;
    align-items: center;
}

.score-threshold-inputs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.score-threshold-inputs label {
    display: grid;
    gap: 5px;
}

.score-threshold-inputs span {
    color: #9db2c8;
    font-size: 0.78rem;
    font-weight: 700;
}

.score-threshold-input {
    width: 100%;
}

.score-range-slider {
    width: 100%;
}

.score-review-lists {
    display: grid;
    gap: 16px;
    margin-bottom: 16px;
}

.review-list-panel {
    overflow: visible;
    border: 1px solid #2b3742;
    border-radius: 8px;
    background: #171c22;
}

.image-classification-prefetch {
    position: absolute;
    overflow: hidden;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.image-classification-prefetch img {
    width: 1px;
    height: 1px;
}

.image-classification-section {
    padding: 14px;
}

.image-classification-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.image-classification-card {
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 10px;
    min-height: 214px;
    padding: 10px;
    border: 1px solid #2b3742;
    border-radius: 8px;
    background: #111820;
}

.image-classification-actions {
    display: grid;
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: 8px;
    align-self: stretch;
}

.image-classification-actions .rz-button {
    width: 100%;
    min-width: 0;
    min-height: 92px;
    white-space: normal;
}

.image-classification-frame {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    aspect-ratio: 4 / 3;
    border: 1px solid #26313d;
    border-radius: 6px;
    background: #0b1015;
}

.image-classification-image {
    display: block;
    max-width: 100%;
    max-height: 208px;
    object-fit: contain;
}

.image-review-prefetch {
    position: absolute;
    overflow: hidden;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.image-review-prefetch img {
    width: 1px;
    height: 1px;
}

.image-review-empty {
    padding: 18px;
    border: 1px solid #2b3742;
    border-radius: 8px;
    background: #171c22;
}

.image-review-queue {
    display: grid;
    gap: 14px;
}

.image-review-card {
    display: grid;
    gap: 12px;
    min-width: 0;
    padding: 12px;
    border: 1px solid #2b3742;
    border-radius: 8px;
    background: #111820;
}

.image-review-card-active {
    position: sticky;
    top: 12px;
    z-index: 5;
    background: #121b24;
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
}

.image-review-actions-horizontal {
    display: grid;
    grid-template-columns: repeat(2, minmax(130px, 160px));
    gap: 10px;
    justify-content: start;
}

.image-review-actions-horizontal .rz-button {
    min-height: 42px;
    min-width: 0;
}

.image-review-image-frame {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 320px;
    max-height: 540px;
    border: 1px solid #26313d;
    border-radius: 6px;
    background: #0b1015;
}

.image-review-image {
    display: block;
    max-width: 100%;
    max-height: 520px;
    object-fit: contain;
}

.image-review-card-pending .image-review-image-frame {
    min-height: 220px;
    max-height: 340px;
}

.image-review-card-pending .image-review-image {
    max-height: 320px;
}

.image-review-upcoming {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 220px));
    gap: 12px;
}

.image-review-upcoming-card {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 4 / 3;
    min-width: 0;
    border: 1px solid #2b3742;
    border-radius: 8px;
    background: #111820;
    overflow: hidden;
}

.image-review-upcoming-image {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.editor-header,
.editor-actions,
.logo-toolbar,
.file-upload-row,
.rule-switch-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.editor-header {
    justify-content: space-between;
    margin-bottom: 12px;
}

.rule-form-grid {
    display: grid;
    grid-template-columns: 100px minmax(110px, 1fr) minmax(120px, 1fr);
    gap: 8px;
    margin-bottom: 8px;
}

.rule-order-input,
.rule-tag-select,
.rule-action-select,
.rule-wide-input,
.tree-json-input,
.logo-notes-input {
    width: 100%;
}

.rule-wide-input,
.tree-json-input,
.rule-switch-row {
    margin-top: 8px;
}

.tree-json-input {
    font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
    font-size: 0.86rem;
}

.editor-actions {
    justify-content: flex-end;
    margin-top: 10px;
}

.validation-alert {
    margin-bottom: 16px;
}

.logo-toolbar {
    justify-content: space-between;
    margin-bottom: 14px;
}

.sample-toolbar,
.feedback-editor {
    margin-bottom: 14px;
}

.file-upload-row {
    flex: 1 1 420px;
}

.logo-notes-input {
    max-width: 360px;
}

.logo-thumb {
    width: 54px;
    height: 54px;
    border: 1px solid #2b3742;
    border-radius: 7px;
    background: #0d1117;
    object-fit: contain;
    padding: 3px;
}

.logo-candidate-grid,
.logo-candidate-grid .rz-data-grid,
.logo-candidate-grid .rz-data-grid-data,
.logo-candidate-grid .rz-grid-table,
.logo-candidate-grid .rz-cell-data {
    overflow: visible;
}

.candidate-preview {
    position: relative;
    width: 52px;
    height: 52px;
}

.candidate-thumb {
    width: 52px;
    height: 52px;
    border: 1px solid #2b3742;
    border-radius: 7px;
    background: #0d1117;
    object-fit: contain;
    padding: 3px;
}

.candidate-flyout {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 10000;
    width: min(760px, calc(100vw - 48px));
    height: min(560px, calc(100vh - 48px));
    padding: 12px;
    border: 1px solid #3a4a59;
    border-radius: 8px;
    background: #0d1117;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.candidate-full-image {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    border: 0;
    border-radius: 4px;
    background: #fff;
    object-fit: contain;
    padding: 0;
}

.candidate-preview:hover {
    z-index: 100;
}

.candidate-preview:hover .candidate-flyout {
    display: block;
}

.attributes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 24px;
    padding: 16px 0;
    border-top: 1px solid #2b3742;
    border-bottom: 1px solid #2b3742;
}

.attributes div,
.raw-facts div {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 12px;
}

.attributes span,
.raw-facts span {
    overflow-wrap: anywhere;
}

.detail-tabs {
    margin-top: 20px;
}

.email-body {
    padding: 20px;
}

.email-body pre {
    margin: 0;
    overflow-wrap: anywhere;
    color: #dbe6ec;
    font-family: inherit;
    line-height: 1.45;
    white-space: pre-wrap;
}

.html-preview {
    overflow: auto;
}

.html-preview * {
    max-width: 100%;
}

.raw-facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 24px;
    padding: 16px;
}

@media (max-width: 980px) {
    .fcs-email-nav {
        padding: 10px 14px;
    }

    .fcs-email-sidebar {
        --rz-sidebar-width: 72px;
    }

    .fcs-email-menu.rz-panel-menu {
        padding: 8px 6px;
    }

    .fcs-email-menu .rz-navigation-item-text,
    .fcs-email-menu .rz-navigation-item-chevron,
    .fcs-email-menu .rz-navigation-menu {
        display: none;
    }

    .fcs-email-menu .rz-navigation-item-wrapper,
    .fcs-email-menu .rz-navigation-item-link {
        justify-content: center;
        padding-right: 0;
        padding-left: 0;
    }

    .fcs-email-menu .rz-navigation-item-icon {
        margin: 0;
    }

    .brand-copy .subtle,
    .status-pill {
        display: none;
    }

    .page-shell {
        padding: 16px;
    }

    .search-panel,
    .detail-header,
    .activity-header {
        align-items: stretch;
        flex-direction: column;
    }

    .search-row {
        flex-basis: auto;
        justify-content: flex-start;
    }

    .attributes,
    .raw-facts,
    .stat-grid,
    .classification-page,
    .classification-page-collapsed,
    .classification-layout,
    .rule-form-grid,
    .rule-editor {
        grid-template-columns: 1fr;
    }

    .classification-side-menu {
        position: static;
        min-height: 0;
    }

    .classification-menu,
    .classification-submenu {
        grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
        margin-left: 0;
    }

    .logo-toolbar,
    .file-upload-row,
    .logo-toolbar .rule-actions {
        align-items: stretch;
        flex-direction: column;
        width: 100%;
    }

    .file-upload-row {
        flex-basis: auto;
    }

    .logo-notes-input,
    .logo-toolbar .limit-input {
        max-width: none;
        width: 100%;
    }

    .classification-page-collapsed .classification-side-header span,
    .classification-page-collapsed .classification-menu-item span {
        display: inline;
    }

    .classification-page-collapsed .classification-side-header,
    .classification-page-collapsed .classification-menu-item {
        justify-content: flex-start;
    }

    .image-classification-grid {
        grid-template-columns: 1fr;
    }

    .image-classification-card {
        grid-template-columns: 72px minmax(0, 1fr);
        min-height: 184px;
    }

    .image-classification-actions .rz-button {
        min-height: 78px;
    }

    .image-classification-image {
        max-height: 178px;
    }

    .image-review-card-active {
        position: static;
    }

    .image-review-actions-horizontal {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .image-review-image-frame {
        min-height: 230px;
        max-height: 360px;
    }

    .image-review-image {
        max-height: 340px;
    }

    .image-review-upcoming {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
