/* ==========================================================================
   Formularz zawarcia — wygląd wg makiety pliki_md/A47/Makieta_v7_formularz_zawarcia.html
   (A-47 §10 Z1): karty, pola, przyciski, pakiet i okres, podsumowanie, dane z GUS, loader.
   Kolory, zaokrąglenia i cienie wyłącznie przez zmienne z media/css/brand-variables.css.
   Zawężone do .b31-registration (kontener formularza w template/form.php), żeby nie wpływać
   na formularz przedłużenia, który dołącza media/css/form_registration.css.
   ========================================================================== */

/* Fonty (BRAND.md §5): tekst Inter, nagłówki Poppins 600 — ładowane w template/header.php */
.b31-registration { font-family: var(--b31-font); color: var(--b31-text); }
.b31-registration h1,
.b31-registration h2,
.b31-registration .b31-pkg-name,
.b31-registration .b31-sum-net { font-family: var(--b31-font-heading); }

/* Karty sekcji */
.b31-registration .b31-card {
    background: var(--b31-card);
    border: 1px solid var(--b31-border);
    border-radius: var(--b31-radius);
    box-shadow: var(--b31-shadow-card);
    padding: 22px 24px;
    margin-bottom: 16px;
    color: var(--b31-text);
}
.b31-registration .b31-card h2 {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    font-size: 19px;
    line-height: 1.3;
    margin: 0 0 4px;
    font-weight: 600;
    color: var(--b31-heading);
}
/* Karta startowa tej samej szerokości co formularz (form_new_view.css: form max-width 1150px) */
.b31-registration .b31-hero { max-width: 1150px; margin-left: auto; margin-right: auto; }
.b31-registration .b31-sub { color: var(--b31-muted); font-size: 14px; margin: 0 0 16px; }
.b31-registration .h5 { font-weight: 600; }
.b31-registration .b31-req,
.b31-registration .b31-city-req,
.b31-registration .b31-pkg-req { color: var(--b31-error); font-weight: 600; }
.b31-registration a { color: var(--b31-cta); }

/* Pola */
.b31-registration input.form-control:not([type=file]):not([type=checkbox]):not([type=radio]),
.b31-registration select.form-control,
.b31-registration select.custom-select,
.b31-registration textarea.form-control,
.b31-registration #virutalOfficeCity {
    width: 100%;
    height: auto;
    line-height: 1.4;
    font-size: 15px;
    color: var(--b31-text);
    padding: 10px 12px !important;
    border: 1px solid var(--b31-border);
    border-radius: var(--b31-radius);
    background-color: var(--b31-card);
    transition: border-color .15s;
}
.b31-registration input.form-control:not([type=file]):not([type=checkbox]):not([type=radio]):focus,
.b31-registration select.form-control:focus,
.b31-registration select.custom-select:focus,
.b31-registration textarea.form-control:focus,
.b31-registration #virutalOfficeCity:focus {
    outline: 2px solid var(--b31-accent);
    outline-offset: 0;
    border-color: var(--b31-cta);
    box-shadow: none;
}
.b31-registration input.form-control.border-danger,
.b31-registration select.border-danger { border-color: var(--b31-error) !important; }
.b31-registration #virutalOfficeCity {
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%230F2E52' stroke-width='2'><path d='M8 9l4-4 4 4M8 15l4 4 4-4'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
}
.b31-registration .b31-city-label { font-size: 14px; font-weight: 500; margin-bottom: 5px; display: block; }
.b31-registration #zip1,
.b31-registration #zip2 { padding-left: 6px !important; padding-right: 6px !important; }
.b31-registration #invoiceClientAddress { height: auto !important; line-height: 1.4 !important; }

/* Pliki (umowa spółki, pełnomocnictwo) */
.b31-registration input.form-control[type=file] {
    width: 100%;
    height: auto;
    border: 1px dashed var(--b31-border);
    border-radius: var(--b31-radius);
    padding: 10px 12px;
    background: var(--b31-card);
    font-size: 14px;
    color: var(--b31-muted);
    cursor: pointer;
}
.b31-registration input.form-control[type=file]::file-selector-button {
    margin-right: 12px;
    padding: 8px 14px;
    border: 0;
    border-radius: var(--b31-radius);
    background: var(--b31-cta);
    color: var(--b31-on-brand);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}
.b31-registration input.form-control[type=file]::file-selector-button:hover { background: var(--b31-cta-hover); }

/* Przyciski */
.b31-registration .btn-primary {
    background: var(--b31-cta);
    border-color: var(--b31-cta);
    border-radius: var(--b31-radius);
    color: var(--b31-on-brand);
    padding: 14px 28px;
    font-weight: 600;
    font-size: 16px;
}
.b31-registration .btn-primary:hover,
.b31-registration .btn-primary:focus { background: var(--b31-cta-hover); border-color: var(--b31-cta-hover); }
.b31-registration .btn-primary:disabled { background: var(--b31-border); border-color: var(--b31-border); color: var(--b31-muted); }
.b31-registration .btn-warning,
.b31-registration .btn-danger { border-radius: var(--b31-radius); }
/* Przycisk wysyłki wyrównany do lewej, szerokość wg treści (makieta); id - bo form_new_view.css daje mu 100% */
.b31-registration #sendFormVaild { display: inline-block; width: auto; margin-top: 16px; }

/* Początek umowy: kalendarz jQuery UI (format dd.mm.rrrr oczekiwany przez backend), ikona w polu */
.b31-registration #agreementBeginDate {
    cursor: pointer;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2355708D' stroke-width='2'><rect x='3' y='5' width='18' height='16' rx='2'/><path d='M16 3v4M8 3v4M3 10h18'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
}
.b31-registration #agreementBeginDate::placeholder { color: var(--b31-muted); }

/* Wiersze dodawane przyciskiem („Dodaj kolejną osobę”, osoby do kontaktu) - template/ajax_form_*.php,
   stary układ Bootstrapa. Tylko CSS: removeProxy()/removeContactPerson() szukają wiersza przez
   parent().parent().parent(), więc kolejność elementów w HTML musi zostać. */
.b31-registration .additional-proxy,
.b31-registration .contact-person {
    margin: 0 0 14px !important;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--b31-border) !important;
}
.b31-registration .additional-proxy .row,
.b31-registration .contact-person .row { margin-left: 0; margin-right: 0; align-items: center; }
.b31-registration .additional-proxy .row > div,
.b31-registration .contact-person .row > div { padding-left: 0; padding-right: 0; }
.b31-registration .additional-proxy label,
.b31-registration .contact-person label {
    padding: 10px 0 5px !important;
    font-weight: 500;
    font-size: 14px;
}
.b31-registration .additional-proxy .btn-danger,
.b31-registration .contact-person .btn-danger {
    flex: 0 0 auto;
    margin: 8px 0 0;
    padding: 6px 10px;
    border: 1px solid var(--b31-error);
    border-radius: var(--b31-radius);
    background: var(--b31-card);
    color: var(--b31-error);
    line-height: 1;
}
.b31-registration .additional-proxy .btn-danger:hover,
.b31-registration .contact-person .btn-danger:hover { background: var(--b31-error); color: var(--b31-on-brand); }
@media (max-width: 767px) {
    /* Phone: the delete button on its own line under the fields */
    .b31-registration .additional-proxy .row > .btn-danger { flex-basis: auto; margin-right: auto; }
}
@media (min-width: 768px) {
    /* Desktop: the delete button sits next to the last field - keep it off the input */
    .b31-registration .additional-proxy .btn-danger,
    .b31-registration .contact-person .btn-danger { margin: 0 0 0 10px; }
}

/* Notka „Brak firmy” */
.b31-registration .b31-note-box {
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--b31-border);
    border-radius: var(--b31-radius);
    background: var(--b31-bg);
    color: var(--b31-muted);
    font-size: 13px;
    line-height: 1.45;
}

/* 2. Pakiet */
.b31-registration .b31-pkg-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 6px; }
.b31-registration .b31-pkg-card {
    display: block;
    position: relative;
    margin: 0;
    padding: 16px 18px;
    border: 1px solid var(--b31-border);
    border-radius: var(--b31-radius);
    background: var(--b31-card);
    cursor: pointer;
}
.b31-registration .b31-pkg-card:hover { border-color: var(--b31-accent); }
.b31-registration .b31-pkg-card input[type=radio] { position: absolute; opacity: 0; width: 0; height: 0; }
.b31-registration .b31-pkg-card.selected { border-color: var(--b31-cta); box-shadow: 0 0 0 1px var(--b31-cta); background: var(--b31-tint); }
.b31-registration .b31-pkg-card.off { opacity: .45; pointer-events: none; }
.b31-registration .b31-pkg-tag { display: block; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--b31-brand); }
.b31-registration .b31-pkg-name { font-size: 19px; font-weight: 600; color: var(--b31-heading); margin-top: 2px; }
.b31-registration .b31-pkg-dsc { font-size: 13.5px; color: var(--b31-muted); margin: 0 0 6px; }
.b31-registration .b31-pkg-feats { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--b31-text); }
.b31-registration .b31-pkg-feats li { margin-bottom: 4px; }
.b31-registration .b31-pkg-more { font-size: 13.5px; margin: 12px 0 0; color: var(--b31-text); }

/* 3. Okres */
.b31-registration .b31-periods { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 6px; }
.b31-registration .b31-per {
    position: relative;
    padding: 16px 10px 12px;
    border: 1px solid var(--b31-border);
    border-radius: var(--b31-radius);
    background: var(--b31-card);
    text-align: center;
    cursor: pointer;
}
.b31-registration .b31-per:hover { border-color: var(--b31-accent); }
.b31-registration .b31-per.on { border-color: var(--b31-cta); box-shadow: 0 0 0 1px var(--b31-cta); background: var(--b31-tint); }
.b31-registration .b31-per .b31-per-len { font-weight: 600; font-size: 15px; }
.b31-registration .b31-per .b31-per-mc { font-size: 19px; font-weight: 600; color: var(--b31-brand); margin-top: 6px; white-space: nowrap; }
.b31-registration .b31-per .b31-per-mcl { font-size: 12px; color: var(--b31-muted); }
.b31-registration .b31-per .b31-per-tot {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--b31-border);
    font-size: 12.5px;
    color: var(--b31-muted);
    white-space: nowrap;
}
.b31-registration .b31-per .b31-per-gross { font-size: 12px; color: var(--b31-muted); white-space: nowrap; margin-top: 2px; }
.b31-registration .b31-per .b31-per-best {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    padding: 2px 8px;
    border-radius: var(--b31-radius);
    background: var(--b31-brand);
    color: var(--b31-on-brand);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    white-space: nowrap;
}

/* Komunikaty pakietu/okresu: ostrzeżenie i wyróżniona notka (pionowy akcent, BRAND.md §3) */
.b31-registration .b31-warn {
    margin: 14px 0;
    padding: 12px 14px;
    border: 1px solid var(--b31-warn-border);
    border-radius: var(--b31-radius);
    background: var(--b31-warn-bg);
    font-size: 14px;
    color: var(--b31-text);
}
.b31-registration .b31-note {
    margin: 14px 0;
    padding: 12px 14px;
    border-left: var(--b31-accent-bar) solid var(--b31-brand);
    border-radius: var(--b31-radius);
    background: var(--b31-tint);
    font-size: 14px;
    color: var(--b31-text);
}

@media (max-width: 760px) {
    .b31-registration .b31-pkg-cards { grid-template-columns: 1fr; }
    /* Two periods per row, as in the mock-up. !important: JS sets grid-template-columns inline
       (number of available periods). */
    .b31-registration .b31-periods { grid-template-columns: 1fr 1fr !important; }
}

/* 9. Podsumowanie (akcent 4 px --b31-brand, kwota netto duża) */
.b31-registration #b31Summary {
    margin-top: 12px;
    padding: 18px 20px;
    border: 1px solid var(--b31-border);
    border-left: var(--b31-accent-bar) solid var(--b31-brand);
    border-radius: var(--b31-radius);
    background: var(--b31-card);
}
.b31-registration .b31-sum-title { font-size: 13px; color: var(--b31-muted); }
.b31-registration .b31-sum-label { font-weight: 600; }
.b31-registration .b31-srow { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; font-size: 14.5px; }
.b31-registration .b31-sum-city { font-size: 13px; color: var(--b31-muted); margin-top: 2px; }
.b31-registration .b31-sum-city:empty { display: none; }
.b31-registration .b31-sum-net { font-size: 28px; line-height: 1.1; font-weight: 600; color: var(--b31-brand); white-space: nowrap; }
.b31-registration .b31-sum-net-label { font-size: 14px; color: var(--b31-muted); font-weight: 400; }
.b31-registration .b31-sum-price { text-align: right; }
.b31-registration .b31-sum-gross { font-size: 14px; color: var(--b31-muted); margin-top: 2px; }
.b31-registration .b31-smc { font-size: 12.5px; color: var(--b31-muted); margin-top: 6px; }
.b31-registration .b31-disc-note {
    display: none;
    margin-top: 12px;
    padding: 12px 14px;
    border: 1px solid var(--b31-ok-border);
    border-radius: var(--b31-radius);
    background: var(--b31-ok-bg);
    color: var(--b31-ok);
    font-size: 14px;
    font-weight: 600;
}
.b31-registration .b31-disc-note.show { display: block; }

/* Dane z GUS (prawa kolumna) */
.b31-registration #gusData {
    padding: 13px 15px;
    border: 1px solid var(--b31-ok-border);
    border-radius: var(--b31-radius);
    background: var(--b31-ok-bg);
    color: var(--b31-text);
}
.b31-registration #gusData .h6 { color: var(--b31-ok); }

/* Lewa kolumna z lokalizacjami (Z3). Nadpisuje kolory z form_new_view.css (wspólny z form_2.php),
   dlatego tylko przez .b31-side. Komputer: lista zawsze rozwinięta; telefon: zwinięta do jednej linii. */
.left.b31-side {
    border-right: var(--b31-accent-bar) solid var(--b31-brand);
    background: var(--b31-card);
    font-family: var(--b31-font);
    color: var(--b31-text);
}
.b31-side .bi-geo-alt-fill { color: var(--b31-accent); }
/* E-mail na dole kolumny: do lewej, z linią nad nim (makieta .sidecontact) */
.b31-side .email-contact {
    text-align: left;
    font-size: 14px;
    border-top: 1px solid var(--b31-border);
    padding-top: 12px;
}
.b31-side .email-contact a { color: var(--b31-cta); }
.b31-side .email-contact a:hover { color: var(--b31-cta-hover); }
.b31-locs { margin-top: 22px; }
.b31-locs summary {
    list-style: none;
    cursor: default;
    font-family: var(--b31-font-heading);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--b31-brand);
}
.b31-locs summary::-webkit-details-marker { display: none; }
/* Strzałki i pasek przewijania listy (niskie ekrany, form_new_view.css) w kolorach palety */
.b31-side .office-locations { scrollbar-color: var(--b31-accent) var(--b31-bg); }
.b31-side .office-locations::-webkit-scrollbar-track { background: var(--b31-bg); }
.b31-side .office-locations::-webkit-scrollbar-thumb { background-color: var(--b31-accent); }
.b31-side .office-locations::before,
.b31-side .office-locations::after { border-color: var(--b31-accent); }

@media only screen and (max-width: 991px) {
    /* Phone/tablet: the location list as a card with the brand bar on top (mock-up .side) */
    .left.b31-side {
        width: auto;
        margin: 12px;
        padding: 14px;
        border: 1px solid var(--b31-border);
        border-top: var(--b31-accent-bar) solid var(--b31-brand);
        border-radius: var(--b31-radius);
    }
    .b31-side .logo { width: 150px; margin: 0; }
    .b31-locs { margin-top: 10px; }
    .b31-locs summary {
        display: flex;
        justify-content: space-between;
        align-items: center;
        cursor: pointer;
        font-size: 14px;
    }
    .b31-locs summary::after { content: "▾"; color: var(--b31-muted); }
    .b31-locs[open] summary::after { content: "▴"; }
}

/* Telefon (makieta, próg 760 px): formularz to jedna karta, sekcje 1–9 bez własnych ramek,
   oddzielone poziomą linią; karta startowa („Formularz zawarcia umowy”) zostaje osobno. */
@media only screen and (max-width: 760px) {
    /* Room under the form for the Tidio launcher icon, so it never covers "Wyślij formularz" */
    .b31-registration { padding-bottom: 88px; }
    .b31-registration form {
        padding: 18px 16px;
        border: 1px solid var(--b31-border);
        border-radius: var(--b31-radius);
        background: var(--b31-card);
        box-shadow: var(--b31-shadow-card);
    }
    .b31-registration form .b31-card,
    .b31-registration form .b31-card.b31-services {
        margin: 24px 0 0;
        padding: 22px 0 0;
        border: 0;
        border-top: 1px solid var(--b31-border);
        border-radius: 0;
        box-shadow: none;
        background: transparent;
    }
    .b31-registration form .b31-card:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
    .b31-registration .b31-hero { padding: 18px 16px; }
    .b31-registration .b31-hero h1 { font-size: 22px; }
    /* Prices move under the package line and align left */
    .b31-registration .b31-sum-price { text-align: left; }
}

/* Kalendarz „Początek umowy” (jQuery UI, motyw ui-lightness) w kolorach palety */
#ui-datepicker-div.ui-widget {
    padding: 8px;
    border: 1px solid var(--b31-border);
    border-radius: var(--b31-radius);
    background: var(--b31-card);
    box-shadow: var(--b31-shadow-card);
    font-family: var(--b31-font);
    color: var(--b31-text);
}
#ui-datepicker-div .ui-widget-header {
    border: 0;
    border-radius: var(--b31-radius);
    background: var(--b31-brand);
    color: var(--b31-on-brand);
}
#ui-datepicker-div .ui-datepicker-prev,
#ui-datepicker-div .ui-datepicker-next { cursor: pointer; }
#ui-datepicker-div .ui-datepicker-prev-hover,
#ui-datepicker-div .ui-datepicker-next-hover { border: 0; background: var(--b31-cta-hover); }
#ui-datepicker-div th { color: var(--b31-muted); font-weight: 500; }
#ui-datepicker-div .ui-state-default {
    border: 1px solid var(--b31-border);
    border-radius: var(--b31-radius);
    background: var(--b31-card);
    color: var(--b31-text);
    text-align: center;
}
#ui-datepicker-div .ui-state-hover { border-color: var(--b31-accent); background: var(--b31-tint); color: var(--b31-text); }
#ui-datepicker-div .ui-state-highlight { border-color: var(--b31-accent); background: var(--b31-tint); color: var(--b31-text); }
#ui-datepicker-div .ui-state-active { border-color: var(--b31-cta); background: var(--b31-cta); color: var(--b31-on-brand); }
#ui-datepicker-div .ui-state-disabled .ui-state-default { opacity: .5; }

/* Bootstrap/main.css colours used on this form, mapped to the palette (main.css and main.js are
   shared with the admin panel, so they are overridden here - this file loads on the form only). */
.b31-registration .alert { border-radius: var(--b31-radius); color: var(--b31-text); }
.b31-registration .alert-info {
    border: 1px solid var(--b31-border);
    border-left: var(--b31-accent-bar) solid var(--b31-brand);
    background: var(--b31-tint);
}
.b31-registration .alert-warning { border: 1px solid var(--b31-warn-border); background: var(--b31-warn-bg); }
.b31-registration .b31-rc.text-danger { color: var(--b31-error) !important; }
.b31-registration .checkbox-danger { box-shadow: 0 0 0 1px var(--b31-error); }

/* Messages from windowMessage() (media/js/main.js) */
.alert-overlay .alert-content {
    border: 1px solid var(--b31-border);
    border-left: var(--b31-accent-bar) solid var(--b31-brand);
    border-radius: var(--b31-radius) !important;
    background: var(--b31-card);
    box-shadow: var(--b31-shadow-card);
    color: var(--b31-text);
    font-family: var(--b31-font);
}
.alert-overlay .alert-content.alert-danger { border-left-color: var(--b31-error); }
.alert-overlay .alert-content.alert-warning { border-left-color: var(--b31-warn); }
.alert-overlay .alert-content.alert-success { border-left-color: var(--b31-ok); }
.alert-overlay .alert-content .btn {
    border: 0;
    border-radius: var(--b31-radius);
    background: var(--b31-cta);
    color: var(--b31-on-brand);
}
.alert-overlay .alert-content .btn:hover { background: var(--b31-cta-hover); }

/* "Sprawdź poprawność danych" review step (#ajaxModal) */
#ajaxModal { font-family: var(--b31-font); color: var(--b31-text); }
#ajaxModal .h5 { font-family: var(--b31-font-heading); font-weight: 600; color: var(--b31-heading); }
#ajaxModal .b31-review-label { color: var(--b31-muted); }
#ajaxModal #confirmForm {
    border: 1px solid var(--b31-cta);
    border-radius: var(--b31-radius);
    background: var(--b31-cta);
    color: var(--b31-on-brand);
    font-weight: 600;
}
#ajaxModal #confirmForm:hover { background: var(--b31-cta-hover); border-color: var(--b31-cta-hover); }
#ajaxModal #backToForm {
    border: 1px solid var(--b31-cta);
    border-radius: var(--b31-radius);
    background: var(--b31-card);
    color: var(--b31-cta);
    font-weight: 500;
}
#ajaxModal #backToForm:hover { background: var(--b31-tint); }

/* Loader przy wysyłce zgłoszenia (po „Potwierdzam”) — poza .b31-registration, id jest unikalne */
#formSubmitOverlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(255, 255, 255, .85);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}
#formSubmitOverlay .b31-spinner {
    width: 64px;
    height: 64px;
    border: 6px solid var(--b31-tint);
    border-top-color: var(--b31-cta);
    border-radius: 50%;
    animation: b31-spin .8s linear infinite;
}
#formSubmitOverlay .b31-spinner-text { margin-top: 18px; font-size: 18px; font-weight: 600; color: var(--b31-text); }
@keyframes b31-spin { to { transform: rotate(360deg); } }
