/* Layout and look of IMS_task, on top of the theme (assets/css/styles.css: Metronic / KTUI) and the
   Telerik Bootstrap theme. Taken over from IMS_rtms so both applications look and work alike. */

:root {
    --kendo-font-family: var(--font-sans);
    /* Hover colour (Metronic's --accent): light blue, a dark blue in dark mode. */
    --accent: var(--color-blue-100);
}

html.dark {
    --accent: var(--color-blue-950);
    /* The browser's own parts (scrollbars, native inputs) are drawn dark too. */
    color-scheme: dark;
}

h1:focus {
    outline: none;
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

/* ---------- Shell (MainLayout) ---------- */

/* The content box keeps the window's height at every width, so its scroll area (.page-scroller) scrolls the page
   (<body> is overflow: hidden). */
.page-box {
    min-height: 0;
}

/* The logo in the header: the app icon and the name (assets/media/logo). */
.app-brand {
    color: var(--foreground);
    text-decoration: none;
}

.app-brand-logo {
    width: 30px;
    height: 30px;
    border-radius: 7px;
}

.app-brand .brand-wordmark {
    font-size: 1.15rem;
}

/* "IMS Tasks" as in the logo: IMS bold, Tasks light. Used in the header, on the home page and the sign-in page. */
.brand-wordmark {
    font-weight: 400;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.brand-wordmark strong {
    font-weight: 800;
    letter-spacing: 0.02em;
}

/* Page fill (desktop): the content area is a flex column as tall as the screen and <main> fills it. An element
   marked .fill takes the height left over by the elements around it (every element between <main> and it must be
   .fill too). GridArea is .fill, so a grid takes the rest of the page (grid.css, .grid-fit). */
@media (min-width: 1024px) {
    .page-scroller {
        display: flex;
        flex-direction: column;
    }

    .page-scroller > main,
    .fill {
        display: flex;
        flex-direction: column;
        flex: 1 0 auto;
    }

    .k-tabstrip.fill > .k-tabstrip-content.k-active {
        display: flex !important;
        flex-direction: column;
        flex: 1 0 auto;
    }
}

/* Collapsible sidebar: the toggle button adds .sidebar-collapsed to #sidebar (desktop only). */
#sidebar {
    transition: width 0.3s ease;
}

.sidebar-toggle-icon {
    transition: transform 0.3s ease;
}

@media (min-width: 1024px) {
    #sidebar.sidebar-collapsed {
        width: 4.25rem;
    }

    #sidebar.sidebar-collapsed .sidebar-title,
    #sidebar.sidebar-collapsed .sidebar-group-title,
    #sidebar.sidebar-collapsed .sidebar-menu-text {
        display: none;
    }

    #sidebar.sidebar-collapsed .sidebar-top {
        justify-content: center;
        padding-inline: 0;
    }

    #sidebar.sidebar-collapsed .kt-accordion-menu-link {
        justify-content: center;
    }

    #sidebar.sidebar-collapsed .sidebar-submenu {
        display: none;
    }

    #sidebar.sidebar-collapsed .sidebar-toggle-icon {
        transform: rotate(180deg);
    }
}

@media (max-width: 1023.98px) {
    .sidebar-toggle {
        display: none;
    }
}

/* The user's name and role in the header. */
.header-user {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.15;
}

.header-user-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--foreground);
}

.header-user-role {
    font-size: 0.6875rem;
    color: var(--muted-foreground);
}

/* KTToast messages: below the header, not on top of it (each toast is placed against the window). */
.kt-toast.kt-toast-top-end,
.kt-toast.kt-toast-top-center,
.kt-toast.kt-toast-top-start {
    margin-top: calc(var(--header-height, 54px) - 0.5rem);
}

/* ---------- Pages ---------- */

/* A list page's title line: the title, and the user's rights on the page at the right. */
.page-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.page-title h1 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--foreground);
}

.permission-summary {
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

.page-note {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-block: 0.5rem;
}

.page-loading {
    position: relative;
    min-height: 12rem;
}

.access-denied {
    max-width: 520px;
    margin-top: 1rem;
}

.access-denied h1 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

/* An error that stops a page from loading (e.g. the record was not found). */
.page-error {
    margin-bottom: 1rem;
    padding: 0.75rem;
    border: 1px solid color-mix(in srgb, var(--destructive) 40%, transparent);
    border-radius: 0.5rem;
    background: color-mix(in srgb, var(--destructive) 8%, transparent);
    color: var(--destructive);
    font-size: 0.875rem;
}

/* ---------- Record pages (CompanyDetails, UserDetails, ...) ----------
   The Save / Save and Close / Close bar at the top (.details-toolbar), and a tab's form groups side by side in as
   many columns as fit (.details-layout). */
.details-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    margin-block-end: 1rem;
    padding-block-end: 0.4rem;
    border-bottom: 1px solid var(--border);
}

/* The record's name at the right end of the toolbar. */
.details-title {
    margin-inline-start: auto;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--foreground);
}

.details-title small {
    margin-inline-start: 0.4rem;
    font-weight: 400;
    color: var(--muted-foreground);
}

.details-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
    gap: 2rem;
    align-items: start;
}

.details-layout .k-form .k-form-fieldset {
    margin-block-start: 0.2rem;
}

.details-layout .k-form .k-form-field {
    margin-block: 0 0.2rem;
}

.details-layout .k-form .k-form-field .k-label,
.details-layout .k-form .k-form-label {
    margin-block-end: 0;
}

/* A tab's form groups flow into the empty space, top to bottom in each column (TelerikForm Columns="N" becomes N
   text columns and each group stays whole in one column), when there are more groups than columns. */
@media (min-width: 1025px) {
    .details-layout .k-form > .k-form-layout:is(
        .k-grid-cols-2:has(> :nth-child(3)),
        .k-grid-cols-3:has(> :nth-child(4))) {
        display: block;
        column-count: 2;
        column-gap: 2rem;
    }

    .details-layout .k-form > .k-form-layout.k-grid-cols-3:has(> :nth-child(4)) {
        column-count: 3;
    }
}

@media (min-width: 768px) {
    .details-layout .k-form > .k-form-layout > * {
        break-inside: avoid;
    }

    .details-layout .k-form > .k-form-layout:has(> :nth-child(3)) > * {
        margin-block: 0 1rem;
    }
}

/* A short explanation under a field. */
.field-hint {
    font-size: 0.7rem;
    color: var(--muted-foreground);
}

.k-tabstrip-content, .k-tabstrip > .k-content {
    margin: 0 !important;
    padding-block: var(--kendo-spacing-2);
    box-sizing: border-box;
    border-width: 1px;
    border-style: solid;
    border-color: transparent;
    display: none;
    overflow: auto;
    flex: 1 1 auto;
    position: relative;
}

/* A busy icon: put icon-spin on an icon while something runs. */
.icon-spin {
    display: inline-block;
    animation: icon-spin 1s linear infinite;
}

@keyframes icon-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .icon-spin { animation: none; }
}

/* ---------- Customer: the rows of the Addresses / E-mails / Phones / Websites tabs ---------- */
.customer-rows-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.75rem;
    max-width: 80rem;
}

.customer-row {
    max-width: 80rem;
    padding: 0.75rem 0.75rem 0.5rem;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--background);
}

.customer-row-fields {
    display: grid;
    gap: 0.25rem 1rem;
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .customer-row-fields.cols-3 { grid-template-columns: 12rem 1fr 1fr; }
    .customer-row-fields.cols-4 { grid-template-columns: repeat(4, 1fr); }
}

.customer-row-fields .k-form-field {
    margin-block: 0 0.25rem;
}

.customer-row-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.25rem;
    padding-top: 0.4rem;
    border-top: 1px dashed var(--border);
}

.customer-row-actions .k-form-field {
    margin: 0;
}

.customer-row-checks {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* A contact who is no longer at the customer. */
.customer-row.inactive {
    background: var(--muted);
}

.customer-row.inactive .customer-row-fields {
    opacity: 0.65;
}

/* ---------- Customer: the Comments tab (CustomerComments) ---------- */
.comments {
    max-width: 80rem;
}

.comments-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.5rem;
}

.comment-card {
    margin-bottom: 0.75rem;
    padding: 0.85rem 1rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--background);
}

.comment-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.comment-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 2.1rem;
    height: 2.1rem;
    border-radius: 50%;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
}

.comment-author {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--foreground);
}

.comment-collapse {
    margin-inline-start: auto;
}

.comment-body {
    margin: 0.6rem 0 0.25rem 0.1rem;
    font-size: 0.875rem;
    overflow-wrap: anywhere;
}

/* The comment's own formatting (lists, headings, links) inside the page's styles. */
.comment-body p { margin: 0 0 0.4rem; }
.comment-body ul { list-style: disc; padding-inline-start: 1.5rem; margin: 0 0 0.4rem; }
.comment-body ol { list-style: decimal; padding-inline-start: 1.5rem; margin: 0 0 0.4rem; }
.comment-body h1 { font-size: 1.4rem; font-weight: 600; }
.comment-body h2 { font-size: 1.2rem; font-weight: 600; }
.comment-body h3 { font-size: 1.05rem; font-weight: 600; }
.comment-body a { color: var(--primary); text-decoration: underline; }
.comment-body blockquote { border-inline-start: 3px solid var(--border); padding-inline-start: 0.75rem; color: var(--muted-foreground); }

.comment-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 1.75rem;
}

.comment-date {
    font-size: 0.7rem;
    color: var(--muted-foreground);
}

.comment-tools {
    display: flex;
    gap: 0.1rem;
}

.comment-editor {
    margin-top: 0.5rem;
}

.comment-new {
    margin-top: 1.25rem;
}

.comment-actions {
    display: flex;
    gap: 0.5rem;
    margin: 0.6rem 0 0.4rem;
}

/* ---------- Administration > Change log: every field of one change ---------- */
.changelog-details td {
    overflow-wrap: anywhere;
}

/* The details dialog scrolls inside the window when an entry has many fields. */
.changelog-dialog .k-dialog-content {
    max-height: 70vh;
    overflow-y: auto;
}

.changelog-details td:first-child {
    width: 9rem;
    font-weight: 500;
}

/* ---------- Administration > Lists: the list picker at the left, the grid at the right ---------- */
.lists-layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (min-width: 1024px) {
    .lists-layout.fill {
        flex-direction: row;
        align-items: stretch;
    }

    .lists-nav {
        flex: 0 0 13rem;
    }

    .lists-main.fill {
        flex: 1 1 0;
        min-width: 0;
    }
}

.lists-nav {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    font-size: 0.8125rem;
}

.lists-nav-group {
    margin: 0.6rem 0 0.2rem;
    padding-inline: 0.6rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted-foreground);
}

.lists-nav-group:first-child {
    margin-top: 0;
}

.lists-nav-item {
    padding: 0.35rem 0.6rem;
    border-radius: 0.375rem;
    color: var(--foreground);
    text-decoration: none;
}

.lists-nav-item:hover {
    background: var(--accent);
}

.lists-nav-item.active {
    background: var(--primary);
    color: var(--primary-foreground);
    font-weight: 500;
}

/* ---------- Grid: the Columns popup (GridArea) ---------- */
.columns-list {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    max-height: 18rem;
    overflow-y: auto;
}

.columns-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.2rem 0.25rem;
    border-radius: 0.25rem;
    font-size: 0.8125rem;
    cursor: pointer;
}

.columns-item:hover {
    background: var(--accent);
}

/* ---------- Home page: the menu as cards ---------- */
.menu-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
    gap: 0.75rem;
    max-width: 60rem;
}

.menu-category {
    margin-top: 1.5rem;
}

.menu-category-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--secondary-foreground);
}

.home-welcome {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.home-logo {
    width: 56px;
    height: 56px;
    border-radius: 13px;
    box-shadow: 0 4px 14px rgba(6, 18, 102, .25);
}

.home-welcome h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.home-welcome p {
    font-size: 0.8125rem;
    color: var(--muted-foreground);
}

/* ---------- Menu & access ---------- */
.menu-tree .k-treelist tr {
    cursor: pointer;
}

.menu-tree-icon {
    margin-inline-end: 0.4rem;
    color: var(--muted-foreground);
}

/* The Access tab: one row per role or user, the rights as check boxes and the data scope as a drop-down. */
.access-section + .access-section {
    margin-top: 1.5rem;
}

.access-section h3 {
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.access-table {
    width: 100%;
    max-width: 60rem;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.access-table th,
.access-table td {
    padding: 0.3rem 0.5rem;
    border-bottom: 1px solid var(--border);
    text-align: start;
    vertical-align: middle;
}

.access-table th {
    font-weight: 600;
    color: var(--secondary-foreground);
    background: var(--muted);
}

.access-table .center {
    text-align: center;
    width: 4.5rem;
}

.access-table .scope {
    width: 14rem;
}

.access-table .remove {
    width: 2.5rem;
}

.access-table tr.no-access td:not(:first-child) {
    opacity: 0.55;
}

.access-add {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    margin-top: 0.6rem;
    max-width: 30rem;
}

.access-add > :first-child {
    flex: 1;
}

.access-add .k-form-field {
    margin-block-end: 0;
}
