/* Shared styles for every free tool page (templates/free_tools/*) — CSS logical properties
   throughout so the one stylesheet serves both RTL (ar) and LTR (en) without duplication. */

.tool-container { max-width: 44rem; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

.tool-breadcrumb { font-size: .85rem; color: var(--muted-foreground); margin-bottom: 1rem; }
.tool-breadcrumb a { color: var(--muted-foreground); text-decoration: none; }
.tool-breadcrumb a:hover { color: var(--foreground); }

.tool-title { font-size: 1.85rem; font-weight: 800; line-height: 1.3; margin: .25rem 0 .5rem; }
.tool-promise { font-size: 1.05rem; color: var(--muted-foreground); margin-bottom: 1.75rem; line-height: 1.7; }

.tool-widget {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.5rem; box-shadow: var(--shadow-soft); margin-bottom: 2rem;
}

.tool-field { margin-bottom: 1rem; }
.tool-field label { display: block; font-weight: 700; font-size: .9rem; margin-bottom: .4rem; }
.tool-field .tool-help { font-size: .8rem; color: var(--muted-foreground); margin-top: .3rem; }
.tool-input, .tool-select, .tool-textarea {
    width: 100%; padding: .7rem .9rem; border: 1.5px solid var(--border); border-radius: .6rem;
    font-size: 1rem; font-family: inherit; background: var(--surface-elevated); color: var(--foreground);
}
.tool-input:focus, .tool-select:focus, .tool-textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.tool-input[dir="ltr"], input[type="tel"].tool-input, input[type="number"].tool-input { text-align: start; }
.tool-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.tool-row > * { flex: 1; min-width: 9rem; }
/* A row's "remove ×" button must never stretch to the 9rem floor above — it's what was
   forcing rows like "label / url / ×" past the viewport width on mobile instead of fitting
   on one line, since 3 children x 9rem routinely exceeds a phone's screen width. */
.tool-row > .tool-btn { flex: 0 0 auto; min-width: auto; }
@media (max-width: 560px) {
    /* On narrow screens, let row items shrink below the 9rem floor instead of forcing
       horizontal scroll — flex-wrap alone doesn't help once a single row has 3+ items,
       since each still claims its 9rem minimum before any wrapping is considered. */
    .tool-row > * { min-width: 0; }
}

.tool-error { color: #c0392b; font-size: .85rem; margin-top: .35rem; }

.tool-result {
    background: var(--brand-soft); border-radius: .75rem; padding: 1.25rem; margin-top: 1.25rem;
}
.tool-result-main { font-size: 1.4rem; font-weight: 800; color: var(--brand-dark); word-break: break-word; }
.tool-result-line { display: flex; justify-content: space-between; padding: .4rem 0; border-top: 1px solid rgba(0,0,0,.06); font-size: .92rem; }
.tool-result-line:first-child { border-top: none; }

.tool-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.tool-btn {
    display: inline-flex; align-items: center; gap: .4rem; border-radius: 999px; font-weight: 700;
    font-size: .88rem; padding: .6rem 1.2rem; border: 1.5px solid var(--border); background: var(--surface);
    color: var(--foreground); cursor: pointer; font-family: inherit;
}
.tool-btn:hover { border-color: var(--foreground); }
.tool-btn-primary { background: var(--brand); color: var(--brand-foreground); border-color: var(--brand); }
.tool-btn-primary:hover { background: var(--brand-dark); }

.tool-howto { margin: 2rem 0; }
.tool-howto h2 { font-size: 1.2rem; font-weight: 800; margin-bottom: .75rem; }
.tool-howto ol { padding-inline-start: 1.4rem; line-height: 1.8; }
.tool-howto li { margin-bottom: .4rem; }

.tool-guide { margin: 2.5rem 0; line-height: 1.9; font-size: 1rem; }
.tool-guide h2 { font-size: 1.3rem; font-weight: 800; margin-bottom: .9rem; }
.tool-guide p { margin: 0 0 1rem; }

.tool-faq { margin: 2.5rem 0; }
.tool-faq h2 { font-size: 1.3rem; font-weight: 800; margin-bottom: .9rem; }
.tool-faq details {
    border: 1px solid var(--border); border-radius: .6rem; padding: .9rem 1.1rem; margin-bottom: .6rem;
    background: var(--surface);
}
.tool-faq summary { font-weight: 700; cursor: pointer; }
.tool-faq p { margin: .6rem 0 0; color: var(--foreground); opacity: .9; line-height: 1.7; }

.tool-signup-hook {
    background: var(--primary); color: var(--primary-foreground); border-radius: var(--radius);
    padding: 1.25rem 1.5rem; margin: 2rem 0; display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap;
}
.tool-signup-hook p { margin: 0; font-weight: 600; }
/* .btn-outline (public-base.css) assumes a light page background — its text/border color is
   var(--foreground), near-black. On this box's dark var(--primary) background that was
   unreadable (dark text on transparent-over-dark). .btn-brand is the right choice for a CTA
   here and is used everywhere else; this is a defensive fallback in case a future tool page
   still reaches for .btn-outline inside this specific box. */
.tool-signup-hook .btn-outline { color: var(--primary-foreground); border-color: rgba(255, 255, 255, .4); }
.tool-signup-hook .btn-outline:hover { border-color: var(--primary-foreground); }

.tool-related { margin: 2rem 0; }
.tool-related h2 { font-size: 1.1rem; font-weight: 800; margin-bottom: .75rem; }
.tool-related-list { display: flex; flex-wrap: wrap; gap: .6rem; }
.tool-related-list a {
    font-size: .88rem; padding: .5rem 1rem; border-radius: 999px; border: 1px solid var(--border);
    color: var(--foreground); text-decoration: none;
}
.tool-related-list a:hover { border-color: var(--brand); color: var(--brand-dark); }

.tool-toast {
    position: fixed; inset-block-end: 1.5rem; inset-inline-start: 50%; transform: translateX(-50%) translateY(.5rem);
    background: var(--primary); color: var(--primary-foreground); padding: .7rem 1.4rem; border-radius: 999px;
    font-size: .88rem; font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
    z-index: 100; box-shadow: var(--shadow-elevated);
}
html[dir="rtl"] .tool-toast { transform: translateX(50%) translateY(.5rem); }
.tool-toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
html[dir="rtl"] .tool-toast.is-visible { transform: translateX(50%) translateY(0); }

.tool-qr-preview { display: flex; justify-content: center; padding: 1rem 0; }
.tool-qr-preview svg { max-width: 220px; height: auto; }

/* Printable QR card — shared by every QR variant tool (whatsapp/instagram/maps/menu/wifi),
   shown on screen as a live preview and, via .tool-print-sheet, as the entire printed page
   (see the print rule above). */
.qr-print-card { width: 10cm; margin: 1.5rem auto 0; border: 1px dashed var(--border); border-radius: .5rem; padding: 1.5rem; text-align: center; }
.qr-print-card svg { max-width: 160px; margin: 1rem auto; display: block; }
.qr-print-card .qr-print-caption { font-weight: 800; font-size: 1.1rem; }
@media print { .qr-print-card { border: none; } }

.tool-print-sheet { display: none; }
@media print {
    /* `visibility: hidden` + `position: absolute` used to leave every hidden element's normal
       height in the page flow (nav, title, guide, FAQ, footer...), which is what produced the
       "lots of empty pages" bug — the document was still as tall as the full page, just with
       invisible content on most of it. `display: none` actually removes elements from flow.
       This single rule hides anything that is neither the print sheet, nor inside it, nor an
       ancestor of it (so a wrapper div between .tool-widget and .tool-print-sheet, at any
       nesting depth, correctly stays without needing a page-specific override) — matched via
       :has(), which every current desktop browser used for printing supports. */
    body :not(.tool-print-sheet):not(.tool-print-sheet *):not(:has(.tool-print-sheet)) {
        display: none !important;
    }
    .tool-print-sheet { display: block !important; }
}

/* Hub page */
.tool-hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; margin-top: 2rem; }
.tool-hub-card {
    display: block; position: relative; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.25rem; text-decoration: none; color: var(--foreground);
    box-shadow: var(--shadow-soft);
}
.tool-hub-card:hover { border-color: var(--brand); }
.tool-hub-card h3 { font-size: 1.05rem; font-weight: 800; margin: 0 0 .4rem; }
.tool-hub-card p { font-size: .88rem; color: var(--muted-foreground); margin: 0; line-height: 1.6; }
.tool-hub-badge {
    position: absolute; inset-block-start: -.6rem; inset-inline-end: 1rem; background: var(--brand);
    color: var(--brand-foreground); font-size: .72rem; font-weight: 700; padding: .25rem .6rem; border-radius: 999px;
}

/* "Recently used" row — hidden by default, shown by JS only if localStorage has entries
   (see hub.html.twig's inline module script) so a first-time visitor never sees an empty shell. */
.tool-recent-section { display: none; margin-bottom: 2rem; }
.tool-recent-section h2 { font-size: 1.05rem; font-weight: 800; margin-bottom: .75rem; }
.tool-recent-list { display: flex; flex-wrap: wrap; gap: .6rem; }
.tool-recent-list a {
    display: inline-flex; align-items: center; gap: .4rem; background: var(--brand-soft); color: var(--brand-dark);
    font-size: .88rem; font-weight: 700; padding: .55rem 1.1rem; border-radius: 999px; text-decoration: none;
}
.tool-recent-list a:hover { background: var(--brand); color: var(--brand-foreground); }

@media (max-width: 560px) {
    .tool-container { padding: 1rem 1rem 3rem; }
    .tool-title { font-size: 1.5rem; }
    .tool-widget { padding: 1.1rem; }
}
