/* Syncfusion Fluent 2 mapped onto the completIn tokens (design spec §10).
   Loaded after fluent2.css / fluent2-dark.css, so this :root block wins over the theme's own :root.
   Every value points at a tokens.css variable, which already flips between dark (:root) and light
   (.t-light on <html>), so one block covers both theme files.
   Variable names checked against _content/Syncfusion.Blazor.Themes/fluent2.css 33.1.49. */

:root {
    --e-font-family: var(--font-body);

    /* brand */
    --color-sf-primary: var(--accent);
    --color-sf-primary-text-color: var(--on-accent);
    --color-sf-primary-light: var(--accent-soft);
    --color-sf-primary-lighter: var(--accent-soft);
    --color-sf-primary-dark: var(--accent-text);
    --color-sf-primary-darker: var(--accent-text);
    --color-sf-primary-label-color: var(--accent-text);
    --color-sf-primary-cell-selection: var(--accent-soft);

    /* primary button states (Fluent 2 hard-codes blue hex values for each of them) */
    --color-sf-primary-bg-color: var(--accent);
    --color-sf-primary-border-color: var(--accent);
    --color-sf-primary-text: var(--on-accent);
    --color-sf-primary-bg-color-hover: var(--accent);
    --color-sf-primary-border-color-hover: var(--accent);
    --color-sf-primary-text-hover: var(--on-accent);
    --color-sf-primary-bg-color-pressed: var(--accent-text);
    --color-sf-primary-border-color-pressed: var(--accent-text);
    --color-sf-primary-text-pressed: var(--on-accent);
    --color-sf-primary-bg-color-focus: var(--accent);
    --color-sf-primary-border-color-focus: var(--accent);
    --color-sf-primary-text-focus: var(--on-accent);
    --color-sf-primary-bg-color-selected: var(--accent-text);
    --color-sf-primary-border-color-selected: var(--accent-text);
    --color-sf-primary-text-selected: var(--on-accent);
    --color-sf-primary-bg-color-disabled: var(--raise);
    --color-sf-primary-border-color-disabled: var(--raise);
    --color-sf-primary-text-disabled: var(--muted);

    /* secondary (default) buttons */
    --color-sf-secondary-bg-color: var(--surface);
    --color-sf-secondary-border-color: var(--line);
    --color-sf-secondary-text-color: var(--text);
    --color-sf-secondary-bg-color-hover: var(--raise);
    --color-sf-secondary-border-color-hover: var(--line);
    --color-sf-secondary-text-color-hover: var(--text);
    --color-sf-secondary-bg-color-pressed: var(--raise);
    --color-sf-secondary-border-color-pressed: var(--muted);
    --color-sf-secondary-text-color-pressed: var(--text);
    --color-sf-secondary-bg-color-focus: var(--surface);
    --color-sf-secondary-border-color-focus: var(--accent-text);
    --color-sf-secondary-text-color-focus: var(--text);
    --color-sf-secondary-bg-color-selected: var(--raise);
    --color-sf-secondary-border-color-selected: var(--line);
    --color-sf-secondary-text-color-selected: var(--text);
    --color-sf-secondary-bg-color-disabled: var(--raise);
    --color-sf-secondary-border-color-disabled: var(--line);
    --color-sf-secondary-text-color-disabled: var(--muted);

    /* surfaces */
    --color-sf-content-bg-color: var(--surface);
    --color-sf-content-bg-color-alt1: var(--surface);
    --color-sf-content-bg-color-alt2: var(--raise);
    --color-sf-content-bg-color-alt3: var(--raise);
    --color-sf-content-bg-color-alt4: var(--raise);
    --color-sf-content-bg-color-alt5: var(--raise);
    --color-sf-content-bg-color-alt6: var(--raise);
    --color-sf-content-bg-color-hover: var(--raise);
    --color-sf-content-bg-color-pressed: var(--raise);
    --color-sf-content-bg-color-focus: var(--raise);
    --color-sf-content-bg-color-selected: var(--accent-soft);
    --color-sf-content-bg-color-dragged: var(--accent-soft);
    --color-sf-content-bg-color-disabled: var(--raise);
    --color-sf-flyout-bg-color: var(--surface);
    --color-sf-flyout-bg-color-hover: var(--raise);
    --color-sf-flyout-bg-color-pressed: var(--raise);
    --color-sf-flyout-bg-color-selected: var(--accent-soft);
    --color-sf-flyout-bg-color-focus: var(--raise);
    --color-sf-table-bg-color-hover: var(--raise);
    --color-sf-table-bg-color-pressed: var(--raise);
    --color-sf-table-bg-color-selected: var(--accent-soft);
    /* modal backdrop: always a dark scrim (fluent2-dark.css ships an invalid rgba($black, .4) here) */
    --color-sf-overlay-bg-color: color-mix(in srgb, var(--nav-bg) 60%, transparent);

    /* text and icons (fluent2-dark.css ships a typo in content-text-color-focus) */
    --color-sf-content-text-color: var(--text);
    --color-sf-content-text-color-alt1: var(--text);
    --color-sf-content-text-color-alt2: var(--muted);
    --color-sf-content-text-color-alt3: var(--muted);
    --color-sf-content-text-color-hover: var(--text);
    --color-sf-content-text-color-pressed: var(--text);
    --color-sf-content-text-color-focus: var(--text);
    --color-sf-content-text-color-selected: var(--text);
    --color-sf-content-text-color-dragged: var(--text);
    --color-sf-content-text-color-disabled: var(--muted);
    --color-sf-placeholder-text-color: var(--muted);
    --color-sf-flyout-text-color: var(--text);
    --color-sf-icon-color: var(--muted);
    --color-sf-icon-color-hover: var(--text);
    --color-sf-icon-color-pressed: var(--text);
    --color-sf-icon-color-disabled: var(--muted);

    /* borders */
    --color-sf-border-light: var(--line);
    --color-sf-border: var(--line);
    --color-sf-border-alt: var(--muted);
    --color-sf-border-dark: var(--line);
    --color-sf-border-hover: var(--muted);
    --color-sf-border-pressed: var(--muted);
    --color-sf-border-focus: var(--accent-text);
    --color-sf-border-selected: var(--accent-text);
    --color-sf-border-disabled: var(--line);
    --color-sf-border-error: var(--danger);
    --color-sf-border-warning: var(--warn);
    --color-sf-border-success: var(--accent-text);
    --color-sf-border-info: var(--info);
    --color-sf-flyout-border: var(--line);

    /* status */
    --color-sf-success: var(--accent-text);
    --color-sf-info: var(--info);
    --color-sf-warning: var(--warn);
    --color-sf-danger: var(--danger);
    --color-sf-danger-bg-color: var(--danger);
    --color-sf-danger-border-color: var(--danger);
    --color-sf-danger-text: var(--on-danger);
}

/* ---------- buttons: 44px, 8px radius, Manrope (design spec §5.3) ----------
   Text buttons only: icon-only buttons (dialog close, grid/pager icons) keep Syncfusion's sizing. */

.e-btn:not(.e-icon-btn) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--control-height);
    padding: 0 16px;
    border-radius: var(--radius-control);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
}

.e-btn.e-primary { font-weight: 700; }

/* compact action inside a card row (design: settings.html, "Change password", "Manage") */
.e-btn.btn-compact:not(.e-icon-btn) { padding: 0 12px; font-size: 13px; }

/* destructive action isolated on the left of a modal footer: red text, no fill */
.modal-footer .e-btn.btn-destructive-text,
.modal-footer .e-btn.btn-destructive-text:hover,
.modal-footer .e-btn.btn-destructive-text:focus,
.modal-footer .e-btn.btn-destructive-text:active {
    background: transparent;
    border-color: transparent;
    color: var(--danger);
}

/* non-destructive action on the left of a modal footer (Unarchive): accent text, no fill */
.modal-footer .e-btn.btn-neutral-text,
.modal-footer .e-btn.btn-neutral-text:hover,
.modal-footer .e-btn.btn-neutral-text:focus,
.modal-footer .e-btn.btn-neutral-text:active {
    background: transparent;
    border-color: transparent;
    color: var(--accent-text);
}

/* ---------- top-bar month picker popup (SfCalendar in month view) ---------- */

.month-picker-popup .e-calendar {
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    background: var(--surface);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

/* ---------- popups ---------- */

.e-datepicker.e-popup-wrapper,
.e-popup.e-popup-open {
    border-radius: var(--radius-card);
}

/* ---------- toast (one SfToast in MainLayout, fed by ToastService) ---------- */

.e-toast-container .e-toast.panel-toast {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--accent);
    border-radius: var(--radius-control);
    box-shadow: var(--shadow-dialog);
    font-family: var(--font-body);
    font-weight: 600;
}

.e-toast-container .e-toast.panel-toast.panel-toast--error { border-color: var(--danger); }

/* ---------- dialog (PanelDialog: modal pattern of design spec §8) ---------- */

.e-dialog.panel-dialog {
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 112px) !important;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: var(--radius-dialog);
    box-shadow: var(--shadow-dialog);
    overflow: hidden;
}

.e-dialog.panel-dialog .e-dlg-header-content {
    padding: 0;
    background: var(--surface);
    border: 0;
    border-bottom: 1px solid var(--line);
}

.e-dialog.panel-dialog .e-dlg-header { width: 100%; line-height: 1.45; white-space: normal; overflow: visible; }
.e-dialog.panel-dialog .modal-header-text { min-width: 0; overflow-wrap: anywhere; } /* long titles wrap at 390px */
.e-dialog.panel-dialog .e-dlg-content { padding: 0; background: var(--surface); color: var(--text); font-size: 14px; }
.e-dialog.panel-dialog .e-footer-content { padding: 0; border: 0; background: var(--raise); }
.e-dialog.panel-dialog .modal-footer { border-top: 1px solid var(--line); }

/* ---------- fields (SfTextBox, SfMaskedTextBox, SfDropDownList): 44px, 8px radius, token surfaces ----------
   Fluent 2 draws a heavier underline from --color-sf-border-alt; inside a field it is a plain hairline. */

.field { --color-sf-border-alt: var(--line); }

.field .e-input-group,
.field .e-input-group.e-control-wrapper {
    min-height: var(--control-height);
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    background: var(--field);
    margin: 0;
    padding: 0 12px;
}

.field .e-input-group:not(.e-disabled):hover,
.field .e-input-group.e-control-wrapper:not(.e-disabled):hover { border-color: var(--muted); }

.field .e-input-group.e-input-focus,
.field .e-input-group.e-control-wrapper.e-input-focus { border-color: var(--accent-text); }

.field .e-input-group input.e-input,
.field .e-input-group.e-control-wrapper input.e-input {
    min-height: calc(var(--control-height) - 2px);
    padding: 0;
    background: transparent;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
}

.field .e-input-group.e-control-wrapper.field-mono input.e-input { font-family: var(--font-mono); font-size: 13px; }
.field .e-input-group::before, .field .e-input-group::after { display: none; }

/* ---------- grid (a .panel-grid wrapper around the SfGrid): raise header with mono caps, 60px rows, hairlines ---------- */

.panel-grid .e-grid {
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    background: var(--surface);
    font-family: var(--font-body);
    font-size: 14px;
}

.panel-grid .e-grid .e-gridheader {
    background: var(--raise);
    border-top: 0;
    border-bottom: 1px solid var(--line);
}

.panel-grid .e-grid .e-headercell {
    background: var(--raise);
    padding: 0 12px;
    height: 40px;
    border: 0;
}

.panel-grid .e-grid .e-headercelldiv,
.panel-grid .e-grid .e-headertext {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.panel-grid .e-grid .e-rowcell {
    padding: 0 12px;
    border: 0;
    border-top: 1px solid var(--line);
    color: var(--text);
    background: var(--surface);
    line-height: 1.4;
}

.panel-grid .e-grid .e-row:first-child .e-rowcell { border-top: 0; }
.panel-grid .e-grid .e-headercell:first-child, .panel-grid .e-grid .e-rowcell:first-child { padding-left: 20px; }
.panel-grid .e-grid .e-headercell:last-child, .panel-grid .e-grid .e-rowcell:last-child { padding-right: 20px; }
.panel-grid .e-grid .e-emptyrow td { border: 0; }
.panel-grid .e-grid .e-gridpager {
    border: 0;
    border-top: 1px solid var(--line);
    background: var(--surface);
    color: var(--muted);
}

/* filled red button of a destructive confirmation ("End contract", "Cancel NFS-e") */
.modal-footer .e-btn.btn-destructive-fill,
.modal-footer .e-btn.btn-destructive-fill:hover,
.modal-footer .e-btn.btn-destructive-fill:focus,
.modal-footer .e-btn.btn-destructive-fill:active {
    background: var(--danger);
    border-color: var(--danger);
    color: var(--on-danger);
    font-weight: 700;
}

/* ---------- row menu (SfDropDownButton, icon only, no caret) on the open billing periods grid ---------- */

.e-btn.e-dropdown-btn.row-menu {
    width: var(--control-height);
    height: var(--control-height);
    border-radius: var(--radius-control);
    color: var(--muted);
}

.e-btn.e-dropdown-btn.row-menu:hover { color: var(--text); }

.e-btn.e-dropdown-btn.row-menu .e-btn-icon.icon-more {
    width: 18px;
    height: 18px;
    background-color: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='5' cy='12' r='1.8'/%3E%3Ccircle cx='12' cy='12' r='1.8'/%3E%3Ccircle cx='19' cy='12' r='1.8'/%3E%3C/svg%3E") center / 18px no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='5' cy='12' r='1.8'/%3E%3Ccircle cx='12' cy='12' r='1.8'/%3E%3Ccircle cx='19' cy='12' r='1.8'/%3E%3C/svg%3E") center / 18px no-repeat;
}

.e-dropdown-popup ul .e-item {
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    min-height: var(--control-height);
    display: flex;
    align-items: center;
}

/* ---------- tooltip (Late entry chip) ---------- */

.e-tooltip-wrap.panel-tooltip {
    background: var(--text);
    border-radius: var(--radius-control);
}

.e-tooltip-wrap.panel-tooltip .e-tip-content {
    color: var(--bg);
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 600;
    padding: 6px 10px;
}

/* ---------- import uploader (SfUploader inside the .import-drop area): only its Browse button shows ---------- */

.import-drop .e-upload.import-uploader {
    border: 0;
    background: transparent;
    width: auto;
}

.import-drop .e-upload.import-uploader .e-file-select-wrap { padding: 0; }
.import-drop .e-upload.import-uploader .e-file-drop { display: none; }
.import-drop.e-upload-drag-hover { border-color: var(--accent-text); }

/* system picker in a review row: 40px instead of 44px, red border until a system is chosen */
.import-pick .e-input-group.e-control-wrapper { min-height: 40px; }
.import-pick .e-input-group.e-control-wrapper input.e-input { min-height: 38px; }
.import-pick.import-pick--missing .e-input-group.e-control-wrapper { border-color: var(--warn); }

/* row action that starts issuing (design: invoices.html "Issue"): accent outline */
.e-btn.btn-accent-outline:not(:disabled),
.e-btn.btn-accent-outline:not(:disabled):hover,
.e-btn.btn-accent-outline:not(:disabled):focus {
    border-color: var(--accent);
    color: var(--accent-text);
}

/* ---------- receipt uploader (SfUploader inside the .receipt-box): only its Browse button shows ---------- */

.receipt-box .e-upload.receipt-uploader {
    border: 0;
    background: transparent;
    width: auto;
}

.receipt-box .e-upload.receipt-uploader .e-file-select-wrap { padding: 0; }
.receipt-box .e-upload.receipt-uploader .e-file-drop { display: none; }
