/*
  OBMS Shell + Component Styles
  All colors reference obms-brand.css variables.
*/

@font-face {
    font-family: 'Public Sans';
    src: url('/fonts/PublicSans-Regular.ttf') format('truetype');
    font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Public Sans';
    src: url('/fonts/PublicSans-Medium.ttf') format('truetype');
    font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Public Sans';
    src: url('/fonts/PublicSans-SemiBold.ttf') format('truetype');
    font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Public Sans';
    src: url('/fonts/PublicSans-Bold.ttf') format('truetype');
    font-weight: 700; font-style: normal; font-display: swap;
}

html { font-size: 14px; }
@media (min-width: 768px) { html { font-size: 16px; } }
html, body { height: 100%; }

/* Base */
.obms-body {
    background: var(--surface-page);
    color: var(--text-primary);
    font-family: 'Public Sans', system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", Arial, sans-serif;
}

/* Layout */
.obms-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: 280px 1fr;
}

.obms-shell--no-sidebar {
    grid-template-columns: 1fr;
}

/* Sidebar */
.obms-sidebar {
    background: var(--surface-sidebar);
    color: var(--text-primary);
    padding: 8px 18px 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border-right: 1px solid var(--border-default);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

[dir="rtl"] .obms-sidebar {
    border-right: none;
    border-left: 1px solid var(--border-default);
}

.obms-sidebar__brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-lg);
    background: transparent;
    border: none;
}

.obms-sidebar__brand h5 {
    margin: 0;
    font-weight: 800;
    font-size: 16px;
    color: var(--brand-heading);
}

.obms-sidebar__logo {
    max-width: 100%;
    height: auto;
    max-height: 48px;
    object-fit: contain;
}

.obms-sidebar__brand small,
.brand-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
}

.obms-sidebar__section-title {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 6px 8px 10px;
}

/* Navigation */
.obms-nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-primary);
    border: 1px solid transparent;
    transition: all .15s var(--ease-out);
    cursor: pointer;
    background: none;
    width: 100%;
    text-align: start;
}

.obms-nav-link:hover {
    background: var(--surface-page);
    border-color: var(--border-default);
    transform: translateY(-1px);
}

.obms-nav-link.active {
    background: var(--brand-primary-soft);
    border-color: var(--brand-primary-strong);
    color: var(--brand-primary);
}

.obms-nav-link.active::before {
    content: "";
    position: absolute;
    left: 6px;
    top: 10px;
    bottom: 10px;
    width: 3px;
    border-radius: 999px;
    background: var(--brand-primary);
}

[dir="rtl"] .obms-nav-link.active::before {
    left: auto;
    right: 6px;
}

.obms-nav-link i {
    font-size: 1.05rem;
    width: 1.25rem;
    text-align: center;
}

.obms-nav-link .bi-chevron-down {
    margin-inline-start: auto;
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.obms-nav-link[aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

/* Child nav links */
.obms-nav-child {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 8px 42px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all .15s var(--ease-out);
}

[dir="rtl"] .obms-nav-child {
    padding: 8px 42px 8px 12px;
}

.obms-nav-child:hover {
    background: var(--surface-page);
    color: var(--brand-primary);
}

.obms-nav-child.active {
    background: var(--brand-primary-soft);
    color: var(--brand-primary);
    font-weight: 600;
}

/* Sidebar Footer */
.obms-sidebar__footer {
    margin-top: auto;
    padding: 12px;
    border-top: 1px solid var(--border-divider);
}

/* Main */
.obms-main {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.obms-topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 14px 18px;
    background: var(--surface-card);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.obms-topbar__subtitle {
    font-size: 12px;
}

/* Search */
.obms-search {
    position: relative;
    width: 280px;
}

.obms-search i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
}

.obms-search input {
    padding-left: 32px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--surface-page);
}

.obms-search input:focus {
    box-shadow: var(--brand-primary-focus);
    border-color: var(--brand-primary-strong);
}

[dir="rtl"] .obms-search i {
    left: auto;
    right: 10px;
}

[dir="rtl"] .obms-search input {
    padding-left: 12px;
    padding-right: 32px;
}

/* Breadcrumbs (topbar) */
.obms-breadcrumb {
    --bs-breadcrumb-divider: '\203A';
    font-size: 12px;
    margin-bottom: 2px;
}

/* Global HTMX progress bar */
#htmx-progress {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    z-index: 2000;
    overflow: hidden;
}

#htmx-progress.active {
    display: block;
}

#htmx-progress::after {
    content: "";
    display: block;
    height: 100%;
    width: 40%;
    background: var(--brand-primary);
    animation: htmx-progress-slide 1s linear infinite;
}

@keyframes htmx-progress-slide {
    from { transform: translateX(-100%); }
    to { transform: translateX(350%); }
}

/* Notification dropdown */
.obms-notif-menu {
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
}

@media (max-width: 480px) {
    .obms-notif-menu {
        width: calc(100vw - 24px);
    }
}

/* Notification dot */
.obms-badge-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--brand-danger);
    border: 2px solid var(--surface-card);
}

.notification-dot {
    position: relative;
}

.notification-dot::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 4px;
    width: 7px;
    height: 7px;
    background: var(--brand-danger);
    border-radius: 50%;
    border: 1.5px solid var(--surface-card);
}

/* Cards — bouncy hover effect */
.obms-card {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    background: var(--surface-card);
    transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out);
}

.obms-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* A transformed ancestor becomes the containing block for a position:fixed
   Bootstrap modal, mis-positioning and flickering it. Skip the lift for cards
   that contain a modal so the modal stays anchored to the viewport. */
.obms-card:has(.modal):hover {
    transform: none;
}

.obms-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.obms-card-header__title {
    font-weight: 700;
    font-size: 16px;
    color: var(--brand-heading);
    line-height: 1.3;
}

.obms-card-header__subtitle {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Pad table edges inside cards so first/last columns aren't glued to the border */
.obms-card .table > :is(thead, tbody) > tr > :is(th, td):first-child {
    padding-left: 20px;
}

.obms-card .table > :is(thead, tbody) > tr > :is(th, td):last-child {
    padding-right: 20px;
}

.obms-icon-chip {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: var(--brand-primary-soft);
    border: 1px solid var(--brand-primary-border);
    color: var(--brand-primary-hover);
    font-size: 20px;
}

/* Progress */
.obms-mini-progress {
    height: 10px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.obms-mini-progress__bar {
    height: 100%;
    background: var(--brand-primary);
}

/* Ranked horizontal bar list (magnitude across clients/categories) */
.obms-barlist {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px 20px 20px;
}

.obms-barlist__row {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.obms-barlist__head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}

.obms-barlist__name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
}

.obms-barlist__name:hover {
    text-decoration: underline;
}

.obms-barlist__count {
    margin-inline-start: auto;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.obms-barlist__value {
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Tasks */
.obms-task {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.03);
    border: 1px solid var(--border-subtle);
}

/* Page Header */
.obms-page-header {
    background: var(--surface-card);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.obms-page-header__text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.obms-page-header__title {
    font-weight: 700;
    font-size: 18px;
    color: var(--brand-heading);
    line-height: 1.2;
}

.obms-page-header__subtitle {
    font-weight: 400;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Page Tabs */
.obms-tabs {
    background: var(--surface-card);
    border-bottom: 1px solid var(--border-default);
    padding: 0 20px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
}

.obms-tabs .nav-link {
    height: 40px;
    padding: 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    background: transparent;
    white-space: nowrap;
}

.obms-tabs .nav-link:hover {
    color: var(--brand-primary);
    border-bottom-color: var(--brand-primary-soft);
}

.obms-tabs .nav-link.active {
    color: var(--brand-primary);
    border-bottom-color: var(--brand-primary);
    background: transparent;
}

/* Avatar */
.avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 700;
    background: var(--avatar-bg);
    color: var(--avatar-text);
    flex-shrink: 0;
}

.avatar-circle-sm {
    width: 28px;
    height: 28px;
    font-size: 0.7rem;
}

/* Content + Footer */
.obms-content {
    padding: 18px;
    flex: 1;
}

.obms-footer {
    padding: 14px 18px 20px;
    margin-top: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 14px;
}

.obms-footer__links {
    display: inline-flex;
    gap: 14px;
}

.obms-footer__links a {
    color: var(--text-muted);
    text-decoration: none;
}

.obms-footer__links a:hover {
    text-decoration: underline;
}

.obms-legal {
    max-width: 880px;
    line-height: 1.6;
}

/* TempData alerts */
.obms-alert-container {
    margin-bottom: 1rem;
}

/* Accessibility */
a:focus-visible,
button:focus-visible,
input:focus-visible {
    outline: none;
    box-shadow: var(--brand-primary-focus);
}

/* Responsive */
@media (max-width: 991.98px) {
    .obms-shell {
        grid-template-columns: 1fr;
    }

    .obms-sidebar {
        display: none;
    }

    .obms-search {
        width: 260px;
    }

    .obms-main {
        min-height: 100vh;
    }

    .obms-topbar .btn-sidebar-toggle {
        display: inline-flex !important;
    }
}

@media (min-width: 992px) {
    .obms-topbar .btn-sidebar-toggle {
        display: none !important;
    }
}

.obms-card dl.row dt,
.obms-card dl.row dd { margin-bottom: 0; }

.btn-group > form[style*="display:contents"] > .btn,
.btn-group > form[style*="display: contents"] > .btn {
    border-radius: 0;
}
.btn-group > form[style*="display:contents"]:first-child > .btn,
.btn-group > form[style*="display: contents"]:first-child > .btn {
    border-top-left-radius: var(--bs-btn-border-radius);
    border-bottom-left-radius: var(--bs-btn-border-radius);
}
.btn-group > form[style*="display:contents"]:last-child > .btn,
.btn-group > form[style*="display: contents"]:last-child > .btn {
    border-top-right-radius: var(--bs-btn-border-radius);
    border-bottom-right-radius: var(--bs-btn-border-radius);
}
.btn-group > form[style*="display:contents"] + form[style*="display:contents"] > .btn,
.btn-group > form[style*="display:contents"] + .btn,
.btn-group > .btn + form[style*="display:contents"] > .btn {
    margin-left: calc(var(--bs-border-width) * -1);
}

/* Compact label — pairs with form-control-sm/form-select-sm in filter bars and dense forms */
.form-label-sm {
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--text-secondary);
}

/* Compact alert — for inline contextual banners */
.alert-sm {
    padding: 0.5rem 0.85rem;
    font-size: 0.8125rem;
    margin-bottom: 0.75rem;
}

/* Filter bar divider — replaces ad-hoc inline border-color overrides */
.obms-filter-bar {
    border-bottom: 1px solid var(--border-subtle);
}

/* Empty state — consistent zero-result / first-run block */
.obms-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 44px 20px;
    text-align: center;
    color: var(--text-muted);
}

.obms-empty__icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: var(--brand-primary-soft);
    border: 1px solid var(--brand-primary-border);
    color: var(--brand-primary-hover);
    font-size: 24px;
}

.obms-empty__title {
    font-weight: 600;
    color: var(--text-secondary);
}

.obms-empty__text {
    font-size: 0.875rem;
    max-width: 380px;
    margin: 0;
}

/* Right-align numeric/money table cells */
.text-end-num {
    text-align: end;
    font-variant-numeric: tabular-nums;
}

/* Truncating cell for free-text columns in dense tables */
.cell-truncate {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
