/* WC Smartform Address — Phone field styling (intl-tel-input style).
 *
 * Selected state — ONE unified input with flag + dial on the left and
 * the phone number on the right:
 *
 *   ┌──────────────────────────────────────────┐
 *   │ 🇨🇿 +420 ▾ │ 601 123 456                   │
 *   └──────────────────────────────────────────┘
 *
 * The whole wrapper has the visible border; the inner button and the
 * #billing_phone input are borderless and transparent, so they look like
 * sections of a single control.
 *
 * Dropdown (opens on click/keyboard):
 *
 *   ┌─────────────────────────────────────────────┐
 *   │ 🇨🇿 Czech Republic (Česká republika) +420    │
 *   │ 🇭🇺 Hungary (Magyarország) +36               │
 *   │ 🇸🇰 Slovakia (Slovensko) +421                │
 *   └─────────────────────────────────────────────┘
 */

/* Outer wrapper carries the border — looks like one input */
.wc-smartform-phone-wrapper {
    display: flex;
    align-items: stretch;
    width: 100%;
    position: relative;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #fff;
    box-sizing: border-box;
    overflow: visible; /* dropdown must escape */
}

.wc-smartform-phone-wrapper:focus-within {
    border-color: #007acc;
    box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.15);
}

/* Compact country button (flag + dial + small arrow). Light grey background
 * to visually distinguish it from the phone input on the right. */
.wc-smartform-phone-wrapper .wcsf-phone-select {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 8px 0 12px;
    margin: 0;
    height: auto;
    min-height: 2.4em;
    font: inherit;
    line-height: 1;
    color: inherit;
    background: #f5f5f5;               /* light grey — visual separation */
    border: none;
    border-right: 1px solid #e2e2e2;   /* subtle separator between country and phone */
    border-radius: 2px 0 0 2px;        /* round the outer-left corners to match wrapper */
    cursor: pointer;
    box-sizing: border-box;
    white-space: nowrap;
}

.wc-smartform-phone-wrapper .wcsf-phone-select:hover {
    background: #ececec;
}

.wc-smartform-phone-wrapper .wcsf-phone-select:focus {
    outline: 2px solid rgba(0, 122, 204, 0.35);
    outline-offset: -2px;
    z-index: 2;
}

.wc-smartform-phone-wrapper .wcsf-phone-select .wcsf-phone-dial {
    font-weight: 500;
}

.wc-smartform-phone-wrapper .wcsf-phone-select .wcsf-phone-arrow {
    font-size: 0.7em;
    opacity: 0.55;
    margin-left: 2px;
    transition: transform 0.15s ease;
}
.wc-smartform-phone-wrapper .wcsf-phone-select.is-open .wcsf-phone-arrow {
    transform: rotate(180deg);
}

/* Phone input — fills remaining width, borderless, transparent. Override
 * common theme styles (borders, background, box-shadow, padding-left) so it
 * blends with the wrapper. Use !important because many WC themes target
 * #billing_phone with high specificity. */
.wc-smartform-phone-wrapper > #billing_phone,
.wc-smartform-phone-wrapper > input[type="tel"] {
    flex: 1 1 0 !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
    padding: 0 12px !important;
    margin: 0 !important;
    height: auto !important;
    min-height: 2.4em !important;
    font: inherit;
    box-sizing: border-box;
}

/* Dropdown */
.wc-smartform-phone-wrapper .wcsf-phone-dropdown {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    margin: 0;
    padding: 4px 0;
    list-style: none;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 3px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    min-width: 320px;
    max-width: 100%;
    max-height: 320px;
    overflow-y: auto;
    z-index: 1000;
}
.wc-smartform-phone-wrapper .wcsf-phone-dropdown[hidden] {
    display: none;
}

.wc-smartform-phone-wrapper .wcsf-phone-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    cursor: pointer;
    outline: none;
}

.wc-smartform-phone-wrapper .wcsf-phone-option:hover,
.wc-smartform-phone-wrapper .wcsf-phone-option:focus,
.wc-smartform-phone-wrapper .wcsf-phone-option.is-selected {
    background: #f0f5fb;
}

.wc-smartform-phone-wrapper .wcsf-phone-option-label {
    display: inline;
    font-size: inherit;
    line-height: 1.3;
}

.wc-smartform-phone-wrapper .wcsf-phone-name-local {
    font-weight: 500;
    color: inherit;
}

.wc-smartform-phone-wrapper .wcsf-phone-option-dial {
    color: #999;
    margin-left: 2px;
}

/* Flag sprite — compact 5-country mini-sprite (CZ/SK/HU/RO/PL), 1 KB.
 * Extracted from intl-tel-input v17 but trimmed to only our supported
 * countries to save ~242 KB on every checkout load. To add a country:
 * 1) add it to `wc_smartform_phone_countries`, 2) re-run the sprite
 * extraction script, 3) append a .sf-flag.sf-XX rule below.
 *
 * Layout: each slot is 20 × 14 px, flags laid horizontally in this order:
 *   [CZ @0] [SK @20] [HU @40] [RO @60] [PL @80]
 */
.sf-flag {
    display: inline-block;
    width: 20px;
    height: 15px;
    flex-shrink: 0;
    background-repeat: no-repeat;
    background-image: url('../img/flags.png');
}

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .sf-flag {
        background-image: url('../img/flags@2x.png');
        background-size: 100px 14px;
    }
}

.sf-flag.sf-cz { height: 14px; background-position:   0 0; }
.sf-flag.sf-sk { height: 14px; background-position: -20px 0; }
.sf-flag.sf-hu { height: 10px; background-position: -40px 0; }
.sf-flag.sf-ro { height: 14px; background-position: -60px 0; }
.sf-flag.sf-pl { height: 13px; background-position: -80px 0; }

/* Validation states — sjednoceno s .valid-address / .invalid-address /
 * .missing-house-number z smartform-address.css (aby telefonní pole
 * vypadalo stejně jako ulice). */

/* Valid (green) — stejně jako email pole nebo ulice s č.p. */
.wc-smartform-phone-wrapper.valid-address {
    border-color: #5cb85c;
}

/* Invalid — red border + jemný light red tint. Tint jde na celý wrapper
 * (pravá = input část), ne na input zvlášť — tak se přesně matchuje
 * odstín s .missing-house-number u ulice (rgba na rgba stackuje se
 * stejným výsledkem). Country selector vlevo má vlastní #f5f5f5 bg,
 * ten ho přepíše, takže levá část zůstane šedá jako normálně. */
.wc-smartform-phone-wrapper.invalid-address,
.wc-smartform-phone-wrapper.missing-house-number {
    border-color: #b81c23;
    background-color: rgba(184, 28, 35, 0.05);
}

/* Padding-right na inputu aby X ikona měla místo (stejně jako
 * ulice má `padding-right: 40px`). */
.wc-smartform-phone-wrapper.invalid-address > #billing_phone,
.wc-smartform-phone-wrapper.invalid-address > input[type="tel"],
.wc-smartform-phone-wrapper.missing-house-number > #billing_phone,
.wc-smartform-phone-wrapper.missing-house-number > input[type="tel"] {
    padding-right: 40px !important;
}

/* X ikona na pravé straně wrapperu, vertikálně na střed. Stejná
 * pozice jako `.smartform-address-status.invalid` u ulice. */
.wc-smartform-phone-wrapper .wcsf-phone-fail-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none; /* klik projde na input */
    z-index: 2;
}
.wc-smartform-phone-wrapper .wcsf-phone-fail-icon svg {
    display: block;
}

/* Legacy / fallback (pro starší cached JS bez error-msg třídy). */
.wc-smartform-phone-error {
    display: block;
    margin-top: 4px;
    font-size: 0.9em;
    color: #b94a48;
}

/* Narrow screens */
@media (max-width: 420px) {
    .wc-smartform-phone-wrapper .wcsf-phone-dropdown {
        min-width: 280px;
    }
}
