/* ===================================================================
   Forms Generator — wspólny stylesheet dla wszystkich typów formularzy.
   Bazuje na wyglądzie /opinie/ (Lato, jasne tło, niebieski akcent).
   =================================================================== */

/* Zmienne motywu — nadpisywane przez index.php w zależności od config.theme */
:root {
    --fg-bg:          #f6f9fc;
    --fg-card:        #ffffff;
    --fg-text:        #0c0055;
    --fg-muted:       #4a5568;
    --fg-accent:      #2d7af1;
    --fg-accent-d:    #1861d1;
    --fg-border:      #e0e0e0;
    --fg-input-bg:    #fefefe;
    --fg-input-bord:  #dcdcdc;
    --fg-on-accent:   #ffffff;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    background: var(--fg-bg);
    font-family: 'Lato', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    color: var(--fg-text);
    min-height: 100vh;
    padding: 20px 15px;
    /* Centrowanie zawartości w pionie i poziomie. Krótkie formularze
       wylądują na środku ekranu; długie wyrosną i można je przewinąć. */
    display: flex;
    align-items: center;
    justify-content: center;
}

#main {
    width: 100%;
    max-width: 580px;
    text-align: center;
    position: relative;
    animation: fgShow 0.25s ease-out;
}

.fg-section {
    width: 100%;
}

@keyframes fgShow {
    from { transform: scale(0.95); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

form {
    background: var(--fg-card);
    border: 2px solid var(--fg-border);
    border-radius: 12px;
    padding: 22px;
    color: var(--fg-text);
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

h1 {
    margin: 0;
    font-size: 22px;
    line-height: 1.25;
    font-weight: 700;
    color: var(--fg-text);
}

.fg-subtitle {
    margin: 0;
    color: var(--fg-muted);
    font-size: 14px;
    line-height: 1.5;
}

.fg-hero {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    border-radius: 8px;
}

/* ----------- Inputs ----------- */

.input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--fg-input-bord);
    border-radius: 8px;
    background: var(--fg-input-bg);
    color: var(--fg-text);
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}

.input::placeholder { color: var(--fg-muted); font-weight: 500; opacity: 0.7; }

.input:focus {
    border-color: var(--fg-accent);
    background: var(--fg-card);
}

/* ----------- Submit button ----------- */

.fg-submit {
    width: 100%;
    margin-top: 4px;
    padding: 14px 20px;
    border: 0;
    border-radius: 8px;
    background: var(--fg-accent);
    color: var(--fg-on-accent);
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
    transition: background 0.2s, transform 0.1s;
}

.fg-submit:hover { background: var(--fg-accent-d); }
.fg-submit:active { transform: scale(0.99); }
.fg-submit:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* ----------- Consent / terms ----------- */

.text2 {
    text-align: left;
    font-size: 11px;
    line-height: 1.5;
    color: var(--fg-muted);
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.text2 input[type="checkbox"] { margin-top: 2px; cursor: pointer; }
.text2 label { cursor: pointer; }

/* ----------- Spinner (Facebook style) ----------- */

.lds-facebook {
    display: none;
    margin: 0 auto;
    width: 60px;
    height: 16px;
    position: relative;
}

.lds-facebook.show { display: block; }

.lds-facebook div {
    display: inline-block;
    position: absolute;
    left: 6px;
    width: 10px;
    background: var(--fg-accent);
    animation: ldsFacebook 1.2s cubic-bezier(0, 0.5, 0.5, 1) infinite;
    border-radius: 2px;
}
.lds-facebook div:nth-child(1) { left: 6px;  animation-delay: -0.24s; }
.lds-facebook div:nth-child(2) { left: 26px; animation-delay: -0.12s; }
.lds-facebook div:nth-child(3) { left: 46px; animation-delay: 0; }

@keyframes ldsFacebook {
    0%   { top: 0;  height: 16px; }
    50%, 100% { top: 4px; height: 8px; }
}

/* ----------- Success state ----------- */

.fg-success {
    background: var(--fg-card);
    border: 2px solid var(--fg-border);
    border-radius: 12px;
    padding: 32px 22px;
    text-align: center;
}

.fg-success-icon {
    color: var(--fg-accent);
    font-size: 48px;
    margin-bottom: 10px;
}

.fg-success h1 { margin-bottom: 10px; }

.fg-success p {
    margin: 0;
    color: var(--fg-muted);
    font-size: 15px;
    line-height: 1.5;
}

/* =================================================================
   Typ: quantity_tiles
   ================================================================= */

.fg-tile-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.fg-tile {
    background: color-mix(in srgb, var(--fg-accent) 5%, var(--fg-card));
    border: 2px solid var(--fg-border);
    border-radius: 10px;
    padding: 18px 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    user-select: none;
    position: relative;
    transition: all 0.2s;
}

.fg-tile:hover {
    border-color: var(--fg-accent);
    background: color-mix(in srgb, var(--fg-accent) 12%, var(--fg-card));
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.fg-tile-number {
    font-size: 26px;
    font-weight: 700;
    color: var(--fg-text);
    line-height: 1;
}

.fg-tile-label {
    font-size: 11px;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.fg-tile.popular {
    border-color: var(--fg-accent);
    background: color-mix(in srgb, var(--fg-accent) 10%, var(--fg-card));
}

.fg-tile.popular::after {
    content: 'popularne';
    position: absolute;
    top: -9px;
    right: -1px;
    background: var(--fg-accent);
    color: var(--fg-on-accent);
    font-size: 9px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    text-transform: uppercase;
}

.fg-tile.sending { pointer-events: none; opacity: 0.6; }
.fg-tile.sending .fg-tile-number,
.fg-tile.sending .fg-tile-label { visibility: hidden; }
.fg-tile.sending::before {
    content: '';
    position: absolute;
    width: 22px; height: 22px;
    border: 3px solid var(--fg-border);
    border-top-color: var(--fg-accent);
    border-radius: 50%;
    animation: fgSpin 0.7s linear infinite;
    top: calc(50% - 11px); left: calc(50% - 11px);
}

@keyframes fgSpin { to { transform: rotate(360deg); } }

/* =================================================================
   Typ: quantity_slider
   ================================================================= */

.fg-qty {
    background: color-mix(in srgb, var(--fg-accent) 4%, var(--fg-card));
    border: 1px solid var(--fg-border);
    border-radius: 12px;
    padding: 16px;
    text-align: left;
}

.fg-qty-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.fg-qty-inline { display: flex; align-items: center; gap: 6px; }

.fg-qty-step {
    width: 30px; height: 30px;
    border-radius: 8px;
    border: 1px solid var(--fg-border);
    background: var(--fg-card);
    font-size: 18px;
    font-weight: 700;
    color: var(--fg-text);
    cursor: pointer;
    transition: all 0.2s;
}
.fg-qty-step:hover { background: var(--fg-accent); color: var(--fg-on-accent); border-color: var(--fg-accent); }

.fg-qty-inline input[type="number"] {
    width: 70px;
    padding: 8px 10px;
    border: 1px solid var(--fg-border);
    border-radius: 8px;
    background: var(--fg-card);
    color: var(--fg-text);
    font: inherit;
    font-weight: 600;
    text-align: center;
}

.fg-qty-unit { color: var(--fg-muted); font-size: 13px; }

.fg-qty input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    margin: 8px 0 12px;
}
.fg-qty input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--fg-accent) var(--val, 50%), var(--fg-border) var(--val, 50%));
}
.fg-qty input[type="range"]::-moz-range-track {
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--fg-accent) var(--val, 50%), var(--fg-border) var(--val, 50%));
}
.fg-qty input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--fg-card);
    border: 2px solid var(--fg-accent);
    margin-top: -8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    cursor: pointer;
}
.fg-qty input[type="range"]::-moz-range-thumb {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--fg-card);
    border: 2px solid var(--fg-accent);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    cursor: pointer;
}

.fg-qty-summary { display: flex; flex-wrap: wrap; gap: 6px; }

.fg-chip {
    background: var(--fg-card);
    border: 1px solid var(--fg-border);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--fg-text);
}
.fg-chip.bonus { background: color-mix(in srgb, var(--fg-accent) 8%, var(--fg-card)); border-color: color-mix(in srgb, var(--fg-accent) 25%, var(--fg-border)); }
.fg-chip.total { background: color-mix(in srgb, var(--fg-accent) 12%, var(--fg-card)); border-color: color-mix(in srgb, var(--fg-accent) 30%, var(--fg-border)); }

/* =================================================================
   Typ: captcha_check (fake reCAPTCHA)
   ================================================================= */

.fg-recaptcha {
    width: 304px;
    height: 78px;
    background: #f9f9f9;
    border: 1px solid #d3d3d3;
    border-radius: 3px;
    box-shadow: 0 0 4px 1px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 13px;
    margin: 0 auto;
    font-family: Roboto, Arial, sans-serif;
}

.fg-recaptcha-left { display: flex; align-items: center; gap: 13px; }

.fg-recaptcha-box {
    width: 28px; height: 28px;
    border: 2px solid #c1c1c1;
    border-radius: 2px;
    background: #fff;
    cursor: pointer;
    position: relative;
    display: flex; align-items: center; justify-content: center;
    transition: border-color 0.2s;
}
.fg-recaptcha-box:hover { border-color: #4285f4; }

.fg-recaptcha-box input {
    position: absolute; opacity: 0;
    width: 100%; height: 100%; margin: 0;
    cursor: pointer;
}

.fg-recaptcha-spinner,
.fg-recaptcha-tick { display: none; width: 28px; height: 28px; }
.fg-recaptcha-spinner.show,
.fg-recaptcha-tick.show { display: block; }

.fg-recaptcha-spinner svg { animation: fgSpin 1.5s linear infinite; width: 28px; height: 28px; }
.fg-recaptcha-tick svg { width: 28px; height: 28px; }

.fg-recaptcha-left label {
    font-size: 14px; color: #000; user-select: none;
    cursor: pointer; line-height: 1;
}

.fg-recaptcha-right {
    display: flex; flex-direction: column;
    align-items: center; gap: 1px;
}
.fg-recaptcha-logo { width: 32px; height: 32px; }
.fg-recaptcha-brand { font-size: 10px; font-weight: 700; color: #555; }
.fg-recaptcha-links { font-size: 8px; color: #999; }
.fg-recaptcha-links a { color: #999; text-decoration: none; }
.fg-recaptcha-links a:hover { text-decoration: underline; }

/* Captcha form ma własny "kontener" — zdejmujemy domyślne ramki */
form[data-mode="captcha"] {
    background: transparent;
    border: 0;
    padding: 0;
    box-shadow: none;
}

/* =================================================================
   Typ: option_grid
   ================================================================= */

.fg-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
}

.fg-option {
    background: color-mix(in srgb, var(--fg-accent) 8%, var(--fg-card));
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 16px 12px;
    cursor: pointer;
    text-align: center;
    user-select: none;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.fg-option img { width: 48px; height: auto; }

.fg-option .fg-option-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--fg-text);
    line-height: 1.3;
}

.fg-option .fg-option-text small {
    display: block;
    margin-top: 4px;
    font-weight: 400;
    color: var(--fg-muted);
}

.fg-option:hover {
    background: color-mix(in srgb, var(--fg-accent) 15%, var(--fg-card));
    transform: translateY(-2px);
}

.fg-option.active {
    border-color: var(--fg-accent);
    background: color-mix(in srgb, var(--fg-accent) 18%, var(--fg-card));
    position: relative;
}
.fg-option.active::before {
    content: '✔';
    position: absolute;
    top: -10px; left: calc(50% - 12px);
    background: var(--fg-accent);
    color: var(--fg-on-accent);
    border-radius: 12px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 900;
}

/* =================================================================
   Mobile
   ================================================================= */

@media (max-width: 480px) {
    body { padding: 10px 0; }
    form { padding: 18px 14px; gap: 12px; }
    h1 { font-size: 19px; }
    .fg-tile-grid { grid-template-columns: repeat(2, 1fr); }
    .fg-recaptcha { width: 100%; }
}
