/*
  Desktop-style pages for the browser version: toolbar, table with a selected row, detail panel beside it and the
  right-click menu (rowmenu.js). Same layout as the WPF views (src/CSDentalPro.Desktop/Views). Loaded after
  desktop-theme.css.
*/

.dp-page { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.dp-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.dp-head h2 { margin: 0; font-size: 22px; font-weight: 700; }
.dp-head p { margin: 2px 0 0; color: var(--dp-muted); font-size: 13px; }
.dp-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.dp-toolbar .dp-spacer { flex: 1 1 auto; }
.dp-search { position: relative; flex: 1 1 280px; max-width: 460px; }
.dp-search input { width: 100%; height: 38px; padding: 0 12px 0 34px; border: 1px solid var(--dp-border-strong); border-radius: 10px; background: var(--dp-surface); font-size: 13.5px; }
.dp-search input:focus { outline: none; border-color: var(--dp-primary); box-shadow: 0 0 0 3px rgba(var(--cs-p-rgb), .18); }
.dp-search .glyph { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--dp-muted); }
.dp-field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 600; color: var(--dp-muted); }
.dp-field input, .dp-field select, .dp-toolbar select, .dp-toolbar input[type="date"] { height: 36px; border: 1px solid var(--dp-border-strong); border-radius: 9px; padding: 0 10px; background: var(--dp-surface); font-size: 13.5px; color: var(--dp-text); }
.dp-check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--dp-text); margin: 0; cursor: pointer; white-space: nowrap; }

.dp-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--dp-border-strong); background: var(--dp-surface); color: var(--dp-text); font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer; text-decoration: none; }
.dp-btn:hover:not(:disabled) { background: var(--dp-hover); color: var(--dp-text); }
.dp-btn:disabled { opacity: .45; cursor: default; }
.dp-btn.primary { background: var(--dp-gradient); border-color: transparent; color: #fff; box-shadow: 0 4px 14px rgba(var(--cs-p-rgb), .25); }
.dp-btn.primary:hover:not(:disabled) { background: var(--dp-gradient-hover); color: #fff; }
.dp-btn.danger { color: var(--dp-danger); border-color: #FECDD3; }
.dp-btn.danger:hover:not(:disabled) { background: var(--dp-danger-soft); color: var(--dp-danger); }
.dp-btn .glyph { font-size: 15px; }

.dp-split { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(360px, 1fr); gap: 14px; align-items: start; }
.dp-card { background: var(--dp-surface); border: 1px solid var(--dp-border); border-radius: 14px; box-shadow: var(--dp-shadow-soft); min-width: 0; }
.dp-card-body { padding: 14px 16px; }

.dp-grid-wrap { overflow: auto; max-height: calc(100vh - 300px); min-height: 200px; border-radius: 14px 14px 0 0; }
@supports (height: 100dvh) { .dp-grid-wrap { max-height: calc(100dvh - 300px); } }
table.dp-grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
table.dp-grid thead th { position: sticky; top: 0; z-index: 1; background: var(--dp-surface-alt); color: var(--dp-muted); font-size: 12px; font-weight: 600; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--dp-border); white-space: nowrap; }
table.dp-grid tbody td { padding: 9px 12px; border-bottom: 1px solid var(--dp-border); vertical-align: middle; }
table.dp-grid tbody tr { cursor: pointer; -webkit-user-select: none; user-select: none; }
table.dp-grid tbody tr:hover td { background: var(--dp-hover); }
table.dp-grid tbody tr.selected td { background: var(--dp-selection); }
table.dp-grid tbody tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--dp-primary); }
table.dp-grid .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.dp-grid .nowrap { white-space: nowrap; }
table.dp-grid .muted { color: var(--dp-muted); }
.dp-empty { padding: 28px 16px; text-align: center; color: var(--dp-muted); white-space: pre-line; }
.dp-pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--dp-border); color: var(--dp-muted); font-size: 13px; }
.dp-pager .dp-btn { height: 30px; padding: 0 10px; }

.dp-state { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--dp-hover); color: var(--dp-muted); }
.dp-state.success { background: var(--dp-success-soft); color: var(--dp-success); }
.dp-state.warning { background: var(--dp-warning-soft); color: var(--dp-warning); }
.dp-state.danger { background: var(--dp-danger-soft); color: var(--dp-danger); }
.dp-state.info { background: var(--dp-info-soft); color: var(--dp-info); }
.dp-state.primary { background: var(--dp-selection); color: var(--dp-primary-hover); }

.dp-detail { position: sticky; top: 0; max-height: calc(100vh - 190px); overflow: auto; }
@supports (height: 100dvh) { .dp-detail { max-height: calc(100dvh - 190px); } }
.dp-detail-head { display: flex; align-items: center; gap: 12px; padding: 16px; border-bottom: 1px solid var(--dp-border); }
.dp-avatar { width: 46px; height: 46px; flex: 0 0 46px; border-radius: 14px; background: var(--dp-gradient); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.dp-detail-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
.dp-detail-head p { margin: 2px 0 0; color: var(--dp-muted); font-size: 12.5px; }
.dp-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 16px; border-bottom: 1px solid var(--dp-border); }
.dp-actions .dp-btn { height: 32px; padding: 0 11px; font-size: 12.5px; }
.dp-section { padding: 12px 16px; border-bottom: 1px solid var(--dp-border); }
.dp-section:last-child { border-bottom: 0; }
.dp-section-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 8px; font-size: 13px; font-weight: 700; color: var(--dp-text); }
.dp-kv { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 5px 10px; font-size: 13px; margin: 0; }
.dp-kv dt { color: var(--dp-muted); font-weight: 500; margin: 0; }
.dp-kv dd { margin: 0; overflow-wrap: anywhere; }
.dp-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.dp-tile { padding: 10px 12px; border-radius: 10px; background: var(--dp-surface-alt); border: 1px solid var(--dp-border); }
.dp-tile span { display: block; font-size: 12px; color: var(--dp-muted); }
.dp-tile strong { font-size: 17px; font-weight: 700; }
.dp-tile.danger strong { color: var(--dp-danger); }
.dp-tile.success strong { color: var(--dp-success); }
.dp-alert { margin: 12px 16px 0; padding: 10px 12px; border-radius: 10px; background: var(--dp-danger-soft); color: #9F1239; font-size: 13px; }
.dp-alert strong { display: block; margin-bottom: 2px; }
.dp-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.dp-list li { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.dp-list .muted { color: var(--dp-muted); }
.dp-placeholder { padding: 48px 20px; text-align: center; color: var(--dp-muted); }
.dp-placeholder .glyph { font-size: 34px; display: block; margin: 0 auto 10px; opacity: .6; width: auto; height: auto; }
.dp-message { padding: 10px 12px; border-radius: 10px; font-size: 13px; }
.dp-message.error { background: var(--dp-danger-soft); color: #9F1239; }
.dp-message.ok { background: var(--dp-success-soft); color: #065F46; }
.dp-tabs { display: flex; gap: 2px; padding: 4px; background: #EEF2F7; border-radius: 11px; overflow-x: auto; max-width: 100%; align-self: flex-start; }
.dp-tabs button { border: 0; background: transparent; border-radius: 8px; padding: 7px 14px; font-size: 13px; font-weight: 600; color: var(--dp-muted); white-space: nowrap; cursor: pointer; }
.dp-tabs button.active { background: var(--dp-surface); color: var(--dp-primary-hover); box-shadow: 0 1px 4px rgba(11, 19, 36, .08); }
.dp-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 12px; }
.dp-form .wide { grid-column: 1 / -1; }
.dp-form textarea { min-height: 70px; border: 1px solid var(--dp-border-strong); border-radius: 9px; padding: 8px 10px; font-size: 13.5px; }

/* Right-click menu (rowmenu.js) */
.row-menu { position: fixed; z-index: 1000; min-width: 210px; max-width: 320px; padding: 5px; background: var(--dp-surface); border: 1px solid var(--dp-border-strong); border-radius: 10px; box-shadow: var(--dp-shadow-raised); display: flex; flex-direction: column; }
.row-menu-item { text-align: left; border: 0; background: transparent; padding: 8px 12px; border-radius: 6px; font-size: 13px; color: var(--dp-text); cursor: pointer; }
.row-menu-item:hover:not(:disabled), .row-menu-item:focus { background: var(--dp-hover); outline: none; }
.row-menu-item:disabled { color: #A9B4C2; cursor: default; }
.row-menu-item.danger { color: var(--dp-danger); }
.row-menu-separator { height: 1px; margin: 4px 6px; background: var(--dp-border); }

@media (max-width: 1100px) {
    .dp-split { grid-template-columns: minmax(0, 1fr); }
    .dp-detail { position: static; max-height: none !important; }
    .dp-grid-wrap { max-height: 55vh !important; }
}
@media (max-width: 860px) {
    .dp-head h2 { font-size: 18px; }
    .dp-search { max-width: none; flex-basis: 100%; }
    .dp-kv { grid-template-columns: 110px minmax(0, 1fr); }
    table.dp-grid { min-width: 520px; }
    .dp-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dp-actions .dp-btn { white-space: normal; height: auto; min-height: 34px; }
}

/* Reports charts (as the desktop Reports page) */
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.report-bars { display: grid; gap: 7px; }
.report-bar { display: grid; grid-template-columns: minmax(90px, 38%) 1fr 60px; align-items: center; gap: 8px; font-size: 12.5px; }
.report-bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dp-text); }
.report-bar-track { height: 10px; border-radius: 6px; background: #EEF2F7; overflow: hidden; }
.report-bar-fill { display: block; height: 100%; border-radius: 6px; background: var(--dp-primary); }
.report-bar-fill.success, .report-column-fill.success { background: var(--dp-success); }
.report-bar-fill.info, .report-column-fill.info { background: var(--dp-info); }
.report-bar-fill.danger, .report-column-fill.danger { background: var(--dp-danger); }
.report-bar-value { text-align: right; font-variant-numeric: tabular-nums; color: var(--dp-muted); }
.report-columns { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding-bottom: 18px; position: relative; }
.report-column { flex: 1 1 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; min-width: 6px; }
.report-column-fill { width: 100%; max-width: 26px; border-radius: 4px 4px 0 0; background: var(--dp-primary); min-height: 2px; }
.report-column-label { position: absolute; bottom: -18px; font-size: 10px; color: var(--dp-muted); white-space: nowrap; }
.report-column:nth-child(odd) .report-column-label { visibility: visible; }
.report-columns:has(.report-column:nth-child(15)) .report-column:nth-child(even) .report-column-label { visibility: hidden; }

/* Dashboard greeting with quick actions (as the desktop Dashboard) */
.dash-hero { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 18px 20px; border-radius: 16px; background: var(--dp-sidebar); color: #fff; box-shadow: var(--dp-shadow-soft); }
.dash-hero h2 { margin: 0; color: #fff; font-size: 22px; font-weight: 700; }
.dash-hero p { margin: 2px 0 0; color: var(--dp-sidebar-text); font-size: 13px; }
.dash-hero-icon { width: 48px; height: 48px; flex: 0 0 48px; border-radius: 14px; background: var(--dp-gradient); display: flex; align-items: center; justify-content: center; font-size: 22px; box-shadow: 0 0 18px rgba(var(--cs-p-light-rgb), .45); }
.dash-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.dash-action { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.08); color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.dash-action:hover { background: rgba(255,255,255,.16); }
@media (max-width: 860px) { .dash-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; } .dash-action { justify-content: center; white-space: normal; height: auto; min-height: 38px; } }
