/* ============================================================
   Feedback Widget – feedback-widget.css
   Działa niezależnie: pełne fallbacki dla zmiennych z style.css.
   Gdy główny arkusz się nie załaduje (ścieżka / kolejność), widget i tak ma poprawne style.
   ============================================================ */
:root {
    /* Wartości domyślne widgetu – nadpisywane przez style.css strony (ta sama kaskada).
       Poprzednie self-referencing var() były nieprawidłowym CSS (circular reference = invalid). */
    --primary: #1a6fdb;
    --primary-light: #3d8ef0;
    --primary-dark: #1255b0;
    --accent: #00b4d8;
    --bg: #f4f7fb;
    --bg-card: #ffffff;
    --text-primary: #1a2236;
    --text-secondary: #4a5a7a;
    --text-muted: #8090ad;
    --border: #dde3ef;
    --shadow-lg: 0 16px 48px rgba(26, 111, 219, 0.13);
    --radius-sm: 10px;
    --radius-lg: 24px;
    /* Lokalne aliasy dla widgetu */
    --fw-radius-sm: var(--radius-sm, 10px);
    --fw-radius-lg: var(--radius-lg, 24px);
    --fw-primary-dark: var(--primary-dark, #1255b0);
}

/* ── Floating trigger button (styl jak kafelki na stronie) ─── */
.fw-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9000;
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg, 24px);
    background: var(--primary);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    cursor: pointer;
    box-shadow: var(--shadow-md, 0 6px 24px rgba(26, 111, 219, 0.1));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: background 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.2s ease, opacity 0.2s ease;
}

.fw-trigger:hover {
    background: var(--primary-dark, #1255b0);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg, 0 16px 48px rgba(26, 111, 219, 0.13));
}

.fw-trigger:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

.fw-trigger--hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

/* ── Overlay ──────────────────────────────────────────────── */
.fw-overlay {
    position: fixed;
    inset: 0;
    z-index: 9001;
    background: rgba(26, 34, 54, 0.52);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none; /* gdy zamknięty – nie blokuje przycisku (z-index 9000) */
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.fw-overlay--open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

@media (min-width: 600px) {
    .fw-overlay {
        align-items: center;
    }
}

/* ── Modal card (jak .calculator-card / .result-card) ──────── */
.fw-modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg, 24px) var(--radius-lg, 24px) 0 0;
    border: 1px solid var(--border);
    width: 100%;
    max-width: 480px;
    padding: 28px 24px 32px;
    box-shadow: var(--shadow-lg, 0 16px 48px rgba(26, 111, 219, 0.13));
    transform: translateY(40px);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: 92vh;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.fw-overlay--open .fw-modal {
    transform: translateY(0);
}

@media (min-width: 600px) {
    .fw-modal {
        border-radius: var(--radius-lg, 24px);
        width: 480px;
        margin: 16px;
        padding: 36px 40px 40px;
    }
}

/* ── Header ───────────────────────────────────────────────── */
.fw-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    gap: 12px;
}

.fw-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.2;
}

.fw-close {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: var(--radius-sm, 10px);
    border: 1px solid var(--border);
    background: var(--bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    padding: 0;
}

.fw-close:hover {
    background: var(--bg-section, #f0f4fa);
    color: var(--text-primary);
    border-color: var(--primary-light);
}

.fw-close:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

/* ── Divider ──────────────────────────────────────────────── */
.fw-divider {
    height: 1px;
    background: var(--border);
    margin-bottom: 22px;
}

/* ── Form fields ──────────────────────────────────────────── */
.fw-field {
    margin-bottom: 18px;
}

.fw-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.fw-required {
    color: var(--primary);
}

.fw-optional {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.825rem;
}

/* ── Type pills ───────────────────────────────────────────── */
.fw-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.fw-pill {
    padding: 8px 20px;
    border-radius: 100px;
    border: 2px solid var(--border);
    background: var(--bg-section, #f0f4fa);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    line-height: 1.4;
}

.fw-pill:hover:not(.fw-pill--active) {
    border-color: var(--primary-light);
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm, 0 2px 8px rgba(26, 111, 219, 0.07));
}

.fw-pill--active {
    border-color: var(--primary);
    color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(26, 111, 219, 0.12), var(--shadow-sm, 0 2px 8px rgba(26, 111, 219, 0.07));
}

.fw-pill:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

/* ── Textarea ─────────────────────────────────────────────── */
.fw-textarea-wrap {
    position: relative;
}

.fw-textarea {
    width: 100%;
    min-height: 130px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 10px);
    font-family: inherit;
    font-size: 0.9375rem;
    color: var(--text-primary);
    background: var(--bg);
    resize: vertical;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
    line-height: 1.5;
    display: block;
}

.fw-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 111, 219, 0.1);
}

.fw-textarea::placeholder {
    color: var(--text-muted);
}

.fw-hint {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 5px;
    transition: color 0.15s;
}

/* ── Text input ───────────────────────────────────────────── */
.fw-input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 10px);
    font-family: inherit;
    font-size: 0.9375rem;
    color: var(--text-primary);
    background: var(--bg);
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}

.fw-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 111, 219, 0.1);
}

.fw-input::placeholder {
    color: var(--text-muted);
}

/* ── Checkbox ─────────────────────────────────────────────── */
.fw-field--checkbox {
    margin-top: 2px;
}

.fw-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.fw-checkbox {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.fw-checkbox-box {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm, 10px);
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
    transition: border-color 0.15s, background 0.15s;
    flex-shrink: 0;
}

.fw-checkbox:checked + .fw-checkbox-box {
    background: var(--primary);
    border-color: var(--primary);
}

.fw-checkbox:checked + .fw-checkbox-box::after {
    content: '';
    display: block;
    width: 5px;
    height: 9px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg) translate(-1px, -1px);
}

.fw-checkbox:focus-visible + .fw-checkbox-box {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.fw-link {
    color: var(--primary);
    text-decoration: none;
}

.fw-link:hover {
    text-decoration: underline;
}

/* ── Error message ────────────────────────────────────────── */
.fw-error {
    color: #e53935;
    font-size: 0.85rem;
    margin: -6px 0 10px;
    line-height: 1.4;
    min-height: 0;
}

.fw-error:empty {
    display: none;
}

/* ── Submit button (jak .calculate-btn na stronie) ─────────── */
.fw-btn {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 100px;
    background: linear-gradient(135deg, var(--primary), var(--accent, #00b4d8));
    color: #fff;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    letter-spacing: 0.02em;
    line-height: 1.4;
    box-shadow: 0 4px 16px rgba(26, 111, 219, 0.25);
}

.fw-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(26, 111, 219, 0.35);
}

.fw-btn:active:not(:disabled) {
    transform: translateY(0);
}

.fw-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ── Loading spinner ──────────────────────────────────────── */
.fw-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: fw-spin 0.7s linear infinite;
    display: none;
    flex-shrink: 0;
}

.fw-btn--loading .fw-spinner {
    display: block;
}

.fw-btn--loading .fw-btn-text {
    opacity: 0.8;
}

@keyframes fw-spin {
    to { transform: rotate(360deg); }
}

/* ── Success state ────────────────────────────────────────── */
.fw-success {
    text-align: center;
    padding: 20px 0 8px;
}

.fw-success svg {
    margin-bottom: 16px;
}

.fw-success h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 10px;
}

.fw-success p {
    color: var(--text-secondary);
    margin: 0 0 24px;
    font-size: 0.9375rem;
    line-height: 1.55;
}

/* ── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .fw-trigger,
    .fw-overlay,
    .fw-modal,
    .fw-btn {
        transition: none;
    }

    .fw-spinner {
        animation: none;
        border-top-color: rgba(255, 255, 255, 0.8);
    }
}

/* reCAPTCHA badge hidden – inline legal notice shown instead */
.grecaptcha-badge { visibility: hidden !important; }

.fw-recaptcha-note {
    font-size: 11px;
    color: var(--text-light, #888);
    text-align: center;
    margin: 8px 0 0;
    line-height: 1.5;
}
.fw-recaptcha-note a {
    color: inherit;
    text-decoration: underline;
}

/* Hide widget on mobile */
@media (max-width: 599px) {
    .fw-trigger { display: none; }
}
