/*
    The operator console.

    Reviewed in docs/CP-12-UI-REVIEW.md and restyled here. What this file already did well is unchanged: it is
    written in logical properties throughout, so right to left is deliberate rather than accidental, and it is
    still a single small stylesheet rather than a framework layered on MudBlazor's.

    What it lacked was a typeface, a colour system, and any way to tell a destructive button from a constructive
    one. Those are fixed here. The tokens and the type scale are deliberately the same ones public.css uses, so
    the two halves of this application stop drifting apart.
*/

/* ---- the typeface -------------------------------------------------------------------------------------
   The same self-hosted, subset Vazirmatn the accounting product and the public face ship. Self-hosted rather
   than a CDN, because this console runs on servers that may never reach the internet. */

@font-face {
    font-family: "Vazirmatn";
    font-style: normal;
    font-weight: 300 800;
    font-display: swap;
    src: url("fonts/vazirmatn/vazirmatn-arabic.woff2") format("woff2");
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC4, U+10EFC-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}

@font-face {
    font-family: "Vazirmatn";
    font-style: normal;
    font-weight: 300 800;
    font-display: swap;
    src: url("fonts/vazirmatn/vazirmatn-latin-ext.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: "Vazirmatn";
    font-style: normal;
    font-weight: 300 800;
    font-display: swap;
    src: url("fonts/vazirmatn/vazirmatn-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---- tokens -------------------------------------------------------------------------------------------
   The console used about a dozen hex literals, some rules borrowing var(--mud-palette-*) and some not. These
   are the same values public.css uses, plus the three states a console needs that a landing page does not. */

:root {
    color-scheme: light;

    --cc-ink: #0f1729;
    --cc-ink-soft: #46556f;
    --cc-ink-faint: #6b7a93;
    --cc-surface: #ffffff;
    --cc-surface-sunken: #f3f6fb;
    --cc-line: #e0e7f1;
    --cc-line-strong: #c6d0e0;

    --cc-accent: #4f46e5;
    --cc-accent-strong: #4338ca;
    --cc-accent-ink: #ffffff;
    --cc-accent-soft: #eef1fe;
    --cc-accent-line: #c7cdfa;

    --cc-danger: #b42318;
    --cc-danger-soft: #fef3f2;
    --cc-danger-line: #f3bdb7;

    --cc-success: #067647;
    --cc-success-soft: #ecfdf3;

    --cc-warn: #9a5b06;
    --cc-warn-soft: #fef6e7;

    --cc-radius-sm: 8px;
    --cc-radius-md: 12px;
    --cc-shadow-sm: 0 1px 2px rgba(15, 23, 41, .05), 0 1px 3px rgba(15, 23, 41, .04);
    --cc-shadow-md: 0 4px 6px rgba(15, 23, 41, .04), 0 10px 24px rgba(15, 23, 41, .06);
}

html, body { min-height: 100%; }
body { margin: 0; background: var(--cc-surface-sunken); color: var(--cc-ink); }
/* 15px at 1.8 rather than 14px at 1.43. Persian has ascenders, descenders and diacritics that need the room,
   and an operator reads these screens all day. */
body, .mud-typography, .mud-button, .mud-nav-link, input, button, textarea, select {
    font-family: "Vazirmatn", Tahoma, "Segoe UI", sans-serif;
}
body { font-size: 15px; line-height: 1.8; }

/* ---- focus --------------------------------------------------------------------------------------------
   This file used to remove an outline and replace it with nothing. One rule, for everything focusable. */
:is(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--cc-accent);
    outline-offset: 2px;
    border-radius: 4px;
}
/* The router focuses these programmatically so a screen reader announces the page; nobody can tab to them,
   and the browser's default ring draws a box around the heading. */
:is(#cc-main, h1, h2, h3):focus { outline: none; }

.cc-content { padding-block: 40px; }
.cc-login { max-width: 680px; margin: 48px auto; }
.cc-wordmark { font-size: 12px; letter-spacing: .12em; }
.cc-form { display: grid; gap: 16px; max-width: 600px; }
.cc-form label { display: grid; gap: 6px; }
.cc-form .cc-field { display: grid; gap: 6px; }
.cc-form fieldset { border: 0; padding: 0; min-width: 0; display: grid; gap: 16px; }
.cc-form input, .cc-form select, .cc-form textarea { min-width: 0; width: 100%; box-sizing: border-box; font: inherit; }
.cc-form select, .cc-form textarea {
    padding: 10px 12px; border: 1px solid var(--cc-line-strong); border-radius: var(--cc-radius-sm);
    background: var(--cc-surface); color: var(--cc-ink);
}
.cc-form fieldset:disabled { color: var(--cc-ink-soft); }
.cc-form fieldset:disabled input, .cc-form fieldset:disabled textarea, .cc-form fieldset:disabled select { color: var(--cc-ink-soft); opacity: 1; background: var(--cc-surface-sunken); }
.cc-category-nav { display: flex; flex-wrap: wrap; gap: 24px; margin-block: 24px; }
.cc-info-grid { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(0, 2fr); gap: 12px 24px; }
.cc-info-grid dt { margin: 0; } .cc-info-grid dd { margin: 0; }
.cc-platform-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-notice { white-space: pre-wrap; overflow-wrap: anywhere; }
.cc-panel { overflow-wrap: anywhere; }
.cc-form input:not([type=checkbox]) {
    padding: 10px 12px; border: 1px solid var(--cc-line-strong); border-radius: var(--cc-radius-sm);
    background: var(--cc-surface); color: var(--cc-ink);
}
.cc-form :is(input, select, textarea):focus {
    border-color: var(--cc-accent); box-shadow: 0 0 0 3px var(--cc-accent-soft); outline: none;
}
/*
    Three kinds of button, because there were none.

    Every control on this console used to be the same pale blue: "تأیید و ساخت مشتری" and "رد درخواست" on the
    signup screen were indistinguishable, and so were "فعال‌سازی" and "بازنشسته‌سازی" everywhere else. The
    default stays neutral - most buttons here save a form or apply a filter and deserve no emphasis. A screen's
    one affirmative action says .cc-primary, and anything that retires, cancels, rejects, suspends or deletes
    says .cc-danger. The difference is colour, weight and border together, so it survives a monochrome screen.
*/
button {
    font: inherit; cursor: pointer; padding: 9px 16px; border-radius: var(--cc-radius-sm);
    border: 1px solid var(--cc-line-strong); background: var(--cc-surface); color: var(--cc-ink);
    transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}
button:hover { border-color: var(--cc-accent-line); background: var(--cc-accent-soft); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.cc-primary {
    background: var(--cc-accent); border-color: var(--cc-accent); color: var(--cc-accent-ink); font-weight: 700;
}
button.cc-primary:hover { background: var(--cc-accent-strong); border-color: var(--cc-accent-strong); }
button.cc-danger {
    background: var(--cc-danger-soft); border-color: var(--cc-danger-line); color: var(--cc-danger); font-weight: 700;
}
button.cc-danger:hover { background: var(--cc-danger); border-color: var(--cc-danger); color: #ffffff; }
.cc-panel {
    padding: 22px; margin-block: 20px; background: var(--cc-surface);
    border: 1px solid var(--cc-line); border-radius: var(--cc-radius-md); box-shadow: var(--cc-shadow-sm);
}
h1 { font-size: 1.75rem; line-height: 1.4; margin-bottom: 16px; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; line-height: 1.45; margin-bottom: 12px; }
h3 { font-size: 1.05rem; line-height: 1.5; }
.cc-inline-form { display: inline-block; margin: 8px; }
.cc-logout { margin-inline-start: 16px; }
.cc-error {
    padding: 14px 16px; background: var(--cc-danger-soft); color: var(--cc-danger);
    border: 1px solid var(--cc-danger-line); border-radius: var(--cc-radius-sm);
}
.cc-success {
    padding: 14px 16px; background: var(--cc-success-soft); color: var(--cc-success);
    border: 1px solid color-mix(in srgb, var(--cc-success) 25%, transparent); border-radius: var(--cc-radius-sm);
}
.cc-table-wrap { overflow-x: auto; } .cc-table { width: 100%; background: white; border-collapse: collapse; }
.cc-table th, .cc-table td { padding: 12px 14px; border-bottom: 1px solid var(--cc-line); text-align: start; }
.cc-table th { background: var(--cc-surface-sunken); font-weight: 700; color: var(--cc-ink-soft); }
.cc-table tbody tr:hover { background: var(--cc-surface-sunken); }
.cc-form .cc-check { display: flex; align-items: center; gap: 12px; } .cc-check input { width: 20px; height: 20px; }
.cc-mobile-nav { display: none; } dt { font-weight: bold; margin-top: 12px; } pre { white-space: pre-wrap; overflow-wrap: anywhere; }
dd { overflow-wrap: anywhere; }
.cc-form-inline { max-width: none; grid-template-columns: minmax(220px, 2fr) minmax(160px, 1fr) auto; align-items: end; }
.cc-pagination, .cc-actions, .cc-action-grid { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin-block: 16px; }
.cc-pagination { justify-content: space-between; }
.cc-badge {
    display: inline-block; padding: 3px 11px; border-radius: 999px; background: var(--cc-accent-soft);
    color: var(--cc-ink-soft); border: 1px solid var(--cc-line); font-size: .84rem; font-weight: 600;
}
.cc-entitlement-effective { background: var(--cc-success-soft); color: var(--cc-success); }
.cc-entitlement-inactive { background: var(--cc-warn-soft); color: var(--cc-warn); }
.cc-entitlement-history { background: var(--cc-accent-soft); color: var(--cc-ink-soft); }
.cc-entitlement-filters { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.cc-license-filters { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.cc-code { font-family: Consolas, monospace; font-size: .85rem; white-space: pre-wrap; word-break: break-all; background: var(--cc-surface-sunken); border: 1px solid var(--cc-line); border-radius: 6px; padding: 12px; overflow-x: auto; }
.cc-code-input { font-family: Consolas, monospace; font-size: .85rem; width: 100%; box-sizing: border-box; }
.cc-entitlement-code { font-family: Consolas, monospace; white-space: nowrap; }
.cc-contact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.cc-contact-card { border: 1px solid var(--cc-line); border-radius: 8px; padding: 16px; min-width: 0; }
.cc-contact-card h3 { margin-top: 0; }
.cc-disclosure { margin-block: 16px; }
.cc-disclosure summary { cursor: pointer; font-weight: bold; margin-bottom: 16px; }
.cc-lifecycle-form { border: 1px solid var(--cc-line); border-radius: 8px; padding: 16px; }
.cc-timeline { list-style: none; padding: 0; margin: 0; border-inline-start: 3px solid var(--cc-line-strong); }
.cc-timeline li { position: relative; margin: 0 20px 18px 0; padding: 2px 16px 14px; border-bottom: 1px solid var(--cc-line); }
.cc-timeline li::before { content: ""; position: absolute; inset-inline-start: -27px; top: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--cc-accent); }
.cc-timeline h3 { margin: 0 0 6px; font-size: 1rem; }
/* SSR does not run a later interactive layout pass. Reserve the actual right drawer width
   explicitly so administrative forms cannot be covered by the persistent drawer on desktop. */
@media (min-width: 961px) {
    .cc-drawer { width: 240px !important; top: var(--mud-appbar-height) !important; height: calc(100% - var(--mud-appbar-height)) !important; }
    .mud-layout:has(.cc-drawer) .mud-main-content { margin-right: 240px !important; margin-left: 0 !important; transition: none !important; }
    .mud-layout:has(.cc-drawer) .mud-appbar { width: 100% !important; left: 0 !important; right: 0 !important; margin-inline: 0 !important; transition: none !important; }
}

.cc-pipeline { display: grid; grid-template-columns: repeat(4, minmax(15rem, 1fr)); gap: 1rem; overflow-x: auto; }
.cc-pipeline-column { background: var(--mud-palette-background-grey); border-radius: .5rem; padding: .75rem; min-width: 15rem; }
.cc-pipeline-card { background: var(--mud-palette-surface); border-inline-start: .25rem solid var(--mud-palette-primary); border-radius: .35rem; margin-block: .6rem; padding: .75rem; }
.cc-metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .75rem; margin-block: 1rem; }
.cc-metric-card { background: var(--mud-palette-background-grey); border-radius: .5rem; padding: .9rem; display: grid; gap: .35rem; }
.cc-metric-card strong { font-size: 1.45rem; color: var(--mud-palette-primary); }
.cc-dashboard-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1rem; }
.cc-dashboard-columns > .cc-panel { margin-block: 0 1rem; }
.cc-outcome-list { display: grid; gap: .6rem; padding-inline-start: 1.5rem; }
.cc-overdue { border-inline-start: .25rem solid var(--mud-palette-error); padding-inline-start: .5rem; }
@media (max-width: 900px) { .cc-pipeline { grid-template-columns: repeat(4, 16rem); } }
@media (max-width: 960px) {
    .cc-drawer { display: none; }
    .mud-main-content { margin-inline: 0 !important; transition: none !important; }
    .mud-appbar { width: 100% !important; left: 0 !important; right: 0 !important; margin-inline: 0 !important; transition: none !important; }
    .cc-mobile-nav { display: flex; flex-wrap: wrap; }
}
#cc-main:focus { outline: none; }
#blazor-error-ui { display: none; position: fixed; bottom: 0; inset-inline: 0; padding: 16px; background: var(--cc-warn-soft); z-index: 2000; }
@media (max-width: 600px) {
    .cc-info-grid { grid-template-columns: minmax(0, 1fr); gap: 6px; }
    .cc-info-grid dd { margin-bottom: 12px; }
    .cc-content { padding-block: 20px; }
    .cc-login { margin: 16px auto; }
    .cc-wordmark { display: none; }
    .cc-form-inline { grid-template-columns: minmax(0, 1fr); }
    .cc-pagination { align-items: stretch; flex-direction: column; }
}
