/*
 * Dashboard shell: sidebar, top bar, cards.
 * Colours, fonts and radius come from theme.css tokens only. Do not add colour values here.
 */

:root {
    --op-sidebar-width: 272px;
    --op-sidebar-collapsed-width: 88px;
    --op-gap: 12px;
    --op-nav-height: 40px;
    --op-icon-size: 20px;
    --op-transition: 0.2s ease;
}

/* ---------- Base ---------- */

.op-app {
    background-color: var(--op-canvas);
    color: var(--op-text);
    font-size: 0.9375rem;
}

.op-icon {
    width: var(--op-icon-size);
    height: var(--op-icon-size);
    flex-shrink: 0;
    fill: currentColor;
}

.op-card {
    background-color: var(--op-surface-raised);
    border-radius: var(--op-radius);
    box-shadow: var(--op-shadow);
}

.op-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    padding: 0;
    color: var(--op-text-muted);
    background-color: var(--op-surface-raised);
    border: 1px solid var(--op-border);
    border-radius: var(--op-radius);
    box-shadow: var(--op-shadow);
    transition: color var(--op-transition), background-color var(--op-transition);
}

.op-icon-btn:hover {
    color: var(--op-text);
    background-color: var(--op-surface-muted);
}

.op-icon-btn:focus-visible,
.op-nav-link:focus-visible,
.op-nav-group-toggle:focus-visible,
.op-theme-toggle button:focus-visible,
.op-user-toggle:focus-visible,
.op-brand:focus-visible {
    outline: none;
    box-shadow: var(--op-focus-ring);
}

.op-skip-link {
    position: absolute;
    top: var(--op-gap);
    left: var(--op-gap);
    z-index: 1100;
    padding: 8px 16px;
    color: var(--op-text-on-primary);
    background-color: var(--op-primary);
    border-radius: var(--op-radius);
}

/* ---------- Shell ---------- */

.op-shell {
    display: flex;
    min-height: 100vh;
}

.op-main {
    flex: 1;
    min-width: 0;
    padding: 0 24px 24px;
}

.op-content:focus {
    outline: none;
}

/* ---------- Sidebar ---------- */

.op-sidebar .offcanvas-body {
    display: flex;
    flex-direction: column;
    gap: var(--op-gap);
}

@media (min-width: 992px) {
    .op-sidebar {
        position: sticky;
        top: 0;
        width: var(--op-sidebar-width);
        height: 100vh;
        flex-shrink: 0;
        transition: width var(--op-transition);
    }

    .op-sidebar .offcanvas-body {
        height: 100%;
        padding: 16px 0 16px 16px;
        overflow-y: auto;
        scrollbar-width: thin;
    }
}

@media (max-width: 991.98px) {
    .op-sidebar {
        --bs-offcanvas-width: 288px;
    }

    .op-sidebar .offcanvas-body {
        padding: 12px;
    }

    .op-main {
        padding: 0 16px 16px;
    }
}

.op-sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.op-sidebar-spacer {
    flex: 1 0 0;
}

/* Brand. The current logo is a 1080x318 JPEG with whitespace, so it is cropped with CSS.
   Replace these crop values when OncoPharm supplies an SVG. */
.op-brand {
    --op-logo-natural-width: 1080;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    height: 64px;
    padding: 0 16px;
    overflow: hidden;
    background-color: var(--op-logo-plate);
}

.op-brand-full,
.op-brand-mark {
    position: relative;
    display: block;
    overflow: hidden;
    flex-shrink: 0;
}

.op-brand img {
    position: absolute;
    max-width: none;
    height: auto;
}

/* Full logo: source region x 70-950, y 50-275 (880 x 225) shown 44px tall. */
.op-brand-full {
    width: 172px;
    height: 44px;
}

.op-brand-full img {
    width: 211px;
    left: -13.7px;
    top: -9.8px;
}

/* Symbol only: source region x 74-274, y 62-262 (200 x 200) shown 36px square. */
.op-brand-mark {
    display: none;
    width: 36px;
    height: 36px;
}

.op-brand-mark img {
    width: 194.4px;
    left: -13.3px;
    top: -11.2px;
}

/* Navigation groups */
.op-nav-group {
    padding: 8px;
}

.op-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.op-nav-link,
.op-nav-group-toggle {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    height: var(--op-nav-height);
    padding: 0 12px;
    color: var(--op-nav-text);
    font: inherit;
    font-size: 0.875rem;
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
    background: none;
    border: 0;
    border-radius: var(--op-radius);
    transition: color var(--op-transition), background-color var(--op-transition);
}

.op-nav-link .op-icon,
.op-nav-group-toggle .op-icon {
    color: var(--op-nav-icon);
}

.op-nav-link:hover,
.op-nav-group-toggle:hover {
    color: var(--op-text);
    background-color: var(--op-nav-hover-bg);
}

.op-nav-link.active {
    color: var(--op-nav-active-text);
    font-weight: 500;
    background-color: var(--op-nav-active-bg);
}

.op-nav-link.active .op-icon {
    color: var(--op-nav-active-text);
}

.op-nav-link.active::before {
    content: "";
    position: absolute;
    top: 8px;
    bottom: 8px;
    left: -8px;
    width: 3px;
    background-color: var(--op-nav-active-indicator);
    border-radius: var(--op-radius-sm);
}

.op-nav-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.op-nav-group-toggle {
    font-weight: 500;
}

.op-nav-group-chevron {
    width: 16px;
    height: 16px;
    transition: transform var(--op-transition);
}

.op-nav-group-toggle.collapsed .op-nav-group-chevron {
    transform: rotate(-90deg);
}

.op-nav-group-toggle + .op-nav {
    margin-top: 2px;
}

.op-badge {
    min-width: 22px;
    padding: 1px 6px;
    color: var(--op-badge-text);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.5;
    text-align: center;
    background-color: var(--op-badge-bg);
    border-radius: var(--op-radius-sm);
}

/* Theme toggle */
.op-theme-toggle {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    padding: 4px;
    background-color: var(--op-toggle-bg);
    border-radius: var(--op-radius);
}

.op-theme-toggle button {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 36px;
    padding: 0 8px;
    color: var(--op-text-muted);
    font: inherit;
    font-size: 0.875rem;
    background: none;
    border: 0;
    border-radius: var(--op-radius);
    transition: color var(--op-transition), background-color var(--op-transition);
}

.op-theme-toggle button .op-icon {
    width: 18px;
    height: 18px;
}

.op-theme-toggle button[aria-pressed="true"] {
    color: var(--op-text);
    font-weight: 500;
    background-color: var(--op-toggle-active-bg);
    box-shadow: var(--op-shadow);
}

.op-theme-toggle .op-nav-label {
    flex: 0 1 auto;
}

/* User card */
.op-user {
    padding: 8px;
}

.op-user-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 4px;
    color: var(--op-text);
    font: inherit;
    text-align: left;
    background: none;
    border: 0;
    border-radius: var(--op-radius);
}

.op-user-toggle:hover {
    background-color: var(--op-nav-hover-bg);
}

.op-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    color: var(--op-nav-active-text);
    font-size: 0.875rem;
    font-weight: 600;
    background-color: var(--op-nav-active-bg);
    border-radius: var(--op-radius);
}

.op-user-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
    line-height: 1.3;
}

.op-user-name {
    overflow: hidden;
    font-size: 0.875rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.op-user-email {
    overflow: hidden;
    color: var(--op-text-muted);
    font-size: 0.75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.op-user-more {
    color: var(--op-text-muted);
}

.op-user .dropdown-menu {
    --bs-dropdown-font-size: 0.875rem;
    min-width: 220px;
}

/* ---------- Collapsed sidebar (desktop only) ---------- */

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

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

    .op-sidebar-collapsed .op-brand-full {
        display: none;
    }

    .op-sidebar-collapsed .op-brand-mark {
        display: block;
    }

    /* Labels stay in the accessibility tree; tooltips show them visually. */
    .op-sidebar-collapsed .op-nav-label,
    .op-sidebar-collapsed .op-user-text {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .op-sidebar-collapsed .op-nav-link,
    .op-sidebar-collapsed .op-nav-group-toggle {
        justify-content: center;
        padding: 0;
    }

    /* Group headers are not needed as icons; show every item in the group. */
    .op-sidebar-collapsed .op-nav-group-toggle {
        display: none;
    }

    .op-sidebar-collapsed .op-nav-group .op-nav.collapse {
        display: flex;
        margin-top: 0;
    }

    .op-sidebar-collapsed .op-badge {
        position: absolute;
        top: 6px;
        right: 10px;
        width: 8px;
        min-width: 0;
        height: 8px;
        padding: 0;
        overflow: hidden;
        color: transparent;
        background-color: var(--op-accent);
        border-radius: 50%;
    }

    .op-sidebar-collapsed .op-theme-toggle {
        flex-direction: column;
    }

    .op-sidebar-collapsed .op-theme-toggle button {
        flex: 0 0 36px;
    }

    .op-sidebar-collapsed .op-user-toggle {
        justify-content: center;
    }

    .op-sidebar-collapsed .op-user-more {
        display: none;
    }

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

/* ---------- Top bar ---------- */

.op-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    gap: var(--op-gap);
    margin: 0 -24px var(--op-gap);
    padding: 16px 24px;
    background-color: var(--op-glass-bg);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

.op-sidebar-toggle .op-icon {
    transition: transform var(--op-transition);
}

.op-page-title {
    flex: 1;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    font-size: 1.625rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.op-search {
    position: relative;
    display: flex;
    align-items: center;
    flex: 0 1 300px;
    min-width: 0;
}

.op-search .op-icon {
    position: absolute;
    left: 12px;
    width: 18px;
    height: 18px;
    color: var(--op-text-muted);
    pointer-events: none;
}

.op-search input {
    width: 100%;
    height: 40px;
    padding: 0 12px 0 40px;
    color: var(--op-text);
    font: inherit;
    font-size: 0.875rem;
    background-color: var(--op-surface-raised);
    border: 1px solid var(--op-border);
    border-radius: var(--op-radius);
    box-shadow: var(--op-shadow);
}

.op-search input::placeholder {
    color: var(--op-text-subtle);
}

.op-search input:focus {
    border-color: var(--op-focus-border);
    outline: none;
    box-shadow: var(--op-focus-ring);
}

@media (max-width: 991.98px) {
    .op-topbar {
        margin: 0 -16px var(--op-gap);
        padding: 12px 16px;
    }

    .op-page-title {
        font-size: 1.25rem;
    }
}

@media (max-width: 575.98px) {
    .op-search {
        flex-basis: 40px;
    }

    .op-search input {
        padding-right: 0;
        cursor: pointer;
    }

    .op-search input:focus {
        position: absolute;
        right: 0;
        width: calc(100vw - 32px);
        padding-right: 12px;
        cursor: text;
    }
}

/* ---------- Content panels ---------- */

.op-panel {
    padding: 20px;
}

.op-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.op-panel-title {
    flex: 1;
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
}

.op-muted {
    color: var(--op-text-muted);
}

.op-stat-placeholder {
    color: var(--op-text-subtle);
    font-size: 2rem;
    font-weight: 500;
    line-height: 1.2;
}

/* ---------- Sign-in and account pages ---------- */

.op-auth-main {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px 16px;
}

.op-auth-panel {
    display: flex;
    flex-direction: column;
    gap: var(--op-gap);
    width: 100%;
    max-width: 420px;
}

.op-auth-brand {
    flex: 0 0 auto;
    justify-content: center;
}

.op-auth-title {
    margin-bottom: 16px;
    font-size: 1.375rem;
    font-weight: 600;
}

.op-auth-footer {
    margin: 0;
    font-size: 0.8125rem;
    text-align: center;
}

.op-dev-signin {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px dashed var(--op-border-strong);
}

.form-control,
.form-select,
.form-control:focus,
.form-select:focus {
    color: var(--op-text);
    background-color: var(--op-surface-raised);
}

.form-control,
.form-select {
    border-color: var(--op-border-strong);
}

/* Server-side validation summary: a plain message, not a bulleted list. */
.validation-summary-errors ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.validation-summary-valid {
    display: none;
}

/* ---------- Data tables and status ---------- */

.op-table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--op-text);
    --bs-table-border-color: var(--op-border);
    margin-bottom: 0;
    font-size: 0.875rem;
}

.op-table th {
    color: var(--op-text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.op-table td,
.op-table th {
    padding: 10px 12px;
    vertical-align: middle;
}

/* Sortable headings (SortHeaderTagHelper): look like the heading, not a link. */
.op-sort-link {
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.op-sort-link:hover,
.op-sort-link:focus-visible {
    color: var(--op-text);
    text-decoration: underline;
}

.op-table-search .form-control {
    max-width: 320px;
}

.op-status {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--op-radius-sm);
}

.op-status-active {
    color: var(--op-positive);
    background-color: var(--op-surface-muted);
}

.op-status-invited {
    color: var(--op-badge-text);
    background-color: var(--op-badge-bg);
}

.op-status-suspended,
.op-status-locked {
    color: var(--op-negative);
    background-color: var(--op-surface-muted);
}

.op-recovery-codes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 16px;
    font-family: var(--bs-font-monospace);
    background-color: var(--op-surface-muted);
    border-radius: var(--op-radius);
}

.op-form-panel {
    max-width: 640px;
}

.op-mfa-form {
    max-width: 320px;
}

.op-qr {
    width: 200px;
    height: 200px;
    padding: 8px;
    background-color: var(--op-logo-plate);
    border-radius: var(--op-radius);
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: reduce) {
    .op-sidebar,
    .op-icon-btn,
    .op-nav-link,
    .op-nav-group-toggle,
    .op-nav-group-chevron,
    .op-theme-toggle button,
    .op-sidebar-toggle .op-icon {
        transition: none;
    }
}
