/* =====================================================================
   SphereWMS QuickBooks Middleware - Admin Theme (Bootstrap 5)
   Replaces the old Metronic-on-BS3 chrome.
   ===================================================================== */

:root {
    /* --- Official SphereWMS brand palette (sphere_brand_style_guide.html) --- */
    --sphere-dark: #1D3557;        /* Sphere Dark Blue - headers, sidebar, dark surfaces */
    --sphere-dark-2: #16293f;      /* darker variant for hover/active on dark */
    --sphere-cyan: #38B6CC;        /* Signature accent - buttons, links, accent line */
    --sphere-deep-cyan: #2A9AB5;   /* hover / darker cyan */
    --sphere-lime: #C5D82E;        /* secondary CTA accent */
    --sphere-light-gray: #F7F8FA;  /* surfaces / card backgrounds */
    --sphere-cyan-tint: #EDF8FA;   /* highlight-card background */
    --sphere-muted: #8294b2;       /* muted brand text */

    /* Semantic aliases (kept so existing rules below keep working) */
    --sphere-primary: var(--sphere-dark);
    --sphere-primary-dark: var(--sphere-dark-2);
    --sphere-primary-light: #2e547e;
    --sphere-accent: var(--sphere-cyan);
    --sphere-sidebar-bg: var(--sphere-dark);
    --sphere-sidebar-hover: #25456b;
    --sphere-sidebar-active: var(--sphere-cyan);
    --sphere-sidebar-text: #cdd8e6;
    --sphere-body-bg: var(--sphere-light-gray);
    --sphere-card-border: #e5e9ef;
    --sphere-text-muted: #6b7a8f;

    /* Functional colors (brand guide) */
    --sphere-success: #196B24;
    --sphere-danger: #C62828;
    --sphere-warning: #E97132;

    --sphere-sidebar-width: 240px;
    --sphere-topbar-height: 60px;
    --sphere-accent-line: 4px;     /* signature cyan underline thickness */

    /* Re-point Bootstrap's primary + link colors to brand cyan (kills the
       generic blue Bootstrap ships with — the style guide forbids it) */
    --bs-primary: #38B6CC;
    --bs-primary-rgb: 56, 182, 204;
    --bs-link-color: #2A9AB5;
    --bs-link-color-rgb: 42, 154, 181;
    --bs-link-hover-color: #1D3557;
}

/* ---------- Body & base ---------- */
body {
    background-color: var(--sphere-body-bg);
    font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont,
        Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #333;
    padding-top: var(--sphere-topbar-height);
}

a {
    color: var(--sphere-accent);
    text-decoration: none;
}
a:hover {
    color: var(--sphere-primary);
    text-decoration: underline;
}

/* ---------- Topbar ---------- */
.sphere-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--sphere-topbar-height);
    background-color: #fff;
    /* Signature SphereWMS motif: 4px cyan accent line under the header */
    border-bottom: var(--sphere-accent-line) solid var(--sphere-cyan);
    box-shadow: 0 1px 4px rgba(15, 30, 50, 0.04);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    z-index: 1030;
}

.sphere-topbar .logo-default1 {
    height: 38px;
    width: auto;
}

.sphere-topbar .sphere-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: var(--sphere-sidebar-width);
    padding-left: 0.25rem;
}

.sphere-topbar .sphere-topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sphere-topbar .username {
    font-weight: 600;
    color: var(--sphere-primary);
}

.sphere-topbar .dropdown-toggle::after {
    margin-left: 0.5rem;
}

/* Sidebar toggle button (mobile) */
.sphere-sidebar-toggle {
    border: none;
    background: transparent;
    color: var(--sphere-primary);
    font-size: 1.25rem;
    margin-right: 0.5rem;
    display: none;
}

@media (max-width: 991.98px) {
    .sphere-sidebar-toggle {
        display: inline-flex;
    }
    .sphere-topbar .sphere-brand {
        width: auto;
    }
}

/* ---------- Sidebar ---------- */
.sphere-sidebar {
    position: fixed;
    top: var(--sphere-topbar-height);
    bottom: 0;
    left: 0;
    width: var(--sphere-sidebar-width);
    background-color: var(--sphere-sidebar-bg);
    overflow-y: auto;
    padding: 1rem 0;
    z-index: 1020;
    transition: transform 0.2s ease;
}

.sphere-sidebar .nav-link {
    color: var(--sphere-sidebar-text);
    padding: 0.65rem 1.25rem;
    border-radius: 0;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.95rem;
    border-left: 3px solid transparent;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.sphere-sidebar .nav-link i {
    width: 18px;
    text-align: center;
    opacity: 0.9;
}

.sphere-sidebar .nav-link:hover {
    background-color: var(--sphere-sidebar-hover);
    color: #fff;
    text-decoration: none;
}

.sphere-sidebar .nav-link.active,
.sphere-sidebar .nav-link[aria-current="page"] {
    background-color: var(--sphere-sidebar-hover);
    color: #fff;
    border-left-color: var(--sphere-accent);
}

.sphere-sidebar .nav-link.disabled,
.sphere-sidebar .nav-link[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

@media (max-width: 991.98px) {
    .sphere-sidebar {
        transform: translateX(-100%);
    }
    .sphere-sidebar.show {
        transform: translateX(0);
    }
}

/* ---------- Main content area ---------- */
.sphere-main {
    margin-left: var(--sphere-sidebar-width);
    padding: 1.5rem;
    min-height: calc(100vh - var(--sphere-topbar-height));
}

@media (max-width: 991.98px) {
    .sphere-main {
        margin-left: 0;
    }
}

/* ---------- Page header / breadcrumbs ---------- */
.page-bar {
    margin-bottom: 1.25rem;
}

.page-breadcrumb {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    font-size: 0.88rem;
    color: var(--sphere-text-muted);
}

.page-breadcrumb > li {
    display: flex;
    align-items: center;
}

.page-breadcrumb > li + li::before {
    content: "/";
    margin: 0 0.5rem;
    color: var(--sphere-text-muted);
    opacity: 0.6;
}

.page-breadcrumb > li > a {
    color: var(--sphere-text-muted);
}
.page-breadcrumb > li > a:hover {
    color: var(--sphere-primary);
}

.page-breadcrumb > li > span {
    color: var(--sphere-primary);
    font-weight: 600;
}

.page-breadcrumb > li .fa-circle {
    display: none; /* legacy separator from old theme */
}

/* ---------- Cards (replaces .portlet) ---------- */
.card {
    border: 1px solid var(--sphere-card-border);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(15, 30, 50, 0.03);
    margin-bottom: 1.25rem;
}

.card-header {
    background-color: #fff;
    /* Subtle echo of the signature cyan accent line under each card header */
    border-bottom: 2px solid var(--sphere-cyan);
    padding: 0.85rem 1.1rem;
    border-radius: 8px 8px 0 0 !important;
}

.card-header .caption-subject {
    font-weight: 700;
    color: var(--sphere-dark);
    letter-spacing: 0.02em;
}

.card-header i {
    color: var(--sphere-cyan);
    margin-right: 0.45rem;
}

.card-body {
    padding: 1.1rem;
}

/* Back-compat: .portlet -> styled like card */
.portlet {
    background: #fff;
    border: 1px solid var(--sphere-card-border);
    border-radius: 8px;
    margin-bottom: 1.25rem;
    box-shadow: 0 1px 3px rgba(15, 30, 50, 0.03);
    overflow: hidden;
}
.portlet-title {
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid var(--sphere-card-border);
}
.portlet-title .caption {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 600;
    color: var(--sphere-primary);
}
.portlet-title .caption-subject {
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 0.95rem;
}
.portlet-body {
    padding: 1.1rem;
}

/* ---------- Buttons ---------- */
.btn {
    border-radius: 6px;
    font-weight: 500;
    padding: 0.45rem 1rem;
    transition: all 0.15s ease;
}

.btn-primary,
.btn-success,
.btn-danger,
.btn-info,
.btn-warning {
    color: #fff;
}

/* Primary CTA = signature Sphere Cyan */
.btn-primary {
    background-color: var(--sphere-cyan);
    border-color: var(--sphere-cyan);
    color: #fff;
}
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background-color: var(--sphere-deep-cyan) !important;
    border-color: var(--sphere-deep-cyan) !important;
    color: #fff;
}

/* Secondary CTA = Sphere Lime (dark text — lime is too light for white text) */
.btn-lime {
    background-color: var(--sphere-lime);
    border-color: var(--sphere-lime);
    color: var(--sphere-dark);
    font-weight: 600;
}
.btn-lime:hover { filter: brightness(0.94); color: var(--sphere-dark); }

/* Align Bootstrap functional colors to the brand palette */
.btn-success { background-color: var(--sphere-success); border-color: var(--sphere-success); }
.btn-success:hover { background-color: #14541c; border-color: #14541c; }
.btn-danger  { background-color: var(--sphere-danger);  border-color: var(--sphere-danger); }
.btn-warning { background-color: var(--sphere-warning); border-color: var(--sphere-warning); color: #fff; }

/* Outline-dark pills use brand Sphere Dark, fill on hover */
.btn-outline-dark {
    border-color: var(--sphere-dark);
    color: var(--sphere-dark);
}
.btn-outline-dark:hover,
.btn-outline-dark:focus,
.btn-outline-dark:active {
    background-color: var(--sphere-dark) !important;
    border-color: var(--sphere-dark) !important;
    color: #fff;
}

/* Map legacy classes to BS5 equivalents */
.btn.btn-circle { border-radius: 999px; }
.btn.dark {
    background-color: var(--sphere-dark);
    border-color: var(--sphere-dark);
    color: #fff;
}
.btn.dark:hover {
    background-color: var(--sphere-dark-2);
    border-color: var(--sphere-dark-2);
    color: #fff;
}
.btn.btn-outline.dark,
.btn.dark.btn-outline {
    background-color: transparent;
    border: 1px solid var(--sphere-dark);
    color: var(--sphere-dark);
}
.btn.btn-outline.dark:hover,
.btn.dark.btn-outline:hover {
    background-color: var(--sphere-dark);
    color: #fff;
}
/* Legacy ".green" is this app's primary submit/login CTA -> signature cyan */
.btn.green {
    background-color: var(--sphere-cyan);
    border-color: var(--sphere-cyan);
    color: #fff;
}
.btn.green:hover {
    background-color: var(--sphere-deep-cyan);
    border-color: var(--sphere-deep-cyan);
    color: #fff;
}
.btn.uppercase { text-transform: uppercase; letter-spacing: 0.03em; }
.btn.default { background-color: #e9eef4; border: 1px solid #d6dde6; color: var(--sphere-dark); }
.btn.default:hover { background-color: #d6dde6; }

/* ---------- Forms ---------- */
.form-control,
.form-select {
    border: 1px solid #d6dde6;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--sphere-cyan);
    box-shadow: 0 0 0 0.2rem rgba(56, 182, 204, 0.22);
}

.form-label,
.control-label {
    font-weight: 600;
    color: #2a3b51;
    margin-bottom: 0.35rem;
}

label.error {
    color: var(--sphere-danger);
    font-weight: 500;
    font-size: 0.85rem;
    margin-top: 0.25rem;
    display: block;
}

.red {
    border: 1px solid var(--sphere-danger);
    color: var(--sphere-danger);
}

/* legacy form-horizontal helpers */
.form-horizontal .control-label {
    text-align: right;
    padding-top: 0.5rem;
}
@media (max-width: 767.98px) {
    .form-horizontal .control-label {
        text-align: left;
    }
}

/* ---------- Tables ---------- */
.table {
    background-color: #fff;
    border-radius: 6px;
    overflow: hidden;
}

.table > thead {
    background-color: #f3f5f8;
}

.table > thead th {
    font-weight: 600;
    color: var(--sphere-primary);
    text-transform: uppercase;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    border-bottom: 2px solid var(--sphere-card-border);
}

.cursor-pointer { cursor: pointer; }

/* DataTables BS5 tweaks */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #d6dde6;
    border-radius: 6px;
    padding: 0.35rem 0.5rem;
}

div.dataTables_wrapper div.dataTables_filter input {
    margin-left: 0.5rem;
}

/* Pagination: brand the active page + hover/links to Sphere Cyan
   (Bootstrap defaults to its generic blue --bs-primary) */
.page-link {
    color: var(--sphere-dark);
}
.page-link:hover {
    color: var(--sphere-deep-cyan);
    background-color: var(--sphere-cyan-tint);
}
.page-link:focus {
    box-shadow: 0 0 0 0.2rem rgba(56, 182, 204, 0.25);
    color: var(--sphere-deep-cyan);
}
.page-item.active .page-link {
    background-color: var(--sphere-cyan);
    border-color: var(--sphere-cyan);
    color: #fff;
}

/* ---------- Modals ---------- */
.modal-header {
    border-bottom: 1px solid var(--sphere-card-border);
    background-color: #fff;
    border-radius: 8px 8px 0 0;
}
.modal-title {
    font-weight: 600;
    color: var(--sphere-primary);
}
.modal-content {
    border-radius: 8px;
    border: 1px solid var(--sphere-card-border);
}

/* ---------- Loader ---------- */
.loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: url(../img/BogusEmptyBrontosaurus-size_restricted.gif) center
        no-repeat rgba(1, 1, 1, 0.51);
}

/* ---------- Notifications ---------- */
#notification,
#notification_error,
#notificationErr,
#message,
#message_error {
    position: fixed;
    top: calc(var(--sphere-topbar-height) + 8px);
    right: 1rem;
    z-index: 9999;
    min-width: 260px;
    max-width: 360px;
    padding: 0.85rem 1.1rem;
    font-weight: 600;
    color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 18px rgba(15, 30, 50, 0.18);
    text-align: center;
}

#notification,
#message {
    background-color: var(--sphere-success);
}

#notification_error,
#notificationErr,
#message_error {
    background-color: var(--sphere-danger);
}

/* ---------- Select2 (BS5 theme) ---------- */
.select2-container { width: 100% !important; }

.select2-container--bootstrap-5 .select2-selection {
    border: 1px solid #d6dde6 !important;
    border-radius: 6px !important;
    min-height: calc(1.5em + 1rem + 2px);
}

/* ---------- Legacy color helpers ---------- */
.font-red    { color: var(--sphere-danger) !important; }
.font-green  { color: var(--sphere-success) !important; }
.font-dark   { color: var(--sphere-primary) !important; }
.font-blue   { color: var(--sphere-accent) !important; }
.bold        { font-weight: 700; }
.sbold       { font-weight: 600; }
.uppercase   { text-transform: uppercase; letter-spacing: 0.03em; }

/* ---------- Login page ---------- */
body.login {
    background: linear-gradient(135deg, var(--sphere-dark) 0%, var(--sphere-cyan) 100%);
    min-height: 100vh;
    padding-top: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.login .content {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
    margin: 1rem;
}

body.login .login-logo {
    display: block;
    margin: 0 auto 1.25rem;
    width: 180px;
}

body.login .form-title {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--sphere-primary);
    font-weight: 700;
}

body.login .form-actions {
    text-align: center;
    margin-top: 1.25rem;
}

body.login .form-control {
    padding: 0.65rem 0.85rem;
}

body.login #result,
body.login #result_error {
    position: fixed;
    top: 20px;
    right: 20px;
    left: auto;
    width: auto;
    min-width: 260px;
    max-width: 360px;
    padding: 1rem 1.25rem;
    font-weight: 600;
    color: #fff;
    border-radius: 8px;
    z-index: 9999;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
    text-align: center;
}
body.login #result { background-color: var(--sphere-success); }
body.login #result_error { background-color: var(--sphere-danger); }

/* ---------- Misc legacy ---------- */
.savebtn { float: right; margin-right: 10px; }
.page-content-wrapper, .page-content, .page-container { width: 100%; }
