/* ===== ui-module.css - shared UI design system (MudBlazor-native) =====
   Linked from Areas/Blazor/App.razor as the LAST stylesheet in <head>, after the
   inline <style> block, so these rules win the cascade for shared class names.
   Scope: only .ui-* and .u-* selectors. No Bootstrap dependency.
   Used by every admin-side area (Todo, Admin, dashboards, module info drawers).
   Razor views MUST NOT add their own <style> blocks - keep styles centralized here. */

/* ===== Page rhythm ===== */
.ui-page {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 0;
}

.ui-stack {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 0;
}

/* ===== Page header ===== */
.ui-page-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    min-width: 0;
}

.ui-page-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.35;
}

.ui-page-subtitle {
    margin: .15rem 0 0;
    font-size: .8rem;
    color: #64748b;
}

.ui-page-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    margin-left: auto;
}

/* ===== Shared back button (Create/Edit/Detail headers) ===== */
.u-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #64748b;
    text-decoration: none;
    transition: background-color .15s, border-color .15s, color .15s;
}

.u-back-btn:hover {
    background: #eef2ff;
    border-color: #4f46e5;
    color: #4f46e5;
}

.u-back-btn:focus-visible {
    outline: 2px solid #4f46e5;
    outline-offset: 2px;
}

/* ===== Panels ===== */
.ui-panel {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
    overflow: hidden;
    min-width: 0;
}

.ui-panel-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #f1f5f9;
    flex-wrap: wrap;
}

.ui-panel-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: 0;
    font-size: .95rem;
    font-weight: 600;
    color: #1e293b;
}

.ui-panel-title .mud-icon-root {
    color: #4f46e5;
}

.ui-panel-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    margin-left: auto;
}

.ui-panel-body {
    padding: 1.5rem;
    min-width: 0;
}

/* ===== Centered page states (success / deleted / error) ===== */
.ui-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.ui-state-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.ui-state-icon.success {
    background: #ecfdf5;
}

.ui-state-icon.error {
    background: #fef2f2;
}

.ui-state-title {
    margin: 0 0 .5rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: #1e293b;
}

.ui-state-text {
    margin: 0 0 1.5rem;
    font-size: .85rem;
    color: #64748b;
}

/* ===== Toolbar (search row) ===== */
.ui-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.ui-search {
    width: 100%;
    max-width: 360px;   /* was 420px */
}

/* ===== Plain tables (.ui-table) ===== */
.ui-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.ui-table thead th {
    background: #f8fafc;
    color: #475569;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: .75rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
    text-align: left;
}

.ui-table tbody td {
    padding: .8rem 1rem;
    font-size: .875rem;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.ui-table tbody tr {
    transition: background-color .12s;
}

.ui-table tbody tr:hover {
    background: #f8fafc;
}

.ui-table tbody tr:last-child td {
    border-bottom: none;
}

.ui-table th.u-text-center,
.ui-table td.u-text-center {
    text-align: center;
}

.ui-table th.u-text-end,
.ui-table td.u-text-end {
    text-align: right;
}

.ui-table tfoot td {
    padding: .75rem 1rem;
    font-size: .85rem;
    color: #64748b;
    border-top: 1px solid #e2e8f0;
}

/* ===== MudDataGrid chrome (.ui-grid) ===== */
.ui-grid.mud-table {
    background: transparent;
}

.ui-grid .mud-table-container {
    border-radius: 0;
}

.ui-grid .mud-table-head .mud-table-cell {
    background: #f8fafc;
    color: #475569;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: .75rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}

.ui-grid .mud-table-body .mud-table-cell {
    padding: .8rem 1rem;
    font-size: .875rem;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
}

.ui-grid .mud-table-body .mud-table-row {
    min-height: 52px;
}

.ui-grid.mud-table-hover .mud-table-container .mud-table-root .mud-table-body .mud-table-row:hover {
    background-color: #f8fafc;
}

.ui-grid .mud-table-row.ui-row-selected > .mud-table-cell,
.ui-grid .mud-table-row.ui-row-selected:hover > .mud-table-cell {
    background-color: #eef2ff !important;
}

.ui-grid .mud-table-pagination-toolbar {
    border-top: 1px solid #f1f5f9;
    padding: 0 .5rem 0 0;
    min-height: 52px;
}

.ui-grid .mud-select .mud-input-control {
    margin-top: 0;
}

.ui-grid .mud-icon-button {
    color: #4f46e5;
}

/* ===== Grid helper columns =====
   Auto table layout hands every column a share of the leftover width, which
   pushed the row actions far away from the checkbox. width:1% shrinks these
   columns to their content (nowrap) so the data columns absorb the rest. */
.ui-grid .ui-col-shrink,
.ui-table .ui-col-shrink {
    width: 1%;
    white-space: nowrap;
}

/* ===== Chips (MudChip + .ui-chip) ===== */
.mud-chip.ui-chip {
    margin: 0;
    height: 24px;
    border-radius: 6px;
    font-weight: 600;
}

.ui-chip .mud-chip-content {
    gap: .25rem;
}

.ui-chip .mud-icon-root {
    font-size: 12px;
}

.ui-chip-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
    margin-top: .5rem;
}

/* ===== Progress (MudProgressLinear + .ui-progress) ===== */
.ui-progress {
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 100%;
    min-width: 0;
}

.ui-progress-track {
    flex: 1;
    min-width: 48px;
}

.ui-progress-track,
.ui-progress-track::before,
.ui-progress-track .mud-progress-linear-bars,
.ui-progress-track .mud-progress-linear-bar {
    border-radius: 999px;
}

.ui-progress-track.mud-progress-linear-color-default:not(.mud-progress-linear-buffer)::before {
    background-color: #f1f5f9;
    opacity: 1;
}

.ui-progress-track .mud-progress-linear-bar {
    background-color: var(--ui-progress-color) !important;
}

.ui-progress-label {
    font-weight: 600;
    white-space: nowrap;
}

/* ===== Forms ===== */
.ui-field-label {
    margin-bottom: .35rem;
    font-size: .8rem;
    font-weight: 500;
    color: #475569;
}

.ui-ticks {
    display: flex;
    justify-content: space-between;
    margin-top: .25rem;
    font-size: .72rem;
    color: #94a3b8;
}

.ui-help-text {
    margin-top: .25rem;
    font-size: .72rem;
    color: #94a3b8;
}

/* ===== Progress slider: match Detail bar (8px, ProgressBar Height="8") =====
   The form slider (MudSlider Size.Large) ships with a 6px track/fill; these
   rules thicken it to 8px so Edit/Create match the Detail page's bar. */
.mud-slider.ui-progress-slider .mud-slider-filled { height: 8px; }
.mud-slider.ui-progress-slider .mud-slider-input::-webkit-slider-runnable-track { height: 8px; }
.mud-slider.ui-progress-slider .mud-slider-input::-moz-range-track { height: 8px; }

.ui-category-card {
    height: 100%;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    padding: 1.25rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background-color .15s;
}

.ui-category-card:hover {
    border-color: #c7d2fe;
}

.ui-category-card.selected {
    border-color: #4f46e5;
    background: #f5f3ff;
}

.ui-category-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #eef2ff;
    color: #4f46e5;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto .6rem;
}

.ui-category-name {
    font-size: .875rem;
    font-weight: 600;
    color: #1e293b;
}

.ui-category-desc {
    margin-top: .15rem;
    font-size: .75rem;
    color: #64748b;
}

/* ===== Items editor (quick add block) ===== */
.ui-quick-add {
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.ui-quick-add-title {
    font-size: .8rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: .5rem;
}

/* ===== KPI tiles ===== */
.ui-stat-card {
    height: 100%;
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
    padding: 1.25rem;
}

.ui-stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ui-stat-label {
    margin: 0;
    font-size: .75rem;
    color: #64748b;
}

.ui-stat-value {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
    color: #1e293b;
}

.ui-stat-sub {
    margin: 0;
    font-size: .72rem;
    color: #94a3b8;
}

/* ===== Charts ===== */
.ui-chart {
    width: 100%;
    height: 320px;
    min-width: 0;
}

/* ===== Attachments ===== */
.ui-upload-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    background: #f8fafc;
    padding: 2rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background-color .15s;
}

.ui-upload-zone:hover,
.ui-upload-zone.dragging {
    border-color: #4f46e5;
    background: #eef2ff;
}

.ui-upload-icon {
    color: #64748b;
}

.ui-upload-title {
    font-size: .85rem;
    font-weight: 600;
    color: #1e293b;
}

.ui-upload-hint {
    margin-top: .15rem;
    font-size: .75rem;
    color: #64748b;
}

.ui-thumb-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: 1rem;
}

.ui-thumb {
    position: relative;
    width: 96px;
    height: 96px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
}

.ui-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: zoom-in;
}

.ui-thumb-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, .65);
    color: #fff;
    font-size: .65rem;
    padding: 2px 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ui-thumb-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 2;
}

.ui-file-list {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin-top: 1rem;
}

.ui-file-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: .75rem 1rem;
    background: #fff;
    transition: background-color .15s;
}

.ui-file-row:hover {
    background: #f8fafc;
}

.ui-file-icon {
    color: #64748b;
    flex-shrink: 0;
}

.ui-file-name {
    flex: 1;
    min-width: 0;
    font-size: .85rem;
    font-weight: 500;
    color: #1e293b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ui-muted-note {
    margin-top: 1rem;
    font-size: .8rem;
    color: #94a3b8;
}

/* ===== Dashboard recent table bits ===== */
.ui-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    padding: 0 .4rem;
    border-radius: 999px;
    background: #eef2ff;
    color: #4f46e5;
    font-weight: 600;
    font-size: .75rem;
}

.ui-badge-overdue {
    display: inline-flex;
    align-items: center;
    margin-left: .35rem;
    padding: .1rem .45rem;
    border-radius: 6px;
    background: #fef2f2;
    color: #dc2626;
    font-weight: 600;
    font-size: .68rem;
}

.ui-owner {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    min-width: 0;
}

.ui-owner-initial {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #eef2ff;
    color: #4f46e5;
    font-weight: 600;
    font-size: .7rem;
    flex-shrink: 0;
}

.ui-category-cell {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}

.ui-category-cell .mud-icon-root {
    color: #4f46e5;
    font-size: 14px;
}

.ui-recent-title {
    font-weight: 600;
    color: #1e293b;
}

.ui-recent-sub {
    font-size: .72rem;
    color: #64748b;
}

.ui-overdue-date {
    color: #dc2626;
    font-weight: 600;
}

/* ===== Empty states ===== */
.ui-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: #64748b;
    font-size: .85rem;
}

.ui-empty .mud-icon-root {
    display: block;
    margin: 0 auto .5rem;
    font-size: 32px;
    color: #cbd5e1;
}

.ui-empty-title {
    margin: 0 0 .25rem;
    font-size: .9rem;
    font-weight: 600;
    color: #1e293b;
}

.ui-empty-text {
    margin: 0;
    font-size: .8rem;
    color: #64748b;
}

/* ===== Module info drawer ===== */
.ui-module-info {
    font-size: .85rem;
    color: #64748b;
    line-height: 1.7;
}

.ui-module-info p {
    margin: 0 0 .85rem;
}

.ui-module-info h6 {
    margin: 1.25rem 0 .5rem;
    font-size: .8rem;
    font-weight: 600;
    color: #1e293b;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.ui-module-info ul {
    margin: 0 0 .85rem;
    padding-left: 1.1rem;
}

.ui-module-info li {
    margin-bottom: .35rem;
}

.ui-module-info strong,
.ui-module-info em {
    color: #1e293b;
}

.ui-info-table {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: .85rem;
}

.ui-info-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: .8rem;
}

.ui-info-table td {
    padding: .6rem .75rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: top;
    line-height: 1.6;
}

.ui-info-table tr:last-child td {
    border-bottom: none;
}

.ui-info-table td:first-child {
    width: 130px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
}

/* ===== Action bar / helpers ===== */
.ui-action-bar {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}

.u-text-center {
    text-align: center !important;
}

.u-text-end {
    text-align: right !important;
}

.u-text-muted {
    color: #64748b !important;
}

.u-text-nowrap {
    white-space: nowrap !important;
}

.u-fw-600 {
    font-weight: 600 !important;
}

.u-w-100 {
    width: 100% !important;
}

.u-table-wrap {
    overflow-x: auto;
}

.u-mb-0 {
    margin-bottom: 0 !important;
}

/* ===== Smaller icons (follow-up correction) ===== */
.ui-panel-title .mud-icon-root { font-size: 18px; }
.ui-panel-actions .mud-icon-button .mud-icon-root { font-size: 16px; }
.ui-action-icon .mud-icon-root { font-size: 16px; }
.ui-table .mud-icon-button .mud-icon-root { font-size: 16px; }
.ui-file-row .mud-icon-button .mud-icon-root { font-size: 16px; }
.ui-quick-add .mud-icon-button .mud-icon-root { font-size: 18px; }
.ui-category-icon .mud-icon-root { font-size: 20px; }
.ui-stat-icon .mud-icon-root { font-size: 22px; }
.ui-upload-icon { font-size: 24px; }
.ui-empty .mud-icon-root { font-size: 28px; }

/* ===== Actions header alignment (round 3 correction) =====
   HeaderCell renders the title inside .column-header, which MudBlazor styles as
   display:flex; justify-content:space-between, so text-align on the th has no
   effect. Center the flex content so the header follows the centered row icons. */
.ui-grid .mud-table-head .ui-actions-header { text-align: center; }
.ui-grid .mud-table-head .ui-actions-header .column-header { justify-content: center; }

/* ===== Hand cursor: whole grid + horizontal scrollbar (round 5) =====
   Requirement: hovering the data table area - rows through the horizontal
   scrollbar - must show the hand cursor. Chromium always shows the arrow over
   scrollbar areas (verified on Chrome 154: even a ::-webkit-styled bar with
   cursor:pointer on the element AND on the scrollbar pseudo-elements keeps the
   arrow), so the bar is replaced with a real DOM bar rendered by
   wwwroot/js/blazor/grid-hscroll.js, whose elements do honour cursor:pointer.
   The first rule puts the hand on every grid descendant; the part rules below
   are the no-JS fallback for the native bar. */
.ui-grid.mud-table,
.ui-grid.mud-table * { cursor: pointer; }

.ui-grid.mud-table::-webkit-scrollbar,
.ui-grid.mud-table .mud-table-container::-webkit-scrollbar,
.ui-grid.mud-table .mud-table-pagination::-webkit-scrollbar,
.u-table-wrap::-webkit-scrollbar { height: 6px; width: 6px; cursor: pointer; }
.ui-grid.mud-table::-webkit-scrollbar-track,
.ui-grid.mud-table .mud-table-container::-webkit-scrollbar-track,
.ui-grid.mud-table .mud-table-pagination::-webkit-scrollbar-track,
.u-table-wrap::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 3px; cursor: pointer; }
.ui-grid.mud-table::-webkit-scrollbar-thumb,
.ui-grid.mud-table .mud-table-container::-webkit-scrollbar-thumb,
.ui-grid.mud-table .mud-table-pagination::-webkit-scrollbar-thumb,
.u-table-wrap::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; cursor: pointer; }
.ui-grid.mud-table::-webkit-scrollbar-thumb:hover,
.ui-grid.mud-table .mud-table-container::-webkit-scrollbar-thumb:hover,
.ui-grid.mud-table .mud-table-pagination::-webkit-scrollbar-thumb:hover,
.u-table-wrap::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
.u-table-wrap { cursor: pointer; }
.u-table-wrap table { cursor: default; }

/* DOM replacement bar (grid-hscroll.js): hide only the native horizontal bar,
   keep its 6px strip, and paint the replacement bar with the hand cursor.
   The MudBlazor theme injects `html, body * { scrollbar-color: ...;
   scrollbar-width: thin; }` at runtime, and those standard properties make
   Chromium ignore every ::-webkit-scrollbar rule (that is why no CSS-only
   cursor fix ever worked). scrollbar-width:none removes the native bar for
   real, so the DOM bar below is the only scrollbar left.
   js-hscroll-bar: the single scroller that gets the replacement bar.
   js-hscroll-hide: every other scrollable candidate in the grid. */
.js-hscroll-bar { padding-bottom: 6px; }
.js-hscroll-bar,
.js-hscroll-hide { scrollbar-width: none; }
.js-hscroll-bar::-webkit-scrollbar:horizontal,
.js-hscroll-hide::-webkit-scrollbar:horizontal { display: none; height: 0; }
.grid-hscroll-track {
    position: fixed;
    display: none;
    height: 6px;
    background: #f1f5f9;
    border-radius: 3px;
    cursor: pointer;
    z-index: 500;
    user-select: none;
    touch-action: none;
}
.grid-hscroll-thumb {
    position: absolute;
    top: 0;
    left: 0;
    height: 6px;
    background: #cbd5e1;
    border-radius: 3px;
    cursor: pointer;
}
.grid-hscroll-thumb:hover { background: #94a3b8; }

/* ===== AI Chat input + send button (admin routes have no Bootstrap) ===== */
.ui-chat-input {
    flex: 1;
    min-width: 0;
    font-family: inherit;
    font-size: .875rem;
    color: #1e293b;
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: .6rem 1rem;
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}

.ui-chat-input::placeholder { color: #94a3b8; }

.ui-chat-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .1);
    outline: none; /* suppress the default black UA focus ring */
}

.ui-chat-input:disabled {
    background: #f8fafc;
    color: #94a3b8;
    cursor: not-allowed;
}

.ui-chat-send { font-family: inherit; cursor: pointer; color: #fff; }
.ui-chat-send:focus { outline: none; }
.ui-chat-send:focus-visible { outline: 2px solid #4f46e5; outline-offset: 2px; }
.ui-chat-send:disabled { cursor: not-allowed; }
