/* Unified Location Picker — Phase D1 styles.
 * Scoped under .up-* — safe alongside Bootstrap and existing Himish CSS.
 * Visual language matches /admin/general-settings.php (Bootstrap 5 base).
 */

.up-root {
    display: block;
    font-size: 14px;
    line-height: 1.4;
    color: #212529;
}

.up-loading,
.up-error {
    padding: 12px 14px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    background: #f8f9fa;
}

.up-spinner-row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #6c757d;
}

.up-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #ced4da;
    border-top-color: #0d6efd;
    border-radius: 50%;
    animation: up-spin 0.8s linear infinite;
}

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

.up-error {
    border-color: #f5c2c7;
    background: #f8d7da;
    color: #842029;
}

.up-error-msg {
    font-size: 14px;
}

.up-error-quote {
    margin-top: 6px;
    padding: 6px 10px;
    background: #fff3cd;
    border: 1px solid #ffe69c;
    color: #664d03;
    border-radius: 4px;
    font-size: 13px;
}

/* Search row */
.up-search-row {
    margin-bottom: 8px;
}

.up-search.form-control {
    width: 100%;
}

.up-search:disabled {
    background: #e9ecef;
    cursor: not-allowed;
}

/* Chip row */
.up-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 8px 0;
}

.up-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px 4px 10px;
    background: #e7f1ff;
    color: #084298;
    border: 1px solid #b6d4fe;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.2;
    max-width: 100%;
}

.up-chip[data-source="ai"] {
    background: #e2f0d9;
    border-color: #b6e0a1;
    color: #1e5631;
}

.up-chip[data-source="preselected"] {
    background: #f0e8ff;
    border-color: #d4c2ff;
    color: #5026a7;
}

.up-chip-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 240px;
}

.up-chip-x {
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 18px;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.up-chip-x:hover,
.up-chip-x:focus {
    background: rgba(0, 0, 0, 0.08);
    outline: none;
}

/* Search results list */
.up-results {
    list-style: none;
    margin: 0;
    padding: 4px 0;
    border: 1px solid #ced4da;
    border-radius: 6px;
    max-height: 280px;
    overflow-y: auto;
    background: #fff;
}

.up-results-empty {
    padding: 10px 12px;
    color: #6c757d;
    font-style: italic;
}

.up-results-group-label {
    padding: 4px 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.up-results-group-label:first-child {
    border-top: 0;
}

.up-result-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    border-top: 1px solid #f1f3f5;
}

.up-result-item:first-child,
.up-results-group-label + .up-result-item {
    border-top: 0;
}

.up-result-item:hover:not(.up-result-disabled) {
    background: #f1f7ff;
}

.up-result-item.up-result-selected {
    background: #e7f1ff;
}

.up-result-item.up-result-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.up-result-name {
    flex: 1;
}

.up-result-type {
    font-size: 11px;
    color: #6c757d;
    text-transform: capitalize;
    background: #f1f3f5;
    border-radius: 10px;
    padding: 2px 8px;
}

.up-result-check {
    color: #0d6efd;
    font-weight: 700;
}

/* Hierarchy tree (single-mode default) */
.up-tree {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid #ced4da;
    border-radius: 6px;
    max-height: 360px;
    overflow-y: auto;
    background: #fff;
}

.up-tree-node {
    border-top: 1px solid #f1f3f5;
}

.up-tree-node:first-child {
    border-top: 0;
}

.up-tree-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
}

.up-tree-toggle,
.up-tree-toggle-spacer {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: #6c757d;
    cursor: pointer;
    border-radius: 4px;
    font-size: 12px;
}

.up-tree-toggle:hover,
.up-tree-toggle:focus {
    background: #f1f3f5;
    outline: none;
}

.up-tree-pick {
    flex: 1;
    border: 0;
    background: transparent;
    text-align: left;
    padding: 6px 8px;
    cursor: pointer;
    border-radius: 4px;
}

.up-tree-pick:hover,
.up-tree-pick:focus {
    background: #f1f7ff;
    outline: none;
}

.up-tree-selected > .up-tree-row > .up-tree-pick {
    background: #e7f1ff;
    color: #084298;
    font-weight: 600;
}

.up-tree-type {
    font-size: 11px;
    color: #6c757d;
    text-transform: capitalize;
    margin-left: 4px;
}

.up-tree-check {
    color: #0d6efd;
    font-weight: 700;
    margin-left: 4px;
}

.up-tree-children {
    list-style: none;
    margin: 0;
    padding: 0 0 0 22px;
    border-top: 1px solid #f1f3f5;
    background: #fafbfc;
}

/* Quote line */
.up-quote-line {
    margin-top: 10px;
    padding: 8px 12px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #495057;
    flex-wrap: wrap;
}

.up-quote-cap {
    font-weight: 600;
    color: #212529;
}

.up-quote-sep {
    color: #adb5bd;
}

.up-quote-price {
    font-weight: 700;
    color: #084298;
}

.up-cap-warning {
    color: #842029;
    font-weight: 600;
    margin-left: auto;
}

.up-quote-empty,
.up-quote-loading {
    color: #6c757d;
    font-style: italic;
}

.up-quote-unsupported {
    color: #6c757d;
}

.up-quote-error {
    color: #842029;
    background: #f8d7da;
    border-color: #f5c2c7;
}

/* Phase D1 GAP 3 — Request-area form */
.up-results-empty-msg {
    margin-bottom: 6px;
}

.up-request-open {
    color: #0d6efd;
    text-decoration: underline;
    font-style: normal;
    font-size: 13px;
    cursor: pointer;
}

.up-request-open:hover,
.up-request-open:focus {
    color: #0a58ca;
    outline: none;
}

.up-request-form {
    margin-top: 10px;
    padding: 12px;
    background: #fffdf5;
    border: 1px solid #ffe69c;
    border-radius: 6px;
    font-style: normal;
    color: #212529;
}

.up-request-form-row {
    margin-bottom: 8px;
}

.up-request-form-row:last-of-type {
    margin-bottom: 6px;
}

.up-request-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #495057;
}

.up-required {
    color: #dc3545;
    margin-left: 2px;
}

.up-optional {
    color: #6c757d;
    font-weight: 400;
}

.up-request-name.form-control,
.up-request-notes.form-control {
    width: 100%;
    font-size: 14px;
}

.up-request-notes.form-control {
    resize: vertical;
}

.up-request-form-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.up-request-error {
    color: #842029;
    background: #f8d7da;
    border: 1px solid #f5c2c7;
    border-radius: 4px;
    padding: 6px 10px;
    margin-bottom: 8px;
    font-size: 13px;
}

.up-request-success {
    margin-bottom: 10px;
    padding: 8px 12px;
    background: #d1e7dd;
    border: 1px solid #badbcc;
    color: #0f5132;
    border-radius: 6px;
    font-size: 13px;
}

/* Mobile */
@media (max-width: 575px) {
    .up-search.form-control {
        font-size: 16px; /* prevent iOS zoom-on-focus */
    }
    .up-chip-label {
        max-width: 160px;
    }
    .up-results,
    .up-tree {
        max-height: 240px;
    }
}
