/* Quotes -- company-scoped spreadsheet editor. */

:root {
    --quotes-ink: #111827;
    --quotes-ink-soft: #374151;
    --quotes-muted: #6b7280;
    --quotes-border: #e5e7eb;
    --quotes-border-strong: #d1d5db;
    --quotes-soft: #f7f8fa;
    --quotes-surface: #ffffff;
    --quotes-blue: #2563eb;
    --quotes-danger: #b42318;
}

main.quotes-page {
    width: 100%;
    max-width: none;
    min-width: 0;
    margin: 0;
    padding: 40px 0 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 0;
    color: var(--quotes-ink);
    height: 100vh;
    height: 100dvh;
}

.quotes-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.quotes-toast {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 10002;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: min(420px, calc(100vw - 32px));
    padding: 12px 14px;
    border-radius: 8px;
    background: var(--quotes-ink);
    color: var(--quotes-surface);
    box-shadow: 0 10px 24px rgba(17, 24, 39, 0.25);
    font-size: 13px;
}

.quotes-toast[hidden] {
    display: none;
}

.quotes-toast-error {
    background: var(--quotes-danger);
}

.quotes-toast-message {
    flex: 1 1 auto;
    min-width: 0;
}

.quotes-toast-close {
    flex: 0 0 auto;
    appearance: none;
    border: none;
    background: none;
    color: inherit;
    font: inherit;
    font-size: 18px;
    line-height: 1;
    padding: 0 2px;
    cursor: pointer;
    opacity: 0.85;
}

.quotes-toast-close:hover {
    opacity: 1;
}

/* The open quote's storage path and last-saved time, injected as customHTML
   items at the far right of the spreadsheet's own menu bar (quotes.js's
   setupFileMenu) -- the path replaces the removed quote-picker dropdown's
   reclaimed toolbar space, and the saved time replaces the transient
   "Saved." status message, sitting just to its left. The menu bar's <li>
   wrapper stretches to the bar's full height (it's a flex child with the
   default stretch alignment) but, unlike the other items, doesn't itself
   re-center its content with flex, so a label sits at the top without
   this. */
li.dhx_menu-nav__item[data-dhx-id="quotes-saved"],
li.dhx_menu-nav__item[data-dhx-id="quotes-filepath"] {
    display: flex;
    align-items: center;
}

.quotes-saved-label,
.quotes-filepath {
    display: inline-block;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 12px;
    font-size: 12.5px;
    color: var(--quotes-muted);
}

.quotes-sheet-container {
    background: var(--quotes-surface);
    padding: 0;
    border-left: 0;
    border-right: 0;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.quotes-sheet-container > .dhx-spreadsheet {
    border-left: 0;
    border-right: 0;
}

.quotes-sheet-container .scroll-view-wrapper .scroll-view {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.quotes-sheet-container .scroll-view-wrapper .scroll-view::-webkit-scrollbar {
    display: none;
}

.quotes-sheet-container .dhx_grid-body {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.quotes-sheet-container .dhx_grid-body::-webkit-scrollbar,
.quotes-sheet-container .dhx_grid-body::-webkit-scrollbar-track,
.quotes-sheet-container .dhx_grid-body::-webkit-scrollbar-thumb {
    display: none;
    width: 0;
    height: 0;
}

.quotes-sheet-container .scroll-view-wrapper .x-scroll,
.quotes-sheet-container .scroll-view-wrapper .y-scroll {
    display: none !important;
}

.quotes-sheet-container .dhx-sheets-toolbar li.dhx_toolbar__item {
    cursor: grab;
    touch-action: none;
}

.quotes-sheet-container .dhx-sheets-toolbar li.quotes-sheet-tab-dragging {
    opacity: 0.5;
    cursor: grabbing;
}

/* Cell content default: top-aligned and wrapping instead of DHTMLX's own
   vertically-centered, clipped-on-overflow default -- reads better for the
   mostly-text content quotes are made of, and matches what a cell looks like
   once Fit Row Height has run on it anyway. An explicit per-cell format set
   via the toolbar (Format > Vertical align / Wrap) always wins: that writes
   its own generated class with these same properties (valign as
   align-items !important, so it beats this unconditionally; wrap/nowrap tie
   on specificity, but DHTMLX inserts that class into the page after this
   stylesheet has already loaded, so cascade order still favors the explicit
   choice). Horizontal "left" needs no rule -- .dhx_string-cell already
   defaults text cells to it; this only has to override the vertical-center
   and nowrap defaults. */
.quotes-sheet-container .dhx_grid-cell__content {
    align-items: flex-start;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Fit Row Height's offscreen measuring div (quotes.js's
   measureWrappedHeight) otherwise only wraps when the cell being measured
   carries its own explicit wrap formatting class -- it has no idea about the
   wrap-by-default rule above, since that lives on .dhx_grid-cell__content,
   a class the detector div never wears. Without this, a cell relying only
   on the default (no explicit per-cell format) would measure as its
   unwrapped single-line height while actually rendering wrapped on screen,
   so Fit Row Height would wrongly report no change needed. */
.dhx-spreadsheet-height-detector {
    white-space: pre-wrap;
    word-break: break-word;
}

.quotes-sheet-container .dhx-sheets-toolbar li.quotes-sheet-tab-drop-target {
    outline: 2px solid var(--quotes-blue);
    outline-offset: -2px;
}

.quotes-vault-dialog {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    background: rgba(17, 24, 39, 0.45);
}

.quotes-vault-dialog[hidden] {
    display: none;
}

.quotes-vault-panel {
    width: min(640px, 100%);
    max-height: 100%;
    padding: 16px;
    box-sizing: border-box;
    overflow: auto;
    color: var(--quotes-ink);
    background: var(--quotes-surface);
    border: 1px solid var(--quotes-border);
    border-radius: 6px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

.quotes-vault-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.quotes-vault-heading h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.quotes-vault-heading button {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    color: var(--quotes-ink);
    background: transparent;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.quotes-vault-heading button:hover {
    background: var(--quotes-soft);
}

.quotes-vault-status {
    margin: 0 0 8px;
    color: var(--quotes-muted);
    font-size: 13px;
}

.quotes-vault-container {
    width: 100%;
    height: min(420px, calc(100dvh - 120px));
    min-height: 200px;
}

.quotes-empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--quotes-muted);
    font-size: 14px;
    text-align: center;
    padding: 24px;
    box-sizing: border-box;
}

.quotes-empty-state a {
    color: var(--quotes-blue);
}

@media only screen and (max-width: 768px), (max-height: 500px) and (orientation: landscape) {
    main.quotes-page {
        width: calc(100% + 1em);
        margin-left: -0.5em;
        height: calc(100vh - 0.5em);
        height: calc(100dvh - 0.5em);
    }
}
