/* ============================================
   Speedy Checkout Widget
   ============================================ */

/* Kept visually in step with the Econt widget — two couriers side by side
   in the same checkout looked unrelated when one had a heavy red frame. */
.woos-checkout-widget {
    margin-top: 15px;
    padding: 0;
    border: 1px solid #e2e6ec;
    border-radius: 12px;
    background: #fff;
    /* overflow must stay visible so autocomplete dropdowns aren't clipped */
    overflow: visible;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    box-sizing: border-box;
    max-width: 100% !important;
    width: 100% !important;
    min-width: 0 !important;
}

.woos-checkout-widget * {
    box-sizing: border-box;
}

/* Guard against theme styles (right-aligned labels/inputs, floats) */
.woos-checkout-widget,
.woos-checkout-widget label,
.woos-checkout-widget input[type="text"],
.woos-checkout-widget .woos-dropdown-item {
    text-align: left !important;
    float: none;
}

/* Header — light, so the widget reads as part of the checkout rather than
   as an embedded courier banner. */
.woos-widget-header {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 10px;
    padding: 10px 14px;
    background: #fff;
    border-bottom: 1px solid #e2e6ec;
    border-radius: 11px 11px 0 0;
    color: #1f2937;
    min-width: 0;
}

/* !important guards against theme img rules like `img { height: auto !important }`,
   which blow a dimensionless SVG up to 100% width */
.woos-checkout-widget .woos-logo {
    height: 18px !important;
    width: 79px !important;
    max-width: 40%;
    flex-shrink: 0;
}

.woos-widget-title {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: #6b7280;
    flex: 0 1 auto;
    min-width: 0;
    margin-left: 0;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Delivery Type Tabs — a segmented control that must never overflow.
   Three tabs have to fit a 320px phone, so each is allowed to shrink below
   its content width (flex-basis 0 + min-width 0) with the icon above the
   label. */
.woos-delivery-tabs {
    display: flex;
    gap: 6px;
    padding: 10px;
    background: #f6f8fb;
    border-bottom: 1px solid #e2e6ec;
    min-width: 0;
}

.woos-tab {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 10px 6px;
    border: 1.5px solid #e2e6ec;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.18s, color 0.18s, background 0.18s, box-shadow 0.18s;
    color: #6b7280;
    font-family: inherit;
    line-height: 1.2;
    -webkit-appearance: none;
    appearance: none;
}

.woos-tab:hover {
    border-color: #d40511;
    color: #d40511;
}

.woos-tab:focus-visible {
    outline: 2px solid #d40511;
    outline-offset: 2px;
}

.woos-tab.active {
    background: #fff;
    color: #d40511;
    border-color: #d40511;
    box-shadow: inset 0 0 0 1px #d40511;
    font-weight: 600;
}

.woos-tab-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    flex: 0 0 auto;
}

.woos-checkout-widget .woos-tab-icon svg {
    width: 20px !important;
    height: 20px !important;
    display: block;
}

/* text-transform is forced off: WoodMart uppercases all <button> text,
   which widens the labels by ~30% and clips them on narrow phones. */
.woos-checkout-widget .woos-tab,
.woos-checkout-widget .woos-tab-label {
    text-transform: none !important;
    letter-spacing: normal !important;
}

.woos-tab-label {
    font-size: 12px;
    text-align: center;
    min-width: 0;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Panels */
.woos-panel {
    padding: 14px;
}

/* Fields */
.woos-field {
    margin-bottom: 10px;
    position: relative;
}

.woos-field:last-child {
    margin-bottom: 0;
}

.woos-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #555;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.woos-field input[type="text"],
.woos-panel input[type="text"] {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fafafa;
    box-sizing: border-box;
}

.woos-field input[type="text"]:focus,
.woos-panel input[type="text"]:focus {
    border-color: #d40511;
    box-shadow: 0 0 0 3px rgba(212, 5, 17, 0.1);
    outline: none;
    background: #fff;
}

.woos-field input[type="text"]:disabled {
    background: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

/* Field Row (side by side) */
.woos-field-row {
    display: flex;
    gap: 12px;
}

.woos-field-half {
    flex: 1;
}

/* Dropdown (autocomplete) */
.woos-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 9999;
    background: #fff;
    border: 1.5px solid #ddd;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 250px;
    overflow-y: auto;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.woos-dropdown.open {
    display: block;
}

.woos-dropdown-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
    transition: background 0.15s;
    font-size: 13px;
}

.woos-dropdown-item:last-child {
    border-bottom: none;
}

.woos-dropdown-item:hover {
    background: #fdf0f0;
}

.woos-dropdown-item.selected {
    background: #fbe5e6;
    color: #d40511;
    font-weight: 600;
}

.woos-dropdown-item .woos-item-main {
    font-weight: 500;
    color: #333;
}

.woos-dropdown-item .woos-item-sub {
    font-size: 11px;
    color: #888;
    margin-top: 2px;
}

.woos-dropdown-empty {
    padding: 12px 14px;
    color: #999;
    font-size: 13px;
    text-align: center;
}

/* Selected Office/Automat Info Card */
.woos-selected-info {
    margin-top: 10px;
    padding: 10px 12px;
    background: #f0faf0;
    border: 1px solid #c3e6c3;
    border-radius: 8px;
    font-size: 13px;
}

.woos-selected-info .woos-info-name {
    font-weight: 700;
    color: #2a7a2a;
    font-size: 14px;
    margin-bottom: 4px;
}

.woos-selected-info .woos-info-address {
    color: #555;
    line-height: 1.4;
}

.woos-selected-info .woos-info-change {
    display: inline-block;
    margin-top: 6px;
    font-size: 12px;
    color: #d40511;
    cursor: pointer;
    text-decoration: underline;
}

/* Shipping Price */
.woos-shipping-price {
    border-radius: 0 0 8px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #f8f8f8;
    border-top: 1px solid #eee;
}

.woos-price-label {
    font-size: 14px;
    font-weight: 500;
    color: #555;
}

.woos-price-value {
    font-size: 16px;
    font-weight: 700;
    color: #d40511;
}

.woos-price-value.free {
    color: #2a7a2a;
}

.woos-price-value.loading {
    color: #999;
    font-size: 14px;
}

.woos-price-delivery-date {
    font-size: 11px;
    color: #888;
    text-align: right;
    padding: 0 18px 10px;
    background: #f8f8f8;
}

/* Loading spinner */
.woos-loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ddd;
    border-top-color: #d40511;
    border-radius: 50%;
    animation: woos-spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

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

/* Responsive */
@media (max-width: 600px) {
    .woos-widget-header {
        padding: 9px 12px;
        gap: 8px;
    }

    .woos-widget-title {
        font-size: 11px;
    }

    .woos-delivery-tabs {
        flex-direction: row;
        gap: 5px;
        padding: 8px;
    }

    .woos-tab {
        padding: 9px 3px;
        gap: 4px;
    }

    .woos-checkout-widget .woos-tab-icon svg {
        width: 18px !important;
        height: 18px !important;
    }

    .woos-tab-label {
        font-size: 11px;
    }

    .woos-field-row {
        flex-direction: column;
        gap: 0;
    }

    .woos-panel {
        padding: 14px;
    }
}

@media (max-width: 380px) {
    /* Narrow phones: the logo alone identifies the courier. */
    .woos-widget-title {
        display: none;
    }

    .woos-tab-label {
        font-size: 10px;
    }

    .woos-checkout-widget .woos-tab-icon svg {
        width: 17px !important;
        height: 17px !important;
    }
}

/* ============================================================
   Избор на доставка в лявата колона (WOOS_Checkout_Layout)
   cart-shipping.php връща <tr>, затова е обвит в <table> —
   тук таблицата се връща обратно към блоков поток.
   ============================================================ */

.woos-checkout-shipping .woos-shipping-heading {
    margin: 5px 0 15px;
}

.woos-checkout-shipping .woos-shipping-table {
    width: 100%;
    margin: 0 0 30px;
    border: 0;
    border-collapse: collapse;
    background: none;
}

.woos-checkout-shipping .woos-shipping-table tbody,
.woos-checkout-shipping .woos-shipping-table tr,
.woos-checkout-shipping .woos-shipping-table th,
.woos-checkout-shipping .woos-shipping-table td {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0 !important;
    border: 0 !important;
    background: none !important;
    text-align: left !important;
}

/* Единственият пакет вече е озаглавен от h3-то отгоре. */
.woos-checkout-shipping .woos-shipping-table tr:only-child > th {
    display: none;
}

.woos-checkout-shipping .woos-shipping-table tr + tr > th {
    padding: 10px 0 8px !important;
    font-weight: 600;
}

.woos-checkout-shipping ul.woocommerce-shipping-methods {
    margin: 0;
    padding: 0;
    list-style: none;
}

.woos-checkout-shipping ul.woocommerce-shipping-methods li {
    margin: 0 0 10px;
    padding: 0;
    list-style: none;
    text-align: left;
}

.woos-checkout-shipping ul.woocommerce-shipping-methods li:last-child {
    margin-bottom: 0;
}

/* Радиото се скрива (но остава фокусируемо) — избраният куриер личи по
   картата. Темата иначе го пуска надясно с float. */
.woos-checkout-shipping ul.woocommerce-shipping-methods input[type="radio"] {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
    opacity: 0 !important;
    pointer-events: none;
}

.woos-checkout-shipping ul.woocommerce-shipping-methods label {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin: 0;
    padding: 12px 14px;
    border: 1px solid #e2e6ec;
    border-radius: 11px;
    background: #fff;
    cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.woos-checkout-shipping ul.woocommerce-shipping-methods label:hover {
    border-color: #c7cdd6;
}

.woos-checkout-shipping ul.woocommerce-shipping-methods input[type="radio"]:checked + label {
    border-color: var(--wd-primary-color, #D62839);
    box-shadow: inset 0 0 0 1px var(--wd-primary-color, #D62839);
}

.woos-checkout-shipping ul.woocommerce-shipping-methods input[type="radio"]:focus-visible + label {
    outline: 2px solid var(--wd-primary-color, #D62839);
    outline-offset: 2px;
}

.woos-rate {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-width: 0;
}

/* Фиксирана кутия + object-fit: логата на двата куриера са с много различни
   пропорции (Еконт е почти квадратно, Спиди — широко), а при еднаква височина
   Еконт изглежда двойно по-малко. */
.woos-rate-logo {
    width: 92px;
    height: 34px;
    flex: 0 0 auto;
    object-fit: contain;
    object-position: left center;
}

.woos-rate-body {
    flex: 1 1 auto;
    min-width: 0;
}

.woos-rate-title {
    display: block;
    font-weight: 600;
    line-height: 1.3;
}

.woos-rate-extra {
    display: block;
    overflow: hidden;
    font-size: 12px;
    line-height: 1.35;
    color: #6b7280;
    text-overflow: ellipsis;
}

.woos-rate-price {
    flex: 0 0 auto;
    font-weight: 700;
    white-space: nowrap;
}

/* Джаджите на куриерите вече разполагат с цялата ширина на формата. */
.woos-checkout-shipping .woos-checkout-widget,
.woos-checkout-shipping .wooe-checkout-widget {
    margin-top: 12px;
}

/* Редът с цената, който остава в кутията с поръчката. */
.woocommerce-checkout-review-order-table tr.woos-shipping-summary td {
    text-align: right;
}

@media (max-width: 480px) {
    .woos-checkout-shipping ul.woocommerce-shipping-methods label {
        gap: 10px;
        padding: 10px 12px;
    }

    .woos-rate-logo {
        width: 76px;
        height: 30px;
    }
}


/* ============================================================
   Валидация на полетата в checkout формата
   WooCommerce слага .woocommerce-validated / .woocommerce-invalid
   на реда; темата не ги оцветява по никакъв начин.
   ============================================================ */

.woocommerce-checkout .woocommerce-billing-fields .form-row .woocommerce-input-wrapper {
    position: relative;
    display: block;
}

.woocommerce-checkout .woocommerce-billing-fields .form-row.woocommerce-validated input.input-text,
.woocommerce-checkout .woocommerce-billing-fields .form-row.woocommerce-invalid input.input-text {
    padding-right: 40px;
}

.woocommerce-checkout .woocommerce-billing-fields .form-row.woocommerce-validated input.input-text {
    border-color: #2f9e63 !important;
    background-color: #f5fbf7;
}

.woocommerce-checkout .woocommerce-billing-fields .form-row.woocommerce-invalid input.input-text {
    border-color: #d63638 !important;
    background-color: #fdf7f7;
}

.woocommerce-checkout .woocommerce-billing-fields .form-row.woocommerce-validated .woocommerce-input-wrapper::after,
.woocommerce-checkout .woocommerce-billing-fields .form-row.woocommerce-invalid .woocommerce-input-wrapper::after {
    position: absolute;
    top: 50%;
    right: 15px;
    width: 18px;
    height: 18px;
    margin-top: -9px;
    content: '';
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    pointer-events: none;
}

.woocommerce-checkout .woocommerce-billing-fields .form-row.woocommerce-validated .woocommerce-input-wrapper::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232f9e63' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}

.woocommerce-checkout .woocommerce-billing-fields .form-row.woocommerce-invalid .woocommerce-input-wrapper::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d63638' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v6'/%3E%3Cpath d='M12 16.5v.5'/%3E%3C/svg%3E");
}

.woos-field-msg {
    display: block;
    margin: 6px 0 0 2px;
    font-size: 12px;
    line-height: 1.4;
    color: #d63638;
}

/* ===== Създаване на профил при поръчка ===== */

.woocommerce-account-fields {
    margin: 0 0 25px;
}

.woocommerce-account-fields .create-account {
    margin: 0;
}

.woocommerce-account-fields .create-account label {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin: 0;
    padding: 12px 14px;
    border: 1px solid #e2e6ec;
    border-radius: 11px;
    background: #fff;
    cursor: pointer;
    line-height: 1.4;
}

.woocommerce-account-fields .create-account label:hover {
    border-color: #c7cdd6;
}

.woocommerce-account-fields .create-account input.input-checkbox {
    flex: 0 0 auto;
    margin: 2px 0 0;
    float: none !important;
}

.woos-account-hint {
    margin: 8px 2px 0;
    font-size: 12.5px;
    line-height: 1.45;
    color: #6b7280;
}


/* ===== Данни за фактура (по избор) ===== */

.woos-invoice {
    margin: 0 0 25px;
}

.woos-invoice-toggle {
    margin: 0;
}

.woos-invoice-toggle label.checkbox {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin: 0;
    padding: 12px 14px;
    border: 1px solid #e2e6ec;
    border-radius: 11px;
    background: #fff;
    line-height: 1.4;
    cursor: pointer;
}

.woos-invoice-toggle label.checkbox:hover {
    border-color: #c7cdd6;
}

.woos-invoice-toggle input.input-checkbox {
    flex: 0 0 auto;
    margin: 2px 0 0;
    float: none !important;
}

.woos-invoice-fields {
    margin-top: 14px;
}

.woos-invoice-fields[hidden] {
    display: none;
}

/* Бележката към поръчката се мести под избора на куриер — без горния
   отстъп, който темата ѝ дава като на отделна секция. */
.woocommerce-additional-fields {
    margin-top: 0;
}

.woocommerce-additional-fields h3 {
    margin: 0 0 12px;
}
