/* =========================================================
   PS Finance Tools — Shared Design System
   Scoped under .ps-fin-tool so nothing leaks into the theme.
   This is an intentionally self-contained copy of the same
   framework used by the HR Tools plugin (see architecture
   notes) — namespaced with ps-fin- / .ps-fin-tool instead of
   ps-hr- / .ps-hr-tool so the two plugins never collide if
   both are active on the same page.
   Individual tools (e.g. payment-voucher.css) add their own
   document-specific styles on top of this.
   ========================================================= */

.ps-fin-tool {
    /* --------------------------------------------------------
       COLOR & FONT INHERITANCE
       Tries your theme's own Global Styles color palette first
       (var(--wp--preset--color--...), already defined by most
       block themes: Astra, Kadence, GeneratePress, Blocksy...).
       Falls back to the hex value after the comma if not found.

       >>> To force your exact brand color, replace the fallback
       >>> hex value below with your site's real accent color.
       -------------------------------------------------------- */
    --ps-fin-accent: var(--wp--preset--color--primary, #2f6feb);
    --ps-fin-accent-dark: var(--wp--preset--color--secondary, #1f4fbf);
    --ps-fin-text: var(--wp--preset--color--foreground, #232323);
    --ps-fin-muted: #6b7280;
    --ps-fin-border: #e2e5e9;
    --ps-fin-bg-panel: #f7f8fa;
    --ps-fin-bg-paper: #ffffff;
    --ps-fin-radius: 6px;

    font-family: inherit;
    color: var(--ps-fin-text);
    max-width: 1150px;
    margin: 2em auto;
    box-sizing: border-box;
}

.ps-fin-tool *,
.ps-fin-tool *::before,
.ps-fin-tool *::after {
    box-sizing: inherit;
    font-family: inherit;
}

/* ---------------- Top toolbar (title + actions) ---------------- */

.ps-fin-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 18px;
    margin-bottom: 20px;
    background: var(--ps-fin-bg-panel);
    border: 1px solid var(--ps-fin-border);
    border-radius: var(--ps-fin-radius);
}

.ps-fin-toolbar-title {
    margin: 0;
    font-size: 1.15em;
    font-weight: 700;
    color: var(--ps-fin-text);
}

.ps-fin-toolbar-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ---------------- Panels & grid ---------------- */

.ps-fin-grid {
    display: grid;
    grid-template-columns: minmax(280px, 380px) 1fr;
    gap: 28px;
    align-items: start;
}

@media (max-width: 800px) {
    .ps-fin-grid {
        grid-template-columns: 1fr;
    }
}

.ps-fin-panel {
    background: var(--ps-fin-bg-panel);
    border: 1px solid var(--ps-fin-border);
    border-radius: var(--ps-fin-radius);
    padding: 20px 22px;
}

.ps-fin-preview-panel {
    background: transparent;
    border: none;
    padding: 0;
}

.ps-fin-panel-title {
    margin: 0 0 14px;
    font-size: 1.05em;
    font-weight: 700;
    color: var(--ps-fin-text);
}

.ps-fin-group-title {
    margin: 20px 0 8px;
    font-size: 0.85em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--ps-fin-muted);
}

.ps-fin-field-group:first-of-type .ps-fin-group-title {
    margin-top: 0;
}

/* ---------------- Form fields ---------------- */

.ps-fin-label {
    display: block;
    font-size: 0.88em;
    font-weight: 600;
    margin: 10px 0 4px;
    color: var(--ps-fin-text);
}

.ps-fin-optional {
    font-weight: 400;
    color: var(--ps-fin-muted);
}

.ps-fin-input {
    width: 100%;
    padding: 9px 11px;
    font-size: 0.95em;
    border: 1px solid var(--ps-fin-border);
    border-radius: var(--ps-fin-radius);
    background: var(--ps-fin-bg-paper);
    color: var(--ps-fin-text);
    line-height: 1.4;
}

.ps-fin-input:focus {
    outline: none;
    border-color: var(--ps-fin-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ps-fin-accent) 20%, transparent);
}

.ps-fin-textarea {
    resize: vertical;
}

.ps-fin-radio-row {
    display: flex;
    gap: 16px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.ps-fin-radio,
.ps-fin-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
}

.ps-fin-checkbox {
    margin-top: 6px;
}

.ps-fin-hidden {
    display: none !important;
}

.ps-fin-link-btn {
    background: none;
    border: none;
    padding: 0;
    margin-top: 8px;
    color: var(--ps-fin-accent);
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
}

.ps-fin-logo-preview-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.ps-fin-logo-preview {
    max-height: 48px;
    max-width: 140px;
    object-fit: contain;
    border: 1px solid var(--ps-fin-border);
    border-radius: 4px;
    background: #fff;
    padding: 4px;
}

/* ---------------- Buttons ---------------- */

.ps-fin-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 11px 20px;
    font-size: 0.95em;
    font-weight: 600;
    border-radius: var(--ps-fin-radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: opacity 0.15s ease, background-color 0.15s ease;
    white-space: nowrap;
}

.ps-fin-btn-primary {
    background: var(--ps-fin-accent);
    color: #fff;
}

.ps-fin-btn-primary:hover {
    background: var(--ps-fin-accent-dark);
}

.ps-fin-btn-secondary {
    background: transparent;
    color: var(--ps-fin-text);
    border-color: var(--ps-fin-border);
}

.ps-fin-btn-secondary:hover {
    background: #fff;
}

.ps-fin-btn-small {
    padding: 6px 12px;
    font-size: 0.85em;
}

/* ---------------- Layout / design picker ---------------- */

.ps-fin-layout-picker-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 18px;
}

.ps-fin-picker-arrow {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--ps-fin-border);
    background: #fff;
    color: var(--ps-fin-text);
    font-size: 1em;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ps-fin-picker-arrow:hover {
    border-color: var(--ps-fin-accent);
    color: var(--ps-fin-accent);
}

.ps-fin-layout-picker {
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 4px 2px 10px;
    flex: 1 1 auto;
    min-width: 0;
    scrollbar-width: thin;
}

.ps-fin-layout-picker::-webkit-scrollbar {
    height: 6px;
}

.ps-fin-layout-picker::-webkit-scrollbar-thumb {
    background: var(--ps-fin-border);
    border-radius: 3px;
}

.ps-fin-swatch {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: 108px;
    flex: 0 0 108px;
    border: 2px solid var(--ps-fin-border);
    border-radius: var(--ps-fin-radius);
    background: #fff;
    cursor: pointer;
    padding: 8px;
    text-align: center;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ps-fin-swatch:hover {
    border-color: var(--ps-fin-accent);
}

.ps-fin-swatch.is-active {
    border-color: var(--ps-fin-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ps-fin-accent) 18%, transparent);
}

.ps-fin-swatch-preview {
    display: block;
    line-height: 0;
    border-radius: 3px;
    background: #f2f3f5;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

.ps-fin-swatch-preview svg {
    display: block;
    width: 100%;
    height: auto;
}

.ps-fin-swatch-label {
    display: block;
    font-size: 0.74em;
    font-weight: 600;
    color: var(--ps-fin-text);
    line-height: 1.3;
}

/* ---------------- Print-only isolation ----------------
   Instead of hiding the rest of the page with visibility:hidden
   (which still reserves layout space and causes blank extra
   pages), we clone the document into a dedicated container that
   lives directly under <body> and only that container is shown
   when printing. Everything else is fully removed with
   display:none, so no leftover space, no blank second page.
------------------------------------------------------------ */

.ps-fin-print-only {
    display: none;
}

@media print {
    body > *:not(.ps-fin-print-only) {
        display: none !important;
    }

    .ps-fin-print-only {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        max-width: none !important;
    }

    /* Chrome/Edge/Firefox silently drop background colors and
       images when printing unless told otherwise. Without this,
       colored header bands, badges, and tinted sections turn
       white on paper/PDF, which can also make white text on top
       of them disappear entirely. */
    .ps-fin-print-only,
    .ps-fin-print-only * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    /* Elements marked screen-only (e.g. the letterhead spacer's
       reminder label) still get cloned into the print area since
       we clone the whole document — explicitly hide them here. */
    .ps-fin-print-only .ps-fin-hide-print {
        display: none !important;
    }
}
