/* Container for Location Manager */
.loc-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Location Tree Container */
#loc-tree-container {
    max-height: 600px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    padding: 10px;
}

/* Scrollbar styling */
#loc-tree-container::-webkit-scrollbar {
    width: 6px;
}

#loc-tree-container::-webkit-scrollbar-track {
    background: #f1f5f9;
}

#loc-tree-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

/* Tree Structure */
.tax-tree {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tax-tree ul {
    list-style: none;
    padding-left: 20px;
    border-left: 1px solid #e2e8f0;
    margin-left: 10px;
    margin-top: 5px;
    margin-bottom: 5px;

    /* Hidden by default for logic control */
    display: none;
}

.tax-tree ul.show {
    display: block;
}

.tax-tree li {
    margin-bottom: 2px;
}

/* Tree Item */
.tree-item {
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.tree-item:hover {
    background-color: #f8fafc;
    border-color: #e2e8f0;
    transform: translateX(2px);
}

.tree-item.active {
    background-color: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-active);
    font-weight: 500;
}

.tree-item .name-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tree-item .name {
    font-size: 14px;
}

.tree-item .badge {
    font-size: 11px;
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
    color: #475569;
}

/* Toggle Button */
.toggle-btn {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 12px;
    color: #64748b;
    transition: background 0.2s;
}

.toggle-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

/* ===== Location Change Prompt ===== */
.loc-change-prompt {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: linear-gradient(135deg, var(--primary-active) 0%, var(--primary) 100%);
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    animation: loc-slide-in 0.3s ease-out;
}

@keyframes loc-slide-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.loc-change-content {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.loc-change-content span {
    font-size: 14px;
}

.loc-change-actions {
    display: flex;
    gap: 8px;
}

.loc-change-actions .btn {
    padding: 6px 14px;
    font-size: 13px;
    border-radius: 6px;
}

.loc-change-actions .btn:not(.btn-primary) {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.loc-change-actions .btn:not(.btn-primary):hover {
    background: rgba(255, 255, 255, 0.3);
}

.loc-change-actions .btn-primary {
    background: white;
    color: var(--primary-active);
}

/* ===== Pin Indicator ===== */
.loc-pin-indicator {
    font-size: 12px;
    margin-left: 2px;
    cursor: help;
}

/* ===== Pin Checkbox in Modal ===== */
.loc-pin-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #475569;
    cursor: pointer;
    white-space: nowrap;
}

.loc-pin-wrap input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.loc-pin-wrap span {
    user-select: none;
    font-weight: 500;
}

/* ===== Small Button Variant ===== */
.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* ===== Reset to Auto-Detect Button ===== */
.loc-reset-btn {
    background: #6b7280;
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.loc-reset-btn:hover {
    background: #4b5563;
}

.loc-reset-btn:active {
    background: #374151;
}

/* ===== Location Modal Styles ===== */
/* Moved from static/css/style.css per AGENTS.md Rule 7 */

.loc-overlay {
    z-index: 101;
}

body:has(#locOverlay.show) .mobile-guest-wa-float {
    display: none !important;
}

.loc-modal {
    width: min(560px, calc(100vw - 32px));
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 22px 60px rgba(15, 23, 42, 0.16);
}

.loc-modal .modal-head {
    min-height: 78px;
    padding: 22px 18px 16px;
    border-bottom: 1px solid #EEF2F6;
}

.loc-modal .modal-head .h {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0;
}

.loc-modal .close {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    color: #0F172A;
    transition: background-color 60ms linear, color 60ms linear;
}

.loc-modal .close:hover {
    background: #F4F6F8;
    color: #020617;
}

.loc-modal-body {
    padding: 0;
    display: flex;
    flex-direction: column;
    height: auto;
    max-height: calc(100dvh - 120px);
    background: #FFFFFF;
}

.loc-cols {
    flex: 0 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    overflow: hidden;
    border-bottom: 1px solid #EEF2F6;
}

.loc-cols[data-step="country"] #cityCol,
.loc-cols[data-step="city"] #countryCol {
    display: none;
}

.loc-col {
    min-height: 0;
    overflow: hidden;
    border-right: 0;
    background: #FFFFFF;
    display: flex;
    flex-direction: column;
}

.loc-head {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 11px 18px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748B;
    letter-spacing: 0.05em;
    background: #FFFFFF;
    border-bottom: 1px solid #EEF2F6;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.loc-head-chip {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    background: #F1F5F9;
    text-transform: none;
    letter-spacing: 0;
    font-size: 11px;
    font-weight: 700;
    color: #64748B;
}

.loc-head--step {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    justify-content: stretch;
}

.loc-step-back {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #64748B;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 60ms linear, color 60ms linear;
}

.loc-step-back:hover {
    background: #F1F5F9;
    color: #0F172A;
}

.loc-step-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    min-height: 30px;
    padding: 0 10px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #0F172A;
    font-size: 12px;
    font-weight: 800;
    text-transform: none;
    letter-spacing: 0;
    text-align: left;
    cursor: pointer;
    transition: background-color 60ms linear, color 60ms linear;
}

.loc-step-title:hover {
    background: #F4F6F8;
    color: #020617;
}

.loc-search-wrap {
    flex: 0 0 auto;
    padding: 16px 20px;
    border-bottom: 1px solid #EEF2F6;
    background: #fff;
    z-index: 5;
}

/* Ensure the nested input-wrap behaves properly */
.loc-search-wrap .input-wrap {
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
}

.loc-search-wrap .input.loc-search-input {
    width: 100%;
    padding: 10px 14px 10px 44px;
    font-size: 14px;
    border-radius: 16px;
    height: 48px;
    box-sizing: border-box;
    border: 1px solid #E2E8F0;
    outline: none;
    background: #FFFFFF;
    color: #0F172A;
    transition: border-color 60ms linear, background-color 60ms linear;
}

.loc-search-wrap .input.loc-search-input:focus {
    border-color: #CBD5E1;
    background: #FBFCFE;
}

.loc-search-wrap .input-icon {
    left: 16px;
    color: #94A3B8;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 2;
}

.loc-selection-summary {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    border-bottom: 1px solid #EEF2F6;
    background: #FBFCFE;
}

.loc-selection-label {
    color: #64748B;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.loc-selection-copy {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.loc-selection-main-row {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.loc-selection-main,
.loc-selection-sub {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.loc-selection-main {
    color: #0F172A;
    font-size: 14px;
    font-weight: 800;
}

.loc-selection-sub {
    color: #64748B;
    font-size: 12px;
    font-weight: 600;
}

.loc-selection-flag {
    width: 24px;
    height: 18px;
    flex-basis: 24px;
}

.loc-list {
    flex: 0 1 auto;
    height: 280px;
    min-height: 280px;
    max-height: min(42dvh, 360px);
    overflow-y: auto;
    padding: 10px 0 14px;
    scrollbar-width: thin;
    scrollbar-color: #CBD5E1 transparent;
}

.loc-list::-webkit-scrollbar {
    width: 8px;
}

.loc-list::-webkit-scrollbar-track {
    background: transparent;
}

.loc-list::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border: 2px solid #FFFFFF;
    border-radius: 999px;
}

.loc-list::-webkit-scrollbar-thumb:hover {
    background: #94A3B8;
}

.loc-list--empty {
    display: flex;
    align-items: flex-start;
}

.loc-opt {
    min-height: 56px;
    margin: 4px 12px;
    padding: 12px 14px;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: #334155;
    border-radius: 12px;
    transition: background-color 60ms linear, color 60ms linear;
}

.loc-opt[hidden] {
    display: none;
}

.loc-opt-main {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.loc-opt-copy {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.loc-opt-copy--row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.loc-flag {
    width: 30px;
    height: 22px;
    flex: 0 0 30px;
    object-fit: contain;
    border-radius: 4px;
    background: #FFFFFF;
    padding: 1px;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.10);
}

.loc-opt-sub {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #64748B;
    font-size: 12px;
    font-weight: 500;
}

.loc-opt-check {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.loc-opt-side {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.loc-change-country {
    height: 30px;
    padding: 0 9px 0 10px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #52657C;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    transition: background-color 60ms linear, color 60ms linear;
}

.loc-change-country:hover {
    background: #FFFFFF;
    color: #0F172A;
}

.loc-change-country svg {
    flex: 0 0 auto;
}

.loc-opt.active .loc-opt-check::before,
.loc-opt.selected .loc-opt-check::before {
    content: '';
    width: 7px;
    height: 4px;
    border-left: 2px solid #0F172A;
    border-bottom: 2px solid #0F172A;
    transform: rotate(-45deg) translateY(-1px);
}

.loc-opt:hover {
    background: #F4F6F8;
    color: #0F172A;
}

.loc-opt.selected {
    background: #EEF2F5;
    color: #0F172A;
    font-weight: 700;
}

.loc-opt.active {
    background: #EEF2F5;
    color: #0F172A;
    font-weight: 700;
}

.loc-opt-all {
    min-height: 64px;
}

.loc-empty-state {
    margin: 28px 18px;
    padding: 18px;
    border: 1px dashed #DDE5EE;
    border-radius: 16px;
    background: #FFFFFF;
    color: #64748B;
}

.loc-empty-title {
    color: #0F172A;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 4px;
}

.loc-empty-copy {
    font-size: 13px;
    line-height: 1.45;
}

.loc-footer {
    min-height: 78px;
    padding: 16px 26px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #FFFFFF;
    border-top: 1px solid #EEF2F6;
}

.loc-footer .loc-pin-wrap {
    flex: 1;
    margin: 0;
    padding: 0;
}

.loc-footer .btn {
    min-width: auto;
    min-height: 44px;
    border-radius: 999px;
    padding: 0 24px;
    font-weight: 700;
    transition: background-color 60ms linear, color 60ms linear, border-color 60ms linear;
}

.loc-footer .btn:not(.btn-primary) {
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    color: #0F172A;
}

.loc-footer .btn:not(.btn-primary):hover {
    background: #F4F6F8;
}

@media (max-width: 900px) {
    .loc-modal {
        width: calc(100vw - 16px);
        height: auto;
        max-height: calc(100dvh - 24px);
        border-radius: 18px;
        display: flex;
        flex-direction: column;
    }

    @supports not (height: 100dvh) {
        .loc-modal {
            max-height: calc(100vh - 24px);
        }
    }

    .loc-modal .modal-head {
        flex: 0 0 auto;
    }

    .loc-modal-body {
        flex: 0 1 auto;
        min-height: 0;
        height: auto;
        max-height: calc(100dvh - 104px);
    }

    .loc-cols {
        grid-template-columns: 1fr;
        flex: 0 1 auto;
        min-height: 0;
        max-height: calc(100dvh - 184px);
        overflow: hidden;
        align-content: start;
    }

    .loc-col {
        min-height: 0;
        max-height: none;
        overflow: hidden;
        border-right: 0;
        border-bottom: 0;
    }

    .loc-col:last-child {
        border-bottom: 0;
    }

    .loc-list {
        flex: 0 1 auto;
        height: 300px;
        min-height: 300px;
        max-height: min(48dvh, 360px);
        overflow-y: auto;
    }

    .loc-list--empty {
        max-height: min(48dvh, 360px);
    }

    .loc-footer {
        flex: 0 0 auto;
        padding: 14px 18px;
    }
}

@media (max-width: 480px) {
    .loc-modal {
        width: calc(100vw - 12px);
        height: auto;
        max-height: calc(100dvh - 24px);
        border-radius: 16px;
    }

    @supports not (height: 100dvh) {
        .loc-modal {
            max-height: calc(100vh - 24px);
        }
    }

    .loc-modal .modal-head {
        min-height: 68px;
        padding: 16px 14px 12px;
    }

    .loc-head {
        padding: 10px 14px;
    }

    .loc-search-wrap {
        padding: 12px 14px;
    }

    .loc-selection-summary {
        grid-template-columns: auto minmax(0, 1fr) auto;
        padding: 9px 14px;
        gap: 10px;
    }

    .loc-selection-main {
        font-size: 13px;
    }

    .loc-selection-sub {
        font-size: 11px;
    }

    .loc-opt {
        margin-left: 8px;
        margin-right: 8px;
        min-height: 54px;
        padding: 11px 12px;
    }

    .loc-opt-side {
        gap: 6px;
    }

    .loc-change-country {
        max-width: 86px;
        padding: 0 8px;
        overflow: hidden;
    }

    .loc-change-country span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .loc-flag {
        width: 28px;
        height: 21px;
        flex-basis: 28px;
    }

    .loc-list {
        height: 280px;
        min-height: 280px;
        max-height: min(46dvh, 320px);
    }

    .loc-footer {
        min-height: 72px;
        padding: 12px 14px;
    }
}
