/* Colours are taken from the Gemini Group of Companies logo: the red of the
   cube, the black of the lettering and the grey of the cube's side. Red on
   buttons and links is a shade darker than the logo's so white text on it
   stays readable. */
:root {
    --brand-red: #e72e2e;
    --brand-red-strong: #d92626;
    --brand-red-dark: #b81f1f;
    --brand-black: #231f20;
    --brand-grey: #a7a9ac;

    /* Inter, loaded from assets/vendor by head_assets(); the rest is what
       shows if that is missing. */
    --bs-font-sans-serif: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

    --bs-primary: #d92626;
    --bs-primary-rgb: 217, 38, 38;
    --bs-link-color: #b81f1f;
    --bs-link-color-rgb: 184, 31, 31;
    --bs-link-hover-color: #8f1818;
    --bs-link-hover-color-rgb: 143, 24, 24;
    --bs-focus-ring-color: rgba(231, 46, 46, .25);
}

body {
    background: #f3f3f4;
    letter-spacing: -.01em;
}

/* Links are told apart by colour, never by an underline. */
a,
a:hover,
.btn-link,
.btn-link:hover {
    text-decoration: none;
}

/* ---- Sidebar menu ------------------------------------------------------
   Fixed on the left. On a desktop the toggle folds it to icons only (the
   choice is kept in a cookie); below 992px it slides in over the page. */
:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 72px;
    --topbar-height: 64px;
}

.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    background: #000;
    box-shadow: 2px 0 8px rgba(0, 0, 0, .18);
    transition: width .2s ease, transform .2s ease;
}

/* Keep the logo on white so its lettering and transparent areas stay clear. */
.sidebar-brand {
    flex-shrink: 0;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px 0 16px;
    background: #fff;
    border-bottom: 3px solid var(--brand-red);
}

.sidebar-brand img {
    display: block;
    flex: 0 0 56px;
    width: 56px;
    height: 56px;
    object-fit: contain;
}

.sidebar-toggle-btn,
.topbar-burger {
    padding: 6px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: #6b6b6f;
    font-size: 1.25rem;
    line-height: 1;
}

.sidebar-toggle-btn:hover,
.topbar-burger:hover {
    color: var(--brand-black);
    background: #ececed;
}

.sidebar-nav {
    flex: 1 1 auto;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 12px 10px 16px;
}

.sidebar-section-label {
    padding: 16px 12px 6px;
    color: rgba(255, 255, 255, .5);
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 2px;
    padding: 9px 12px;
    border-radius: 6px;
    color: rgba(255, 255, 255, .85);
    font-size: .9375rem;
    text-decoration: none;
    white-space: nowrap;
}

.sidebar-link i {
    flex-shrink: 0;
    width: 1.25rem;
    font-size: 1.1rem;
    text-align: center;
}

.sidebar-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, .08);
}

.sidebar-link.active {
    color: #fff;
    background: var(--brand-red-strong);
}

/* A sub-menu: the row that opens it, and its items set in from the left. */
.sidebar-link .sidebar-caret {
    width: auto;
    margin-left: auto;
    font-size: .75rem;
    transition: transform .2s ease;
}

.sidebar-group-toggle.collapsed .sidebar-caret {
    transform: rotate(-90deg);
}

.sidebar-group-toggle[aria-expanded="true"] {
    color: #fff;
}

.sidebar-sub .sidebar-link {
    padding-left: 28px;
    font-size: .875rem;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1035;
    background: rgba(0, 0, 0, .45);
}

.main-area {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    transition: margin-left .2s ease;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    flex-shrink: 0;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: 0 1.25rem;
    background: #fff;
    border-bottom: 1px solid #e3e3e5;
}

.topbar-brand {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    color: var(--brand-black);
    font-weight: 600;
    text-decoration: none;
}

.topbar-logo {
    display: block;
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: .5rem;
    color: var(--brand-black);
    line-height: 1.2;
    text-decoration: none;
}

.topbar-user > i {
    color: var(--brand-grey);
    font-size: 1.75rem;
}

@media (min-width: 992px) {
    .sidebar-collapsed .sidebar {
        width: var(--sidebar-collapsed-width);
    }

    .sidebar-collapsed .main-area {
        margin-left: var(--sidebar-collapsed-width);
    }

    .sidebar-collapsed .sidebar-brand {
        justify-content: center;
        padding: 0;
    }

    .sidebar-collapsed .sidebar-brand a,
    .sidebar-collapsed .sidebar-link span,
    .sidebar-collapsed .sidebar-section-label span {
        display: none;
    }

    /* A section title becomes a rule between the groups of icons. */
    .sidebar-collapsed .sidebar-section-label {
        margin: 8px 8px;
        padding: 0;
        border-top: 1px solid rgba(255, 255, 255, .15);
    }

    .sidebar-collapsed .sidebar-link {
        justify-content: center;
        padding: 10px 0;
    }

    /* Folded, there is no room to open a sub-menu: its items are always
       shown, as icons like the rest. */
    .sidebar-collapsed .sidebar-group-toggle {
        display: none;
    }

    .sidebar-collapsed .sidebar-sub {
        display: block !important;
        height: auto !important;
    }
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }

    .sidebar-open .sidebar {
        transform: none;
        box-shadow: 2px 0 8px rgba(0, 0, 0, .18);
    }

    .sidebar-open .sidebar-backdrop {
        display: block;
    }

    .main-area {
        margin-left: 0;
    }
}

.dropdown-menu {
    --bs-dropdown-link-active-bg: var(--brand-black);
}

/* The main action on a page is red; secondary actions are black outlines,
   which keeps them apart from the red outline of a destructive one. */
.btn-primary {
    --bs-btn-bg: var(--brand-red-strong);
    --bs-btn-border-color: var(--brand-red-strong);
    --bs-btn-hover-bg: var(--brand-red-dark);
    --bs-btn-hover-border-color: var(--brand-red-dark);
    --bs-btn-active-bg: #a31b1b;
    --bs-btn-active-border-color: #a31b1b;
    --bs-btn-disabled-bg: var(--brand-red-strong);
    --bs-btn-disabled-border-color: var(--brand-red-strong);
    --bs-btn-focus-shadow-rgb: 231, 46, 46;
}

.btn-outline-primary {
    --bs-btn-color: var(--brand-black);
    --bs-btn-border-color: var(--brand-black);
    --bs-btn-hover-bg: var(--brand-black);
    --bs-btn-hover-border-color: var(--brand-black);
    --bs-btn-active-bg: var(--brand-black);
    --bs-btn-active-border-color: var(--brand-black);
    --bs-btn-disabled-color: var(--brand-black);
    --bs-btn-disabled-border-color: var(--brand-black);
    --bs-btn-focus-shadow-rgb: 35, 31, 32;
}

.text-bg-primary {
    background-color: var(--brand-black) !important;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    border-color: #f1a3a3;
    box-shadow: 0 0 0 .25rem rgba(231, 46, 46, .2);
}

.form-check-input:checked {
    background-color: var(--brand-red-strong);
    border-color: var(--brand-red-strong);
}

.pagination {
    --bs-pagination-color: var(--brand-black);
    --bs-pagination-hover-color: var(--brand-red-dark);
    --bs-pagination-focus-color: var(--brand-red-dark);
    --bs-pagination-focus-box-shadow: 0 0 0 .25rem rgba(231, 46, 46, .2);
}

/* The tab strip across the top of System Settings. */
.settings-tabs .nav-link {
    color: #55555a;
    font-weight: 500;
}

.settings-tabs .nav-link:hover {
    color: var(--brand-black);
}

.settings-tabs .nav-link.active {
    color: var(--brand-red-dark);
    border-top: 3px solid var(--brand-red);
}

.card {
    border: 0;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .08);
}

.table > :not(caption) > * > * {
    vertical-align: middle;
}

.brand-icon {
    color: var(--brand-red);
}

.app-tile {
    color: inherit;
    text-decoration: none;
    transition: transform .12s ease, box-shadow .12s ease;
}

.app-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(16, 24, 40, .12);
}

/* A long role name wraps inside the tile instead of running out of it. */
.app-tile .badge {
    max-width: 100%;
    line-height: 1.3;
    text-align: left;
    white-space: normal;
}

.app-tile .app-icon {
    font-size: 2rem;
    color: var(--brand-red);
}

/* A card holding one record's form: not stretched across a wide screen. */
.form-card {
    max-width: 820px;
}

.setting-number {
    max-width: 10rem;
}

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* The logo straddles the sign-in card edge just below the square motif. */
.login-card {
    --login-logo-half: 92px;
    width: 100%;
    max-width: 400px;
    margin-top: var(--login-logo-half);
}

.login-logo {
    width: 260px;
    max-width: 100%;
    height: auto;
    margin-top: calc(-1.5rem - var(--login-logo-half));
}

/* The current logo on the settings page, on the white it is shown against. */
.logo-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 220px;
    height: 110px;
    padding: 12px;
    border: 1px solid #e3e3e5;
    border-radius: 6px;
    background: #fff;
}

.logo-preview img {
    max-width: 100%;
    max-height: 100%;
}

code.perm {
    color: var(--brand-black);
    background: #ececed;
    padding: .1rem .35rem;
    border-radius: .25rem;
}
