/*
 * Dashboards - one set of building blocks for every "home" screen (administrator, moderator, business owner, customer).
 *
 *   .dx-head      the page title, a line under it and the quick-action buttons
 *   .dx-section   a titled block with an optional "View all" link
 *   .dx-grid      a responsive grid of .dx-stat cards - EVERY card is a link to the page that shows what the number counts
 *   .dx-todo      "needs your attention": one card per waiting item, with the count; an all-clear state when nothing waits
 *   .dx-panel     a card with a header and .dx-row lines, each line a link to the right page
 *
 * Colours come from the --ui-* variables, which already switch for dark mode, so nothing here is theme-specific.
 * Each card takes its accent from data-tone (teal, blue, purple, orange, amber, red, slate, green).
 *
 * TO GO BACK: delete the <link> to this file in resources/views/layouts/admin.php, dashboard.php and main.php; the templates still render
 * (plain links in plain boxes).
 */

/* --dx-tone fills a chip; --dx-ink is the same colour as TEXT on the card (darker in light mode, lighter in dark mode, so it stays readable) */
[data-tone="teal"] { --dx-tone: #0d7d7d; --dx-ink: #0b6666; }
[data-tone="blue"] { --dx-tone: #2563eb; --dx-ink: #1d4ed8; }
[data-tone="purple"] { --dx-tone: #7c3aed; --dx-ink: #6d28d9; }
[data-tone="orange"] { --dx-tone: #c2410c; --dx-ink: #b4390b; }
[data-tone="amber"] { --dx-tone: #b45309; --dx-ink: #92400e; }
[data-tone="red"] { --dx-tone: #c62839; --dx-ink: #b91c1c; }
[data-tone="slate"] { --dx-tone: #475569; --dx-ink: #475569; }
[data-tone="green"] { --dx-tone: #15803d; --dx-ink: #166534; }
[data-bs-theme="dark"] [data-tone="teal"] { --dx-ink: #5eead4; }
[data-bs-theme="dark"] [data-tone="blue"] { --dx-ink: #93c5fd; }
[data-bs-theme="dark"] [data-tone="purple"] { --dx-ink: #c4b5fd; }
[data-bs-theme="dark"] [data-tone="orange"] { --dx-ink: #fdba74; }
[data-bs-theme="dark"] [data-tone="amber"] { --dx-ink: #fcd34d; }
[data-bs-theme="dark"] [data-tone="red"] { --dx-ink: #fca5a5; }
[data-bs-theme="dark"] [data-tone="slate"] { --dx-ink: #cbd5e1; }
[data-bs-theme="dark"] [data-tone="green"] { --dx-ink: #86efac; }

/* ---- page head ------------------------------------------------------------------------------------------------------------------------ */
.dx-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 1.25rem; }
.dx-head h1 { margin: 0; font-size: clamp(1.55rem, 1.2rem + 1.2vw, 2.1rem); font-weight: 780; letter-spacing: -.025em; line-height: 1.1; }
.dx-head p { margin: .35rem 0 0; color: var(--ui-muted, var(--bs-secondary-color)); font-size: .95rem; }
.dx-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---- sections ------------------------------------------------------------------------------------------------------------------------- */
.dx-section { margin-top: 1.9rem; }
.dx-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap; margin-bottom: .8rem; }
.dx-section-head h2 { margin: 0; font-size: 1.08rem; font-weight: 760; letter-spacing: -.01em; }
.dx-section-head p { margin: .15rem 0 0; font-size: .86rem; color: var(--ui-muted, var(--bs-secondary-color)); flex-basis: 100%; }
.dx-section-head a { font-size: .86rem; font-weight: 650; white-space: nowrap; }

/* ---- stat cards (always links) --------------------------------------------------------------------------------------------------------- */
.dx-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.dx-stat {
    position: relative; display: grid; align-items: center; gap: 2px 14px; min-width: 0; padding: 16px 18px;
    grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "icon value go" "icon label label" ". note note";
    color: var(--ui-text, inherit); text-decoration: none; background: var(--ui-surface, #fff);
    border: 1px solid var(--ui-line, var(--bs-border-color)); border-radius: 16px; box-shadow: 0 1px 2px rgba(15, 30, 40, .05);
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.dx-stat-icon { grid-area: icon; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 13px; font-size: 1.3rem; color: #fff; background: var(--dx-tone, #0d7d7d); }
.dx-stat-value { grid-area: value; font-size: 1.65rem; font-weight: 780; line-height: 1.05; letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.dx-stat-label { grid-area: label; font-size: .86rem; color: var(--ui-muted, var(--bs-secondary-color)); line-height: 1.3; }
.dx-stat-note { grid-area: note; margin-top: 6px; font-size: .76rem; font-weight: 650; line-height: 1.3; color: var(--dx-ink, inherit); }
.dx-stat-go { grid-area: go; align-self: start; font-size: .95rem; color: var(--ui-muted, inherit); opacity: .35; transition: opacity .16s ease, transform .16s ease; }
.dx-stat[data-state="alert"] { border-color: var(--dx-tone); box-shadow: 0 0 0 1px var(--dx-tone) inset; }
.dx-stat[data-state="alert"] .dx-stat-value { color: var(--dx-ink, var(--dx-tone)); }
.dx-stat-value.is-long { font-size: 1.3rem; white-space: nowrap; }
@media (hover: hover) {
    .dx-stat:hover { transform: translateY(-2px); color: var(--ui-text, inherit); border-color: var(--dx-tone, var(--ui-line)); box-shadow: 0 12px 26px -14px rgba(15, 30, 40, .45); }
    .dx-stat:hover .dx-stat-go { opacity: .9; transform: translate(2px, -2px); }
}
.dx-stat:focus-visible, .dx-todo:focus-visible, a.dx-row:focus-visible { outline: 3px solid var(--ui-accent, #ae442e); outline-offset: 2px; }

/* ---- needs your attention -------------------------------------------------------------------------------------------------------------- */
.dx-todo-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }
.dx-todo {
    display: flex; align-items: center; gap: 14px; min-width: 0; padding: 14px 16px; color: var(--ui-text, inherit); text-decoration: none;
    background: var(--ui-surface, #fff); border: 1px solid var(--ui-line, var(--bs-border-color)); border-left: 5px solid var(--dx-tone, #b45309); border-radius: 14px;
    transition: transform .16s ease, box-shadow .16s ease;
}
.dx-todo-count { flex: none; display: grid; place-items: center; min-width: 2.5rem; height: 2.5rem; padding: 0 .55rem; border-radius: 12px; font-weight: 800; font-variant-numeric: tabular-nums; color: #fff; background: var(--dx-tone, #b45309); }
.dx-todo-text { flex: 1 1 auto; min-width: 0; }
.dx-todo-text strong { display: block; font-size: .96rem; line-height: 1.25; }
.dx-todo-text small { display: block; margin-top: 2px; font-size: .8rem; line-height: 1.35; color: var(--ui-muted, var(--bs-secondary-color)); }
.dx-todo > .bi { flex: none; opacity: .4; }
@media (hover: hover) { .dx-todo:hover { transform: translateY(-2px); color: var(--ui-text, inherit); box-shadow: 0 12px 26px -14px rgba(15, 30, 40, .45); } .dx-todo:hover > .bi { opacity: .9; } }
.dx-clear { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border: 1px dashed var(--ui-line, var(--bs-border-color)); border-radius: 14px; background: var(--ui-surface, #fff); color: var(--ui-muted, inherit); }
.dx-clear .bi { font-size: 1.6rem; color: var(--dx-ink, #15803d); }
.dx-clear strong { display: block; color: var(--ui-text, inherit); }

/* ---- panels with link rows ------------------------------------------------------------------------------------------------------------- */
.dx-panels { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); align-items: start; }
.dx-panel { display: flex; flex-direction: column; min-width: 0; overflow: hidden; background: var(--ui-surface, #fff); border: 1px solid var(--ui-line, var(--bs-border-color)); border-radius: 16px; box-shadow: 0 1px 2px rgba(15, 30, 40, .05); }
.dx-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--ui-line, var(--bs-border-color)); }
.dx-panel-head h2 { margin: 0; font-size: 1rem; font-weight: 760; }
.dx-panel-head a { font-size: .84rem; font-weight: 650; white-space: nowrap; }
.dx-panel-body { flex: 1 1 auto; padding: 14px 18px; }
.dx-panel-foot { padding: 11px 18px; border-top: 1px solid var(--ui-line, var(--bs-border-color)); font-size: .84rem; }
.dx-rows { margin: 0; padding: 0; list-style: none; }
.dx-row { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 12px 18px; color: inherit; text-decoration: none; border-top: 1px solid var(--ui-line, var(--bs-border-color)); }
.dx-rows > li:first-child > .dx-row { border-top: 0; }
/* a wide panel lays its lines out in two columns when there is room */
.dx-panel-wide { grid-column: 1 / -1; }
@media (min-width: 900px) {
    .dx-panel-wide .dx-rows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 0; }
    .dx-panel-wide .dx-rows > li:nth-child(2) > .dx-row { border-top: 0; }
    .dx-panel-wide .dx-rows > li:nth-child(even) > .dx-row { border-left: 1px solid var(--ui-line, var(--bs-border-color)); }
}
a.dx-row:hover { color: inherit; background: var(--ui-soft, rgba(0, 0, 0, .04)); }
.dx-row > .bi:first-child { flex: none; width: 1.4rem; text-align: center; font-size: 1.05rem; color: var(--dx-ink, var(--ui-muted)); }
.dx-row-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.dx-row-text small { display: block; margin-top: 1px; font-size: .78rem; color: var(--ui-muted, var(--bs-secondary-color)); }
.dx-row strong { flex: none; font-variant-numeric: tabular-nums; }
.dx-row > .dx-row-go { flex: none; opacity: .35; }
a.dx-row:hover > .dx-row-go { opacity: .9; }

/* ---- small chips (a count that is also a link) ----------------------------------------------------------------------------------------- */
.dx-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.dx-chip { display: inline-flex; align-items: baseline; gap: 6px; padding: 7px 12px; color: var(--ui-text, inherit); text-decoration: none; font-size: .85rem; background: var(--ui-soft, rgba(0, 0, 0, .04)); border: 1px solid var(--ui-line, var(--bs-border-color)); border-radius: 999px; }
.dx-chip b { font-size: 1.1rem; font-variant-numeric: tabular-nums; color: var(--dx-ink, inherit); }
a.dx-chip:hover { color: var(--ui-text, inherit); border-color: var(--dx-tone, var(--ui-line)); }

@media (max-width: 575.98px) {
    .dx-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .dx-stat { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "icon go" "value value" "label label" "note note"; gap: 8px 8px; padding: 14px; }
    .dx-stat-icon { width: 40px; height: 40px; font-size: 1.15rem; border-radius: 11px; }
    .dx-stat-value { font-size: 1.45rem; }
    .dx-todo-list { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) { .dx-stat, .dx-todo, .dx-stat-go { transition: none; } .dx-stat:hover, .dx-todo:hover { transform: none; } }

/* four to a row (the owner's eight numbers: 4 + 4 instead of 5 + 3) */
.dx-grid-4 > .dx-grid { grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }
@media (min-width: 992px) { .dx-grid-4 > .dx-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 575.98px) { .dx-grid-4 > .dx-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* three to a row (the customer's nine cards: 3 x 3) */
.dx-grid-3 > .dx-grid { grid-template-columns: repeat(auto-fit, minmax(235px, 1fr)); }
@media (min-width: 768px) { .dx-grid-3 > .dx-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 575.98px) { .dx-grid-3 > .dx-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
