/* ==========================================================================
   Pangoni free tools / calculators
   Shared styles for /tools/* pages. Brand token: #274ABB (--pangoni-primary).
   Layout: light hero -> white tool body -> dark footer (matches site shell).
   ========================================================================== */

:root {
    --tool-primary: #274ABB;
    --tool-primary-dark: #172C6F;
    --tool-ink: #17203b;
    --tool-muted: #5b6472;
    --tool-line: #e4e8f0;
    --tool-bg-soft: #eef3ff;
    --tool-surface: #ffffff;
    --tool-radius: 14px;
    --tool-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
}

/* ---- Hub cards ---------------------------------------------------------- */
.tool-hub-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--tool-surface);
    border: 1px solid var(--tool-line);
    border-radius: var(--tool-radius);
    padding: 1.75rem;
    text-decoration: none;
    color: var(--tool-ink);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.tool-hub-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--tool-shadow);
    border-color: #c9d4f5;
    color: var(--tool-ink);
}

.tool-hub-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: var(--tool-bg-soft);
    color: var(--tool-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1.1rem;
}

.tool-hub-card h3 { font-size: 1.15rem; font-weight: 700; margin-bottom: .4rem; }
.tool-hub-card p { color: var(--tool-muted); font-size: .95rem; margin-bottom: 1rem; }
.tool-hub-card .tool-hub-go { margin-top: auto; color: var(--tool-primary); font-weight: 600; font-size: .95rem; }

/* ---- Calculator layout -------------------------------------------------- */
.tool-shell { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }

@media (min-width: 992px) {
    .tool-shell.tool-shell-split { grid-template-columns: 1.05fr .95fr; align-items: start; }
}

.tool-card {
    background: var(--tool-surface);
    border: 1px solid var(--tool-line);
    border-radius: var(--tool-radius);
    padding: 1.75rem;
    box-shadow: var(--tool-shadow);
}

.tool-card h2 { font-size: 1.15rem; font-weight: 700; margin-bottom: 1.25rem; }

.tool-card--sticky { position: sticky; top: 1.5rem; }

/* ---- Fields ------------------------------------------------------------- */
.tool-field { margin-bottom: 1.1rem; position: relative; }
.tool-field:last-child { margin-bottom: 0; }

.tool-field label { display: block; font-weight: 600; font-size: .9rem; color: var(--tool-ink); margin-bottom: .35rem; }
.tool-field .tool-hint { display: block; font-weight: 400; font-size: .8rem; color: var(--tool-muted); margin-top: .3rem; }

.tool-input-group { display: flex; align-items: stretch; border: 1px solid var(--tool-line); border-radius: 10px; overflow: hidden; background: #fff; transition: border-color .15s ease, box-shadow .15s ease; }
.tool-input-group:focus-within { border-color: var(--tool-primary); box-shadow: 0 0 0 3px rgba(39, 74, 187, .12); }
.tool-input-group .tool-affix { display: inline-flex; align-items: center; padding: 0 .8rem; background: #f4f6fb; color: var(--tool-muted); font-size: .9rem; font-weight: 600; border-right: 1px solid var(--tool-line); }
.tool-input-group .tool-affix.tool-affix-end { border-right: 0; border-left: 1px solid var(--tool-line); }
.tool-input-group input,
.tool-input-group select { flex: 1; border: 0; outline: 0; padding: .7rem .85rem; font-size: 1rem; color: var(--tool-ink); background: transparent; width: 100%; min-width: 0; }

.tool-input { width: 100%; border: 1px solid var(--tool-line); border-radius: 10px; padding: .7rem .85rem; font-size: 1rem; color: var(--tool-ink); background: #fff; transition: border-color .15s ease, box-shadow .15s ease; }
.tool-input:focus, textarea.tool-input:focus { border-color: var(--tool-primary); box-shadow: 0 0 0 3px rgba(39, 74, 187, .12); outline: 0; }

/* Invalid state (set by common.js validation) */
.tool-input.is-invalid,
.tool-input-group.is-invalid { border-color: #dc3545; }
.tool-input.is-invalid:focus,
.tool-input-group.is-invalid:focus-within { border-color: #dc3545; box-shadow: 0 0 0 3px rgba(220, 53, 69, .16); }
.tool-error { display: none; color: #dc3545; font-size: .8rem; margin-top: .35rem; }

/* Always-uppercase fields (receipt/agreement names & numbers) — keep placeholders normal case */
.text-uppercase::placeholder { text-transform: none; }

/* Soft sign-up nudge shown beneath each tool */
.tool-more { margin-top: 1.25rem; text-align: center; font-size: .92rem; color: var(--tool-muted); background: var(--tool-bg-soft); border: 1px solid #dbe4fb; border-radius: 12px; padding: .85rem 1.1rem; }
.tool-more a { color: var(--tool-primary); font-weight: 600; text-decoration: none; }
.tool-more a:hover { text-decoration: underline; }

/* ---- Date picker (assets/js/tools/datepicker.js) ------------------------ */
.dp-native-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; opacity: 0; pointer-events: none; }

.dp-trigger { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: .5rem; border: 1px solid var(--tool-line); border-radius: 10px; padding: .7rem .85rem; font-size: 1rem; color: var(--tool-ink); background: #fff; cursor: pointer; text-align: left; transition: border-color .15s ease, box-shadow .15s ease; }
.dp-trigger:hover { border-color: #c9d4f5; }
.dp-trigger:focus, .dp-trigger.is-open { border-color: var(--tool-primary); box-shadow: 0 0 0 3px rgba(39, 74, 187, .12); outline: 0; }
.dp-trigger .bi { color: var(--tool-muted); font-size: 1.05rem; flex: 0 0 auto; }
.dp-value.is-placeholder { color: var(--tool-muted); }

.dp-popover { position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; width: 300px; max-width: calc(100vw - 2rem); background: #fff; border: 1px solid var(--tool-line); border-radius: 14px; box-shadow: var(--tool-shadow); padding: .85rem; }
.dp-popover.dp-above { top: auto; bottom: calc(100% + 6px); }

.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.dp-title { font-weight: 700; font-size: .95rem; color: var(--tool-ink); }
.dp-nav { border: 0; background: transparent; color: var(--tool-muted); width: 32px; height: 32px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.dp-nav:hover { background: var(--tool-bg-soft); color: var(--tool-primary); }

.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-dow { margin-bottom: .25rem; }
.dp-dow span { text-align: center; font-size: .72rem; font-weight: 600; color: var(--tool-muted); padding: .2rem 0; }

.dp-day { border: 0; background: transparent; color: var(--tool-ink); aspect-ratio: 1 / 1; min-height: 36px; border-radius: 8px; font-size: .9rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.dp-day:hover { background: var(--tool-bg-soft); }
.dp-day:focus { outline: 2px solid var(--tool-primary); outline-offset: -2px; }
.dp-day.is-today { box-shadow: inset 0 0 0 1px var(--tool-primary); }
.dp-day.is-selected { background: var(--tool-primary); color: #fff; }
.dp-day.is-selected:hover { background: var(--tool-primary-dark); }
.dp-day.is-empty { background: transparent; cursor: default; }

.dp-foot { display: flex; justify-content: space-between; margin-top: .6rem; padding-top: .55rem; border-top: 1px solid var(--tool-line); }
.dp-link { border: 0; background: transparent; color: var(--tool-primary); font-size: .85rem; font-weight: 600; cursor: pointer; padding: .2rem .3rem; border-radius: 6px; }
.dp-link:hover { background: var(--tool-bg-soft); }

@media (max-width: 480px) {
  .dp-day { min-height: 42px; }
}

/* Tidy the native picker for the no-JS / touch-fallback case */
input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .55; }
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: .85; }

/* Segmented toggle (e.g. monthly / annual) */
.tool-toggle { display: inline-flex; background: #eef1f7; border-radius: 10px; padding: 3px; gap: 3px; }
.tool-toggle button { border: 0; background: transparent; padding: .4rem .9rem; border-radius: 8px; font-size: .88rem; font-weight: 600; color: var(--tool-muted); cursor: pointer; }
.tool-toggle button[aria-pressed="true"] { background: #fff; color: var(--tool-primary); box-shadow: 0 1px 2px rgba(16, 24, 40, .12); }

.tool-checks { display: grid; gap: .35rem; }
.tool-check { font-size: .92rem; color: var(--tool-ink); }
.tool-check .text-lg { display: inline-flex; align-items: center; line-height: 1; }
.tool-check .form-check-input { margin: 0; vertical-align: middle; cursor: pointer; }
.tool-check .form-check-label { margin: 0; cursor: pointer; line-height: 1.3; }

/* Brand-blue checkbox state (theme default is #5c60f5) */
.form-check-input:checked { background-color: var(--tool-primary); border-color: var(--tool-primary); }
.form-check-input:focus { border-color: var(--tool-primary); box-shadow: 0 0 0 3px rgba(39, 74, 187, .15); }

/* ---- Results ------------------------------------------------------------ */
.result-primary { background: linear-gradient(135deg, var(--tool-primary), var(--tool-primary-dark)); color: #fff; border-radius: 12px; padding: 1.4rem 1.5rem; margin-bottom: 1.1rem; }
.result-primary .result-label { font-size: .85rem; opacity: .85; margin-bottom: .2rem; }
.result-primary .result-value { font-size: 2rem; font-weight: 800; line-height: 1.1; }

.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.result-stat { border: 1px solid var(--tool-line); border-radius: 12px; padding: .95rem 1.1rem; background: #fff; }
.result-stat .result-label { font-size: .8rem; color: var(--tool-muted); margin-bottom: .2rem; }
.result-stat .result-value { font-size: 1.35rem; font-weight: 700; color: var(--tool-ink); }
.result-stat.is-warn { background: #fff8ec; border-color: #f6dfb0; }
.result-stat.is-warn .result-value { color: #9a6a12; }

/* Inline SVG icons (Bootstrap Icons shapes, self-hosted inline — no icon font). */
.bi { display: inline-block; vertical-align: -0.125em; fill: currentColor; }

.tool-note { display: flex; gap: .6rem; align-items: flex-start; font-size: .9rem; color: var(--tool-muted); background: var(--tool-bg-soft); border-left: 4px solid var(--tool-primary); border-radius: 8px; padding: .85rem 1rem; margin-top: 1.1rem; }
.tool-note .bi { color: var(--tool-primary); margin-top: .15rem; flex: 0 0 auto; }
.tool-note.is-flag { background: #fff8ec; border-left-color: #d9962a; color: #7a5514; }
.tool-note.is-flag .bi { color: #d9962a; }

.tool-disclaimer { font-size: .8rem; color: var(--tool-muted); margin-top: 1rem; }

/* ---- Embed panel -------------------------------------------------------- */
.tool-embed { border: 1px dashed #c3ccdf; border-radius: var(--tool-radius); padding: 1.4rem; background: #fbfcfe; }
.tool-embed h3 { font-size: 1rem; font-weight: 700; margin-bottom: .3rem; }
.tool-embed p { font-size: .9rem; color: var(--tool-muted); margin-bottom: .9rem; }
.tool-embed textarea { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; color: #33405c; background: #fff; border: 1px solid var(--tool-line); border-radius: 10px; padding: .8rem; resize: vertical; min-height: 84px; }
.tool-copy-btn { margin-top: .7rem; }
.tool-copy-btn.is-copied { background: #167c3f !important; border-color: #167c3f !important; }

/* ---- Generated document preview (agreement / receipt) ------------------- */
.doc-preview { background: #fff; border: 1px solid var(--tool-line); border-radius: var(--tool-radius); box-shadow: var(--tool-shadow); padding: 2.25rem 2.5rem; color: #1c2333; }
.doc-preview h1, .doc-preview h2, .doc-preview h3 { color: #101828; }
.doc-preview .doc-title { text-align: center; font-size: 1.35rem; font-weight: 800; letter-spacing: .02em; margin-bottom: .35rem; }
.doc-preview .doc-sub { text-align: center; color: var(--tool-muted); font-size: .85rem; margin-bottom: 1.6rem; }
.doc-preview .doc-clause { margin-bottom: 1rem; font-size: .95rem; line-height: 1.7; }
.doc-preview .doc-clause b { color: #101828; }
.doc-preview .doc-sign { display: flex; gap: 2.5rem; margin-top: 2.25rem; flex-wrap: wrap; }
.doc-preview .doc-sign > div { flex: 1; min-width: 180px; }
.doc-preview .doc-sign .doc-line { border-top: 1px solid #9aa3b5; margin-top: 2.5rem; padding-top: .35rem; font-size: .8rem; color: var(--tool-muted); }

/* Receipt-specific */
.receipt-doc { max-width: 640px; margin: 0 auto; }
.receipt-doc .receipt-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; border-bottom: 2px solid var(--tool-primary); padding-bottom: 1rem; margin-bottom: 1.25rem; }
.receipt-doc .receipt-brand { font-size: 1.2rem; font-weight: 800; color: var(--tool-primary-dark); }
.receipt-doc .receipt-badge { text-align: right; }
.receipt-doc .receipt-badge .receipt-word { font-size: 1.05rem; font-weight: 800; letter-spacing: .12em; color: #101828; text-transform: uppercase; }
.receipt-doc table.receipt-table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.receipt-doc table.receipt-table td { padding: .55rem .25rem; border-bottom: 1px solid #edf0f6; font-size: .95rem; }
.receipt-doc table.receipt-table td:first-child { color: var(--tool-muted); width: 42%; }
.receipt-doc table.receipt-table td:last-child { text-align: right; font-weight: 600; color: #101828; }
.receipt-doc .receipt-total { display: flex; justify-content: space-between; align-items: center; background: var(--tool-bg-soft); border-radius: 10px; padding: .9rem 1.1rem; margin-top: .75rem; }
.receipt-doc .receipt-total .r-label { font-weight: 700; color: var(--tool-primary-dark); }
.receipt-doc .receipt-total .r-value { font-weight: 800; font-size: 1.25rem; color: var(--tool-primary-dark); }
.receipt-doc .receipt-foot { margin-top: 1.5rem; font-size: .78rem; color: var(--tool-muted); text-align: center; }

/* ---- Embed mode (rendered inside an <iframe>, ?embed=1) ----------------- */
.embed-attribution { display: none; }

body.embed-mode { background: #fff !important; }
body.embed-mode > header[role="banner"],
body.embed-mode > footer[role="contentinfo"],
body.embed-mode .no-embed { display: none !important; }
body.embed-mode main { padding: 0 !important; }
body.embed-mode .tool-hero { display: none !important; }
body.embed-mode .tool-embed { display: none !important; }
body.embed-mode .embed-attribution {
    display: flex; align-items: center; justify-content: center; gap: .4rem;
    font-size: .8rem; color: var(--tool-muted); padding: .7rem; border-top: 1px solid var(--tool-line);
}
body.embed-mode .embed-attribution a { color: var(--tool-primary); font-weight: 700; text-decoration: none; }
body.embed-mode .tool-embed-wrap { padding: 1rem !important; }

/* ---- Print (Download PDF via window.print) ------------------------------ */
@media print {
    /* Print only the generated document card — hide chrome, inputs, CTAs, and embed/promo blocks */
    header[role="banner"], footer[role="contentinfo"], nav, .navbar,
    .tool-hero, .tool-card--inputs, .tool-actions,
    .tool-embed, .tool-more, .no-embed, .no-print { display: none !important; }
    body { background: #fff !important; }
    main { padding: 0 !important; }
    .tool-shell, .tool-shell-split { display: block !important; }
    .print-doc { box-shadow: none !important; border: 0 !important; margin: 0 !important; padding: 0 !important; }
    .doc-preview { box-shadow: none !important; border: 0 !important; }
    a[href]::after { content: ""; }
}
