/*
 * The Anfigo look — one file for every product of the family (ADR 0007): Customer Service (dashboard.html) and
 * Accounting (accounting.html) link it after css/tailwind.css, so a product looks like the others by using it,
 * never by copying its rules. What only one product needs stays in that page.
 *
 *   canvas          the warm cream behind every page (body.bg-gray-50 on the dashboard, body.anfigo-canvas elsewhere)
 *   display type    Newsreader for headings and large figures; Hanken Grotesk (Tailwind's sans) for everything else
 *   accent          the forest green on native form controls
 *   sidebar         .nav-item / .nav-item.active / .nav-divider / .nav-icon — the left menu of every product
 *   frame           .anfigo-bar · .anfigo-side (-pages, -foot) · .anfigo-switcher · .anfigo-account · .anfigo-menu ·
 *                   .anfigo-scroll — drawn by js/dashboard/shell.js, the same header, sidebar and scroll everywhere
 *   filter chips    .overview-filter-chip / .active-chip / .chip-count — the pill filters and period switches
 *   busy            [aria-busy="true"] — an action still running (js/dashboard/actions.js): a second press does nothing
 *   buttons         .anfigo-btn + -primary (the one main action) / -secondary (the quiet one) / -danger (red, apart)
 *   message bar     .anfigo-toast / .anfigo-toast-on — js/dashboard/format.js showToast: bottom left, one at a time
 *   load failed     .anfigo-load-failed — format.js loadFailedHtml / showLoadFailed: the reason and Retry, in place
 *   loading         .anfigo-skeleton — format.js loadingHtml: grey lines where a list's rows will be, never "Loading…"
 *   search          .anfigo-search · .anfigo-search-results — js/dashboard/search.js: the top bar's one box, "/" jumps to it
 *   bulk            .anfigo-tick · .anfigo-bulk — js/dashboard/bulk.js: a row's tick box and the bar over the ticked rows
 */

/* ── Loading ── grey lines where the rows will be; still for whoever asks the screen for less motion. */
.anfigo-skeleton { padding: 4px 0; }
.anfigo-skeleton-row { display: flex; align-items: center; gap: 16px; padding: 12px 8px; }
.anfigo-skeleton-row span {
    display: block;
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg, #EEE9DF 0%, #F6F2EA 50%, #EEE9DF 100%);
    background-size: 200% 100%;
    animation: anfigo-skeleton 1.4s ease-in-out infinite;
}
.anfigo-skeleton-row span:first-child { width: 28%; flex: none; }
.anfigo-skeleton-row span:last-child { flex: 1; max-width: 60%; }
@keyframes anfigo-skeleton { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) {
    .anfigo-skeleton-row span { animation: none; }
}

/* ── A load that failed ── where the content would be: the reason, then Retry. */
.anfigo-load-failed {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
    margin: 0 0 16px;
    padding: 10px 12px 10px 16px;
    border-radius: 10px;
    border: 1px solid #FECACA;
    background: #FEF2F2;
    color: #B91C1C;
    font-size: 14px;
    line-height: 20px;
}
.anfigo-load-failed .anfigo-btn { min-height: 32px; padding: 5px 14px; }

/* ── The message bar ── bottom left (above the phone's bottom bar), one at a time, readable size. */
.anfigo-toast {
    position: fixed;
    left: 24px;
    bottom: 24px;
    z-index: 200;
    max-width: min(440px, calc(100vw - 32px));
    padding: 10px 16px;
    border-radius: 8px;
    background: #1f2937;
    color: #fff;
    font-size: 14px;
    line-height: 20px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity .2s ease-out, transform .2s ease-out;
}
.anfigo-toast-on { opacity: 1; transform: none; }
@media (max-width: 768px) {
    .anfigo-toast { left: 16px; right: 16px; max-width: none; bottom: calc(76px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
    .anfigo-toast { transition: none; }
}

/* ── Buttons ── one look for an action in every product (the family's dialog uses them first — js/dashboard/dialog.js). */
.anfigo-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 36px;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.anfigo-btn-primary { background: #176150; color: #fff; }
.anfigo-btn-primary:hover { background: #134f42; }
.anfigo-btn-secondary { background: #fff; color: #374151; border-color: #E5E7EB; }
.anfigo-btn-secondary:hover { background: #F9FAFB; }
.anfigo-btn-danger { background: #dc2626; color: #fff; }
.anfigo-btn-danger:hover { background: #b91c1c; }
/* A destructive action that is not the screen's question (Disconnect, Remove): red words, kept apart from Save. */
.anfigo-btn-danger-text { background: none; color: #dc2626; min-height: 32px; padding: 6px 10px; }
.anfigo-btn-danger-text:hover { background: #FEF2F2; color: #b91c1c; }
.anfigo-btn:disabled { opacity: .5; cursor: not-allowed; }
.anfigo-btn[hidden] { display: none; }   /* the button's own display would otherwise beat the hidden attribute */
.anfigo-btn:focus-visible { outline: 2px solid #176150; outline-offset: 2px; }
.anfigo-btn-danger:focus-visible { outline-color: #dc2626; }

/* Keyboard focus is always visible — the family's green ring — and a mouse click shows none (:focus-visible).
   Fields keep their own focus look. */
:where(button, a[href], [role="button"], [tabindex]:not([tabindex="-1"]), summary):focus-visible {
    outline: 2px solid #176150;
    outline-offset: 2px;
}

/* On a phone every text field is at least 16 px: below that, an iPhone zooms the page in on every tap. */
@media (max-width: 768px) {
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]), select, textarea { font-size: 16px; }
}

/* An action still running: the pointer says so everywhere, and a button dims (a page in the sidebar, a section or
   a filter does not — opening one is not a save). */
[aria-busy="true"] { cursor: progress; }
button[aria-busy="true"]:not(.nav-item):not(.subnav-item):not(.overview-filter-chip):not(.anfigo-menu-item) { opacity: .6; }

/* Warm cream app canvas. Targets the body element only, so inner bg-gray-50 surfaces (inputs, table headers,
   hovers) keep their neutral gray. */
body.bg-gray-50,
body.anfigo-canvas {
    background: #F1EEE6 !important;
}

/* Display headings use the design's Newsreader serif. Scoped to large headings so dense UI controls/labels keep
   the Hanken Grotesk sans body font. */
h1,
h2,
h3,
.text-xl,
.text-2xl,
.text-3xl {
    font-family: 'Newsreader', Georgia, serif;
}

/* Green focus ring/accent fallback for native form controls. */
input,
textarea,
select {
    accent-color: #176150;
}

/* ── The sidebar ── */
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    margin: 2px 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #475569;
    transition: background .15s, color .15s;
    border: none;
    background: none;
    width: calc(100% - 16px);
    text-align: left;
}

.nav-item:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.nav-item.active {
    background: #176150;
    color: #fff;
}

/* A page this door cannot open, shown with its lock (the Front desk door's Integrations) */
.nav-item.nav-locked { color: #94A3B8; }
.nav-lock { margin-left: auto; width: 14px; height: 14px; color: #94A3B8; flex-shrink: 0; }

.nav-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 10px 16px;
}

.nav-item .nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ── Filter chips ── */
.overview-filter-chip {
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #475569;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
    white-space: nowrap;
}

.overview-filter-chip:hover {
    background: #f1f5f9;
}

.overview-filter-chip.active-chip {
    background: #176150;
    color: #fff;
    border-color: #176150;
}

.chip-count {
    font-size: 12px;
    font-weight: 600;
    opacity: 0.6;
    margin-left: 2px;
}

.overview-filter-chip.active-chip .chip-count {
    opacity: 0.85;
}

/* A dropdown chip (Drive's Type ▾): the chip names the group, or the option chosen; its menu lists the options. */
.inbox-dd { position: relative; }
.inbox-dd[hidden] { display: none; }
.inbox-dd-btn { display: inline-flex; align-items: center; gap: 4px; }
.inbox-dd .anfigo-menu { left: 0; right: auto; top: calc(100% + 4px); min-width: 200px; }
.inbox-dd-menu .overview-filter-chip { display: flex; justify-content: space-between; align-items: center; width: 100%; border: 0; border-radius: 8px; padding: 7px 10px; font-size: 13px; text-align: left; }
.inbox-dd-menu .overview-filter-chip[hidden] { display: none; }

/* ── The frame (js/dashboard/shell.js) ── the same header, sidebar and scroll in every product.
   The sidebar's three parts: the product switcher on top, the product's pages (their own scroll), and the
   foot — the product's settings, then the account (the property, who is working, the way out). */
.anfigo-bar {
    height: 53px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
}

/* Tick boxes and the bar over the ticked rows (js/dashboard/bulk.js). */
.anfigo-tick { width: 16px; height: 16px; accent-color: #176150; cursor: pointer; flex-shrink: 0; }
.anfigo-bulk { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 8px 12px; margin: 8px 0; border-radius: 10px; background: #E9F0EA; }
.anfigo-bulk[hidden] { display: none; }
.anfigo-bulk-count { font-size: 13px; font-weight: 600; color: #134f42; margin-right: 4px; }
.anfigo-bulk .anfigo-btn { padding-top: 4px; padding-bottom: 4px; }
.anfigo-bulk-clear { margin-left: auto; font-size: 13px; color: #4b5563; text-decoration: underline; }

/* The top bar's search (js/dashboard/search.js): one box after the logo, its results in a card under it. */
[data-anfigo-search] { position: relative; flex: 1; max-width: 560px; margin: 0 auto 0 32px; }   /* beside the logo, whatever the bar spreads */
.anfigo-search { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; border-radius: 10px; background: #F4F1EA; border: 1px solid transparent; }
.anfigo-search:focus-within { background: #fff; border-color: #176150; box-shadow: 0 1px 6px rgba(20, 40, 35, .12); }
.anfigo-search-icon { width: 16px; height: 16px; color: #6b7280; flex-shrink: 0; }
.anfigo-search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-size: 14px; color: #1f2937; }
.anfigo-search input::-webkit-search-cancel-button { cursor: pointer; }
.anfigo-search-key { font: 500 11px/1 inherit; color: #6b7280; border: 1px solid #d1d5db; border-radius: 4px; padding: 2px 6px; background: #fff; }
.anfigo-search:focus-within .anfigo-search-key { display: none; }
.anfigo-search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 70; max-height: min(70vh, 520px); overflow-y: auto;
    background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; box-shadow: 0 8px 28px rgba(20, 40, 35, .16); padding: 6px; }
.anfigo-search-results[hidden] { display: none; }
.anfigo-search-group { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: #6b7280; padding: 8px 10px 4px; }
.anfigo-search-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 7px 10px; border-radius: 8px; }
.anfigo-search-row:hover, .anfigo-search-row.active { background: #F4F1EA; }
.anfigo-search-row-icon { width: 16px; height: 16px; color: #176150; flex-shrink: 0; }
.anfigo-search-row-text { display: flex; flex-direction: column; min-width: 0; }
.anfigo-search-row-title { font-size: 14px; color: #1f2937; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.anfigo-search-row-detail { font-size: 12px; color: #6b7280; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.anfigo-search-more .anfigo-search-row-title { color: #176150; font-weight: 500; }
.anfigo-search-note { font-size: 13px; color: #6b7280; padding: 10px; }
@media (max-width: 768px) {
    [data-anfigo-search] { margin: 0 8px 0 12px; }
    .anfigo-search-key { display: none; }
}

.anfigo-side {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-right: 1px solid #e5e7eb;
    min-height: 0;
}

.anfigo-side-pages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 2px 0 8px;
}

.anfigo-side-foot {
    border-top: 1px solid #e5e7eb;
    padding: 6px 0 8px;
}

.nav-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #6b7280;
    padding: 10px 24px 4px;
}

/* The product switcher and the account: a button, and a menu that opens from it. */
.anfigo-switcher { position: relative; padding: 12px 8px 6px; }
.anfigo-account { position: relative; padding: 4px 8px 0; }

.anfigo-switcher-btn,
.anfigo-account-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 7px 10px;
    border-radius: 10px;
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    text-align: left;
}

.anfigo-switcher-btn { border-color: #EEE8DC; background: #FBF9F4; }
.anfigo-switcher-btn:hover, .anfigo-account-btn:hover { background: #F4F1EA; }
.anfigo-chevron { width: 15px; height: 15px; color: #9ca3af; flex-shrink: 0; }

.anfigo-product-mark {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: #176150;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.anfigo-product-mark svg { width: 16px; height: 16px; }
.anfigo-product-mark-sm { width: 26px; height: 26px; border-radius: 7px; }
.anfigo-switcher-name { display: block; font-size: 14px; font-weight: 600; color: #1f2937; line-height: 1.2; }
.anfigo-switcher-sub { display: block; font-size: 12px; color: #6b7280; }

.anfigo-avatar {
    width: 30px;
    height: 30px;
    border-radius: 9999px;
    background: #E9F0EA;
    color: #176150;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.anfigo-account-name { font-size: 13px; font-weight: 600; color: #1f2937; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.anfigo-account-who { font-size: 12px; color: #6b7280; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.anfigo-menu {
    position: absolute;
    z-index: 60;
    left: 8px;
    right: 8px;
    min-width: 236px;
    background: #fff;
    border: 1px solid #E5DFD3;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(20, 40, 35, .12);
    padding: 6px;
}

.anfigo-menu[hidden] { display: none; }
.anfigo-switcher .anfigo-menu { top: calc(100% - 2px); }
.anfigo-account .anfigo-menu { bottom: calc(100% + 4px); }

.anfigo-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    color: #374151;
    text-align: left;
    background: none;
    border: 0;
    cursor: pointer;
    text-decoration: none;
}

.anfigo-menu-item:hover { background: #F4F1EA; }
.anfigo-menu-item.current { background: #E9F0EA; color: #176150; font-weight: 600; }
.anfigo-menu-item .sub { display: block; font-size: 12px; font-weight: 400; color: #6b7280; }
.anfigo-menu-item > svg { width: 16px; height: 16px; flex-shrink: 0; }
.anfigo-menu-item-out:hover { color: #dc2626; }
.anfigo-menu-sep { height: 1px; background: #EEE8DC; margin: 6px 4px; }

/* On a phone the sidebar is gone: the switcher and the account sit in the header, their menus open down. */
[data-anfigo-narrow] { display: none; align-items: center; gap: 4px; }
.anfigo-narrow-menu { position: relative; padding: 0; }
.anfigo-narrow-menu .anfigo-switcher-btn, .anfigo-narrow-menu .anfigo-account-btn { padding: 4px 6px; border-color: transparent; background: none; }
.anfigo-narrow-menu .anfigo-menu { top: calc(100% + 6px); bottom: auto; left: auto; right: 0; width: 260px; }
@media (max-width: 768px) {
    [data-anfigo-narrow] { display: flex; }
}

/* The page that scrolls: a slim scrollbar that shows while the pointer is over it. */
.anfigo-scroll { scrollbar-width: thin; scrollbar-color: transparent transparent; }
.anfigo-scroll:hover { scrollbar-color: rgba(20, 40, 35, .22) transparent; }
.anfigo-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.anfigo-scroll::-webkit-scrollbar-track { background: transparent; }
.anfigo-scroll::-webkit-scrollbar-thumb { background: transparent; border-radius: 8px; }
.anfigo-scroll:hover::-webkit-scrollbar-thumb { background: rgba(20, 40, 35, .22); }

/* A page's title: Customer Service's, on every page of every product (the serif of the headings above). */
.anfigo-title {
    font-family: 'Newsreader', Georgia, serif;
    font-size: 16px;
    line-height: 24px;
    font-weight: 600;
    color: #374151;
}

/* The doors — Manager / Front desk (js/dashboard/door.js builds them on whichever page shows them) */
.door-tile { display: flex; flex-direction: column; align-items: center; gap: 8px; background: #fff; border: 1px solid #E5DFD3; border-radius: 16px; padding: 28px 16px; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.door-tile:hover { border-color: #176150; box-shadow: 0 0 0 3px rgba(23, 97, 80, .12); }
.door-tile-title { font-size: 17px; font-weight: 600; color: #111827; }
.door-tile-sub { font-size: 12.5px; color: #6B7280; }
.door-tile.active { border-color: #176150; box-shadow: 0 0 0 3px rgba(23, 97, 80, .12); }
.door-pin-input { width: 10rem; font-family: inherit; font-size: 24px; letter-spacing: .6em; text-align: center; color: #111827; background: #fff; border: 1px solid #E5DFD3; border-radius: 14px; padding: 12px 0 12px .6em; outline: none; transition: border-color .15s, box-shadow .15s; }
.door-pin-input:focus { border-color: #176150; box-shadow: 0 0 0 3px rgba(23, 97, 80, .12); }
.door-pin-input.door-pin-wrong { border-color: #B91C1C; box-shadow: 0 0 0 3px rgba(185, 28, 28, .12); }
.door-pin-input::placeholder { color: #B9C7C1; letter-spacing: .3em; }

/* ── The section nav: a page's own left list and its panels (Integrations — js/dashboard/integrations_page.js —, the
   Knowledge Base, AI rules, Settings, Advanced), the same in every product ── */
.integrations-sub-content {
    display: none;
}

.integrations-sub-content.active {
    display: block;
}

.meta-sub-content {
    display: none;
}

.meta-sub-content.active {
    display: block;
}
/* Shared left vertical secondary nav — matches the main sidebar. */
.subnav-layout { display: flex; gap: 24px; align-items: flex-start; }
.subnav {
    width: 220px; flex: none; display: flex; flex-direction: column; gap: 2px;
    background: #fff; padding: 12px 8px;
}
/* Slim scroll control for the side nav */
.subnav::-webkit-scrollbar { width: 6px; }
.subnav::-webkit-scrollbar-track { background: transparent; }
.subnav::-webkit-scrollbar-thumb { background: #D8D0C2; border-radius: 8px; }
.subnav { scrollbar-width: thin; scrollbar-color: #D8D0C2 transparent; }
.subnav .nav-divider { margin: 12px 6px; }
.subnav-content { flex: 1; min-width: 0; }
/* Coming-soon badge inside a sub-nav item */
.subnav-soon { margin-left: auto; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #9a8a70; background: #F1E7D6; border-radius: 999px; padding: 1px 7px; }
.subnav-item.active .subnav-soon { background: rgba(255, 255, 255, .2); color: #fff; }
.subnav-group {
    font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    color: #9a8a70; padding: 14px 12px 6px;
}
.subnav-group:first-child { padding-top: 2px; }
.subnav-item {
    display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
    padding: 10px 14px; border-radius: 8px; border: none; background: none; cursor: pointer;
    font-size: 14px; font-weight: 500; color: #475569; transition: background .15s, color .15s;
}
.subnav-item:hover { background: #f1f5f9; color: #1e293b; }
.subnav-item.active { background: #176150; color: #fff; }
@media (max-width: 768px) {
    .subnav-layout { flex-direction: column; }
    .subnav { width: 100%; flex-direction: row; flex-wrap: wrap; gap: 4px; position: static; max-height: none; overflow: visible; }
    .subnav-group { width: 100%; padding: 8px 4px 2px; }
}
/* Coming Soon card */
.coming-soon-card {
    background: #f9fafb;
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    padding: 40px 24px;
    text-align: center;
    color: #9ca3af;
}

.coming-soon-badge {
    display: inline-block;
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 2px 10px;
    text-transform: uppercase;
    margin-bottom: 12px;
}
