/* ============================================================
   MyGreat.Cloud – consolidated styles
   ============================================================ */

/* ---------- Root & body ---------- */
html {
    font-size: 90%;
}

.project-graph-node-selected rect {
    stroke-width: 3px;
}

.project-graph-node-connect-source rect {
    stroke: var(--bs-info) !important;
    stroke-width: 4px;
}

.project-graph-link-selected {
    stroke-width: 3.5px;
}

.project-graph-edge-running {
    animation: project-graph-edge-flow 1.6s linear infinite;
}

@keyframes project-graph-edge-flow {
    from {
        stroke-dashoffset: 0;
    }
    to {
        stroke-dashoffset: -20;
    }
}

@media (prefers-reduced-motion: reduce) {
    .project-graph-edge-running {
        animation: none;
    }
}

:root {
    color-scheme: dark;
    --app-sidebar-width: 240px;
    --app-shell-bg: #0f1115;
    --app-shell-fg: #e6e6e6;
    --app-sidebar-bg: #141824;
    --app-surface: #151a22;
    --app-surface-muted: #171d2b;
    --app-border: #2b2f3a;
    --app-border-strong: #2b3448;
    --app-muted: #9aa0a6;
    --app-link: #9ecbff;
    --app-link-hover: #dce6ff;
    --app-nav-link: #aab2bd;
    --app-nav-hover-bg: #1e2430;
    --app-nav-active-bg: #1b2232;
    --app-nav-active-fg: #9ecbff;
    --app-nav-active-border: #5aa2ff;
    --app-user-trigger-bg: #1b2232;
    --app-user-trigger-hover-bg: #222b3d;
    --app-user-trigger-border: #2b3448;
    --app-user-trigger-hover-border: #3a465f;
    --app-user-trigger-fg: #d6deee;
    --app-user-trigger-hover-fg: #eef4ff;
    --app-user-name: #eef4ff;
    --app-user-email: #9fb0cc;
    --app-avatar-bg: #2e3a52;
    --app-avatar-fg: #dce7ff;
    --app-table-head-bg: #171d2b;
    --app-table-head-fg: #b9c2d3;
    --app-table-head-border: #323a4b;
    --app-row-hover-bg: #1b2232;
    --app-badge-border: rgba(255, 255, 255, 0.08);
}

html[data-bs-theme="light"] {
    color-scheme: light;
    --app-shell-bg: #f4f7fb;
    --app-shell-fg: #1d2430;
    --app-sidebar-bg: #ffffff;
    --app-surface: #ffffff;
    --app-surface-muted: #edf2f8;
    --app-border: #d5deea;
    --app-border-strong: #c0ccdb;
    --app-muted: #66758a;
    --app-link: #0d6efd;
    --app-link-hover: #084298;
    --app-nav-link: #4c5d75;
    --app-nav-hover-bg: #eef4fb;
    --app-nav-active-bg: #e4eefb;
    --app-nav-active-fg: #0a58ca;
    --app-nav-active-border: #0d6efd;
    --app-user-trigger-bg: #f2f6fc;
    --app-user-trigger-hover-bg: #e7eef8;
    --app-user-trigger-border: #c8d4e3;
    --app-user-trigger-hover-border: #afbfd2;
    --app-user-trigger-fg: #1d2430;
    --app-user-trigger-hover-fg: #10243d;
    --app-user-name: #1d2430;
    --app-user-email: #5a6b82;
    --app-avatar-bg: #dce7f7;
    --app-avatar-fg: #28405f;
    --app-table-head-bg: #edf2f8;
    --app-table-head-fg: #556579;
    --app-table-head-border: #c8d4e3;
    --app-row-hover-bg: #eef4fb;
    --app-badge-border: rgba(0, 0, 0, 0.08);
}
body {
    height: 100vh;
    overflow: hidden;
    background: var(--app-shell-bg);
    color: var(--app-shell-fg);
}

/* ---------- Layout ---------- */
.sidebar {
    width: var(--app-sidebar-width);
    flex: 0 0 var(--app-sidebar-width);
    min-width: var(--app-sidebar-width);
    background: var(--app-sidebar-bg);
    border-right: 1px solid var(--app-border);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}
.app-shell-sidebar-desktop {
    width: var(--app-sidebar-width);
    flex: 0 0 var(--app-sidebar-width);
    min-width: 0;
    overflow: hidden;
    transition: width 0.2s ease, flex-basis 0.2s ease;
}
.app-shell-corner-toggle {
    position: fixed;
    bottom: 1rem;
    left: calc(var(--app-sidebar-width) - 1.25rem);
    z-index: 1035;
    width: 2.5rem;
    height: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 999px;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    color: var(--app-shell-fg);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
    transition: left 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}
.sidebar-brand-wrap {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 0.75rem;
}
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.page-header-copy {
    min-width: 0;
    flex: 1 1 24rem;
}
.page-action-box {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
    border: 1px solid var(--app-border);
    border-radius: 1rem;
    background: var(--app-surface);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.04);
}
.page-action-box .btn {
    white-space: nowrap;
}
.page-action-box-label {
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--app-muted);
}
.page-action-box-group {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.content-area {
    overflow-y: auto;
    height: 100vh;
    background: var(--app-shell-bg);
    scrollbar-gutter: stable;
}
.content-shell {
    padding: 1.5rem;
}
.mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--app-shell-bg);
    padding-top: 0.25rem;
}
.mobile-sidebar-offcanvas {
    width: min(86vw, 320px);
    background: var(--app-sidebar-bg);
    color: var(--app-shell-fg);
}
.mobile-sidebar-offcanvas .offcanvas-header {
    border-bottom: 1px solid var(--app-border);
}
.mobile-sidebar-offcanvas .offcanvas-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.mobile-sidebar-offcanvas .sidebar {
    width: 100%;
    min-width: 0;
    flex: 1 1 auto;
    border-right: 0;
    height: 100%;
}

/* ---------- List group overrides ---------- */
.list-group-item {
    background: var(--app-surface);
    color: var(--app-shell-fg);
    border-color: var(--app-border);
}
.list-group-item a {
    color: var(--app-link);
}
.list-group-item a.btn {
    color: var(--bs-btn-color);
}
.list-group-item a.btn:hover,
.list-group-item a.btn:focus {
    color: var(--bs-btn-hover-color, var(--bs-btn-color));
}

/* ---------- Bootstrap overrides ---------- */
.text-muted {
    color: var(--app-muted) !important;
}
.form-check-input {
    cursor: pointer;
}

.knowledge-base-help-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 999px;
    color: var(--app-link);
    text-decoration: none;
    flex: 0 0 auto;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.knowledge-base-help-icon {
    width: 1rem;
    height: 1rem;
    display: block;
}

.knowledge-base-help-icon circle {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.4;
}

.knowledge-base-help-icon .knowledge-base-help-icon-dot,
.knowledge-base-help-icon .knowledge-base-help-icon-stem {
    fill: currentColor;
    stroke: none;
}

.knowledge-base-help-link:hover,
.knowledge-base-help-link:focus {
    background: var(--app-row-hover-bg);
    color: var(--app-link-hover);
}

.knowledge-base-inline-heading {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.knowledge-base-header-row {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
}

.knowledge-base-header-row .btn {
    flex: 1 1 auto;
    min-width: 0;
}

.app-menu-toggle {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    color: var(--app-shell-fg);
}

.app-shell-corner-toggle:hover,
.app-shell-corner-toggle:focus,
.app-menu-toggle:hover,
.app-menu-toggle:focus {
    background: var(--app-row-hover-bg);
    border-color: var(--app-border-strong);
    color: var(--app-shell-fg);
}

.run-files-table {
    min-width: 1800px;
}

.run-files-col-select {
    min-width: 72px;
    width: 72px;
    white-space: nowrap;
}

.run-files-col-status {
    min-width: 90px;
    width: 90px;
    white-space: nowrap;
}

.run-files-col-path {
    min-width: 420px;
    width: 32%;
    white-space: nowrap;
}

.run-files-col-proposed {
    min-width: 320px;
    width: 24%;
}

.run-files-col-proposed .files-proposed-rename-input {
    min-width: 280px;
    width: 100%;
}

.run-files-col-proposed .files-rename-job-status {
    min-width: 280px;
}

.run-log-message-help {
    cursor: help;
    text-decoration: underline dotted;
    text-underline-offset: 0.18rem;
}

.run-message-tooltip {
    --bs-tooltip-max-width: 28rem;
}

.exclude-filter-browser-overlay {
    position: fixed;
    inset: 0;
    z-index: 1080;
}

.exclude-filter-browser-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.62);
}

.exclude-filter-browser-panel {
    position: relative;
    z-index: 1;
    width: min(1080px, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    margin: 1rem auto;
    display: flex;
    flex-direction: column;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
}

.exclude-filter-browser-panel .card-body {
    overflow: auto;
}

.exclude-filter-browser-list {
    min-height: 12rem;
}

.exclude-filter-browser-entry {
    background: var(--app-surface);
    border-color: var(--app-border);
}

.exclude-filter-browser-entry-rule {
    white-space: nowrap;
    overflow-x: auto;
    max-width: 100%;
    display: inline-block;
}

.exclude-filter-browser-entry-name {
    min-width: 0;
}

/* ---------- Sidebar branding ---------- */
.sidebar-brand .sidebar-logo {
    width: 120px;
    height: auto;
    opacity: 0.95;
}
.sidebar-brand .sidebar-title {
    font-weight: 600;
    color: var(--app-shell-fg);
    letter-spacing: 0.2px;
}

html[data-sidebar-collapsed="1"] .app-shell-sidebar-desktop {
    width: 0;
    flex-basis: 0;
}

html[data-sidebar-collapsed="1"] .app-shell-corner-toggle {
    left: 1rem;
}

/* ---------- Sidebar navigation ---------- */
.sidebar ul.nav .nav-link {
    padding: 0.4rem 0.75rem;
    color: var(--app-nav-link);
}
.sidebar ul.nav .nav-link:hover {
    color: var(--app-shell-fg);
    background-color: var(--app-nav-hover-bg);
    border-radius: 4px;
}
.sidebar ul.nav .nav-link.active {
    color: var(--app-nav-active-fg);
    font-weight: 500;
    background-color: var(--app-nav-active-bg);
    border-radius: 4px;
    border-left: 3px solid var(--app-nav-active-border);
    padding-left: calc(0.75rem - 3px);
}
.sidebar-meta {
    opacity: 0.7;
}
.sidebar-projects-nav {
    font-size: 0.9rem;
}
.sidebar-jobs-nav {
    font-size: 0.85rem;
}
.sidebar-job-name {
    max-width: 180px;
}
.sidebar-tenant-name {
    line-height: 1.25;
}

.sidebar-tenant-trigger {
    background: var(--app-user-trigger-bg);
    border: 1px solid var(--app-user-trigger-border);
    color: var(--app-user-trigger-fg);
}

.sidebar-tenant-trigger:hover,
.sidebar-tenant-trigger:focus {
    background: var(--app-user-trigger-hover-bg);
    border-color: var(--app-user-trigger-hover-border);
    color: var(--app-user-trigger-hover-fg);
}

.sidebar-tenant-menu {
    min-width: 16rem;
}

.sidebar-user-menu {
    width: 100%;
}

.sidebar-user-trigger {
    background: var(--app-user-trigger-bg);
    border: 1px solid var(--app-user-trigger-border);
    color: var(--app-user-trigger-fg);
    border-radius: 8px;
    padding: 0.5rem 0.6rem;
}

.sidebar-user-trigger:hover,
.sidebar-user-trigger:focus {
    background: var(--app-user-trigger-hover-bg);
    border-color: var(--app-user-trigger-hover-border);
    color: var(--app-user-trigger-hover-fg);
}

.sidebar-user-avatar,
.sidebar-user-avatar-fallback {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    flex: 0 0 32px;
}

.sidebar-user-avatar {
    object-fit: cover;
}

.sidebar-user-avatar-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--app-avatar-bg);
    color: var(--app-avatar-fg);
    font-size: 0.8rem;
    font-weight: 600;
}

.sidebar-user-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.sidebar-user-name,
.sidebar-user-email {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-name {
    font-size: 0.88rem;
    color: var(--app-user-name);
}

.sidebar-user-email {
    font-size: 0.74rem;
    color: var(--app-user-email);
}

.theme-option-check {
    visibility: hidden;
    font-size: 0.8rem;
}

[data-theme-option][aria-checked="true"] .theme-option-check {
    visibility: visible;
}

/* ---------- Progress bar sizes ---------- */
.progress-lg {
    height: 14px;
}
.progress-sm {
    height: 10px;
}

/* ---------- Chart containers ---------- */
.chart-container {
    height: 280px;
}

/* ---------- Scrollable card body ---------- */
.card-body-scroll {
    max-height: 500px;
    overflow-y: auto;
}

.run-detail-list-scroll {
    padding: 0;
}

.run-detail-table-scroll,
.run-detail-list-table-scroll {
    max-height: 500px;
    overflow: auto;
    padding: 0 1rem 1rem;
}

.run-detail-list-controls {
    margin: 0;
    padding: 1rem 1rem 0.75rem;
}

.run-live-value,
.run-live-meta-value {
    font-family: var(--bs-font-monospace);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.run-live-value-sm {
    font-size: 0.875rem;
}

.run-live-meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.25rem;
}

.run-live-meta-label {
    color: var(--bs-secondary-color);
    font-size: 0.875rem;
}

.run-detail-section-scroll {
    padding-top: 0;
}

.run-detail-section-controls {
    margin: 0 -1rem 0.75rem;
    padding: 1rem 1rem 0.75rem;
}

.run-detail-table-scroll .run-detail-sticky-table,
.run-detail-list-table-scroll .run-detail-sticky-table {
    min-width: 100%;
}

.run-detail-sticky-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--app-table-head-bg);
    box-shadow: inset 0 -1px 0 var(--app-table-head-border);
}

.run-detail-list-empty {
    padding: 1rem 0 0;
}

.run-detail-refresh-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    background: var(--bs-body-bg);
}

.run-detail-refresh-switch .form-check-input {
    margin: 0;
}

.run-detail-refresh-switch .form-check-label {
    margin: 0;
    font-size: 0.875rem;
    color: var(--app-muted);
    cursor: pointer;
    white-space: nowrap;
}

.run-detail-list-pagination {
    margin: 1rem 1rem 0;
    padding: 0 0 1rem;
    max-width: 100%;
}

.run-detail-list-pagination-scroll {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0.25rem;
}

.run-detail-list-pagination .pagination {
    width: max-content;
    min-width: 100%;
}

.run-detail-summary-card {
    width: 100%;
}

.run-detail-summary-card .card-body {
    height: 100%;
}

/* ---------- Table column widths (logs) ---------- */
.col-time   { width: 120px; }
.col-level  { width: 90px; }
.col-object { width: 220px; }
.col-object-type { width: 180px; }
.col-source { width: 240px; }

/* ---------- Table column widths (transferring) ---------- */
.col-progress { width: 220px; }
.col-transfer-file { width: 320px; }
.col-transfer-eta { width: 110px; }
.col-transfer-speed { width: 130px; }
.col-transfer-size { width: 110px; }
.col-transfer-route { width: 360px; }

.run-detail-transferring-table {
    table-layout: fixed;
}

.run-detail-transferring-table td[data-scrollable-cell],
.run-detail-transferring-table th[data-scrollable-cell] {
    max-width: 0;
}

/* ---------- Dashboard allowance bar ---------- */
.allowance-bar-wrapper {
    min-width: 240px;
}

/* ---------- Unified data table styling ---------- */

.table.data-table {
    margin-bottom: 0;
    color: var(--app-shell-fg);
}

.table.data-table thead th {
    border-bottom: 1px solid var(--app-table-head-border);
    background: var(--app-table-head-bg);
    color: var(--app-table-head-fg);
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-weight: 600;
    vertical-align: middle;
    white-space: nowrap;
}

.table.data-table tbody tr {
    border-color: var(--app-border);
}

.table.data-table tbody tr:hover {
    background: var(--app-row-hover-bg);
}

.table.data-table td,
.table.data-table th {
    border-color: var(--app-border);
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    vertical-align: middle;
}

.table.data-table .table-sort {
    color: inherit;
    font-weight: inherit;
    font-size: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
}

.table.data-table .table-sort:hover,
.table.data-table .table-sort:focus {
    color: var(--app-link-hover);
}

.table.data-table .badge {
    border: 1px solid var(--app-badge-border);
}

.data-table td[data-scrollable-cell],
.data-table th[data-scrollable-cell] {
    max-width: 0;
}

.table-cell-scroll {
    display: block;
    max-width: min(28rem, 45vw);
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scrollbar-width: thin;
    padding-bottom: 0.125rem;
}

.table-cell-scroll--wide {
    max-width: min(36rem, 60vw);
}

.table-cell-scroll code,
.table-cell-scroll small,
.table-cell-scroll span {
    white-space: inherit;
}

.worker-copy-button {
    min-width: 2rem;
    line-height: 1;
}

.worker-copy-button.is-copied {
    border-color: var(--bs-success);
    color: var(--bs-success);
}

@media (max-width: 991.98px) {
    body {
        overflow: auto;
        height: auto;
        min-height: 100vh;
    }
    .app-shell {
        display: block !important;
        height: auto !important;
        min-height: 100vh;
    }
    .content-area {
        height: auto;
        min-height: 100vh;
        overflow-y: visible;
    }
    .content-shell {
        padding: 1rem;
    }
    .page-header {
        margin-bottom: 0.75rem;
    }
    .page-action-box {
        width: 100%;
        justify-content: space-between;
    }
    .page-action-box-group {
        width: 100%;
        justify-content: flex-end;
    }
    .sidebar-job-name {
        max-width: 100%;
    }
}

@media (max-width: 767.98px) {
    h1, h2 {
        font-size: 1.4rem;
    }
    .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    .mobile-list-row {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }
    .mobile-list-main {
        min-width: 0;
    }
    .page-action-box {
        padding: 0.75rem;
    }
    .page-action-box-group {
        justify-content: stretch;
    }
    .page-action-box-group > .btn,
    .page-action-box-group > a {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 130px;
    }
    .mobile-list-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        justify-content: flex-start !important;
        width: 100%;
    }
    .mobile-list-actions > .btn,
    .mobile-list-actions > .btn-group,
    .mobile-list-actions form,
    .mobile-list-actions > a {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 130px;
    }
    .mobile-list-actions .btn,
    .mobile-list-actions .btn-group > .btn {
        width: 100%;
    }
    .mobile-list-item small {
        font-size: 0.8rem;
        line-height: 1.35;
        overflow-wrap: anywhere;
    }
    .btn-group.flex-wrap {
        display: flex !important;
        width: 100%;
        gap: 0.5rem;
    }
    .btn-group.flex-wrap > .btn {
        flex: 1 1 auto;
    }
}
