/**
 * SO Form — Customer Address Selection, Location Name & Delivery Toggle
 * Compact layout — designed to fit within viewport height
 * @package DCN_SO_Manager
 */

/* ================================================================
   Address Panel — compact
   ================================================================ */
.so-addr-panel {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px 12px;
    margin: 8px 0 4px;
    animation: soAddrFadeIn 250ms ease-out;
}

@keyframes soAddrFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.so-addr-panel__label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12.5px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.so-addr-panel__hint {
    font-size: 11px;
    font-weight: 400;
    color: #9ca3af;
}

/* Address Cards — compact */
.so-addr-cards {
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-height: 180px;
    overflow-y: auto;
}

.so-addr-card {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    background: #fff;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    transition: all 150ms ease;
}

.so-addr-card:hover {
    border-color: #0d725e;
    background: #f0fdf4;
}

.so-addr-card.active {
    border-color: #0d725e;
    background: #ecfdf5;
    box-shadow: 0 0 0 2px rgba(13, 114, 94, 0.1);
}

.so-addr-card__radio {
    margin-top: 1px;
    width: 15px;
    height: 15px;
    accent-color: #0d725e;
    flex-shrink: 0;
}

.so-addr-card__body {
    flex: 1;
    min-width: 0;
}

.so-addr-card__header {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 2px;
    flex-wrap: wrap;
}

.so-addr-card__type {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 9999px;
    line-height: 1.4;
}

.so-addr-card__type--shipping {
    background: #cffafe;
    color: #155e75;
}

.so-addr-card__type--tax_invoice {
    background: #fef3c7;
    color: #92400e;
}

.so-addr-card__type--other {
    background: #f3f4f6;
    color: #4b5563;
}

.so-addr-card__primary {
    font-size: 9px;
    font-weight: 700;
    padding: 0 5px;
    border-radius: 9999px;
    background: #d1fae5;
    color: #065f46;
}

.so-addr-card__text {
    font-size: 12px;
    color: #374151;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.so-addr-card__location {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.so-addr-empty {
    text-align: center;
    padding: 12px;
    color: #9ca3af;
    font-size: 12px;
    background: #fff;
    border-radius: 6px;
    border: 1px dashed #d1d5db;
}

/* ================================================================
   Location Name Panel — compact inline
   ================================================================ */
.so-location-panel {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 8px 12px;
    margin: 4px 0 8px;
    animation: soAddrFadeIn 250ms ease-out;
}

.so-location-panel__label {
    font-size: 12px;
    font-weight: 600;
    color: #92400e;
    margin-bottom: 6px;
}

.so-location-panel__body {
    display: flex;
    align-items: center;
    gap: 8px;
}

.so-location-input {
    flex: 1;
    padding: 7px 10px;
    border: 1.5px solid #fde68a;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    background: #fff;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.so-location-input:focus {
    outline: none;
    border-color: #f59e0b;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.12);
}

.so-location-input::placeholder {
    color: #d1d5db;
    font-weight: 400;
    font-size: 12px;
}

.so-location-panel__hint {
    font-size: 10.5px;
    color: #b45309;
    margin: 0;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ================================================================
   Delivery Address Toggle — compact
   ================================================================ */
.so-delivery-toggle {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.so-delivery-toggle__option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    transition: all 150ms ease;
    font-size: 12.5px;
    color: #374151;
    flex: 1;
}

.so-delivery-toggle__option:hover {
    border-color: #0d725e;
}

.so-delivery-toggle__option:has(input:checked) {
    border-color: #0d725e;
    background: #ecfdf5;
}

.so-delivery-toggle__option input[type="radio"] {
    accent-color: #0d725e;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.so-delivery-toggle__text {
    font-weight: 500;
    font-size: 12px;
    line-height: 1.3;
}

/* Delivery preview — compact */
.so-delivery-preview {
    margin-top: 6px;
    padding: 7px 10px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 5px;
    font-size: 12px;
    color: #166534;
    line-height: 1.4;
    display: none;
}

.so-delivery-preview.visible {
    display: block;
}

.so-delivery-preview strong {
    font-size: 12px;
    color: #0d725e;
}

/* ================================================================
   Form compact overrides — fit viewport
   ================================================================ */
.rg-so-form-container .so-addr-panel + .so-location-panel {
    margin-top: 4px;
}

.rg-so-form-container .so-delivery-addr-group {
    margin-top: 0;
}

.rg-so-form-container #rg_delivery_custom_wrap textarea {
    min-height: 50px;
    max-height: 80px;
    font-size: 13px;
}

/* ================================================================
   Responsive
   ================================================================ */
@media (max-width: 768px) {
    .so-addr-panel {
        padding: 8px 10px;
    }

    .so-addr-cards {
        max-height: 150px;
    }

    .so-addr-card {
        padding: 6px 8px;
    }

    .so-delivery-toggle {
        flex-direction: column;
        gap: 4px;
    }

    .so-location-panel__body {
        flex-direction: column;
        align-items: stretch;
    }

    .so-location-panel__hint {
        white-space: normal;
    }
}
