/* 地址选择器样式 */
.address-picker-container {
    position: relative;
}

.address-picker-trigger {
    position: relative;
}

.address-display {
    width: 100%;
    padding: 10px 35px 10px 12px;
    height: 45px;
    line-height: 1.5;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
    cursor: pointer;
    transition: border-color 0.3s;
    box-sizing: border-box;
}

.address-display:focus {
    outline: none;
    border-color: #3b82f6;
}

.address-picker-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #666;
    font-size: 16px;
}

.address-detail-input {
    width: 100%;
    padding: 10px 12px;
    height: 45px;
    line-height: 1.5;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: border-color 0.3s;
    box-sizing: border-box;
}

.address-detail-input:focus {
    outline: none;
    border-color: #3b82f6;
}

/* 地址选择器模态框 */
.address-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 99999;
    display: none; /* 使用display控制显示隐藏，完全禁用动画 */
    overflow: hidden; /* 改为hidden防止背景层滚动 */
    padding: 20px;
}

/* 暗黑模式下的模态框背景 */
body.dark-theme .address-modal-backdrop {
    background-color: rgba(0, 0, 0, 0.7);
}

.address-modal-backdrop.show {
    display: block; /* 直接显示，无动画 */
}

/* 桌面端居中显示 */
@media (min-width: 768px) {
    .address-modal-backdrop.show {
        display: flex; /* show状态下使用flex */
        align-items: center;
        justify-content: center;
        overflow-y: auto; /* 桌面端允许整体滚动 */
        -webkit-overflow-scrolling: touch;
    }
}

.address-modal-dialog {
    width: 100%;
    max-width: 500px;
    background-color: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    /* 完全移除所有transition */
    margin: 0 auto;
}

/* 移动端从底部弹出 - 禁用所有动画 */
@media (max-width: 767px) {
    .address-modal-dialog {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-width: 100%;
        /* 移除所有transform，直接定位在底部 */
        border-radius: 16px 16px 0 0;
        max-height: 85vh;
        display: flex;
        flex-direction: column;
    }
    
    .address-modal-body {
        max-height: calc(85vh - 120px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* 移动端底部按钮间距优化 */
    .address-modal-footer {
        padding-top: 20px;
        padding-bottom: 8px; /* 底部内边距 */
        padding-bottom: calc(8px + env(safe-area-inset-bottom)); /* 适配 iPhone 底部安全区域 */
    }
}

/* 桌面端样式已经完全移除动画 */

.address-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    position: relative;
}

.address-modal-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.address-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: #6b7280;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.address-modal-close:hover {
    background-color: #f3f4f6;
}

.address-modal-body {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* iOS平滑滚动 */
    overscroll-behavior: contain; /* 防止滚动链 */
}

.address-modal-footer {
    padding: 16px 20px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* 地址选择器内容 */
.address-tabs {
    display: flex;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 16px;
}

.address-tab {
    padding: 10px 16px;
    cursor: pointer;
    position: relative;
    font-size: 14px;
    color: #6b7280;
    transition: color 0.2s;
}

.address-tab:hover {
    color: #374151;
}

.address-tab.active {
    color: #3b82f6;
}

.address-tab.active::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background-color: #3b82f6;
}

/* 暗黑模式下的标签页激活状态 */
body.dark-theme .address-tab.active {
    color: #60a5fa !important;
}

body.dark-theme .address-tab.active::after {
    background-color: #60a5fa !important;
}

.address-panel {
    display: none;
}

.address-panel.active {
    display: block;
}

.address-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* iOS平滑滚动 */
    overscroll-behavior: contain; /* 防止滚动链 */
    scroll-behavior: smooth; /* 平滑滚动 */
    
    /* 自定义滚动条样式（Webkit浏览器） */
    scrollbar-width: thin;
    scrollbar-color: #d1d5db #f3f4f6;
}

/* Webkit滚动条样式 */
.address-list::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.address-list::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 3px;
}

.address-list::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
    transition: background 0.2s;
}

.address-list::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.address-item {
    padding: 8px 12px;
    text-align: center;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.address-item:hover {
    background-color: #f3f4f6;
    border-color: #d1d5db;
}

.address-item.active {
    background-color: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

/* 暗黑模式下的地址项选中状态 - 覆盖主题的!important */
body.dark-theme .address-modal-backdrop .address-item.active {
    background-color: #3b82f6 !important;
    color: white !important;
    border-color: #3b82f6 !important;
}

/* 暗黑模式下的地址项hover状态 - 强制蓝色覆盖主题样式 */
body.dark-theme .address-modal-backdrop .address-item:hover {
    background-color: #3b82f6 !important;
    color: white !important;
    border-color: #3b82f6 !important;
}

/* 暗黑模式下的地址项点击/聚焦状态 - 立即显示蓝色 */
body.dark-theme .address-modal-backdrop .address-item:active,
body.dark-theme .address-modal-backdrop .address-item:focus {
    background-color: #3b82f6 !important;
    color: white !important;
    border-color: #3b82f6 !important;
    outline: none;
}

/* 按钮样式 */
.address-btn {
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.address-btn-primary {
    background-color: #3b82f6;
    color: white;
}

.address-btn-primary:hover {
    background-color: #2563eb;
}

.address-btn-primary:active,
.address-btn-primary:focus {
    background-color: #1d4ed8;
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.address-btn-secondary {
    background-color: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.address-btn-secondary:hover {
    background-color: #e5e7eb;
}

.address-btn-secondary:active,
.address-btn-secondary:focus {
    background-color: #d1d5db;
    outline: none;
    box-shadow: 0 0 0 2px rgba(156, 163, 175, 0.3);
}

/* 暗黑模式下的按钮样式 */
body.dark-theme .address-btn-primary {
    background-color: #3b82f6 !important;
    color: white !important;
}

body.dark-theme .address-btn-primary:hover {
    background-color: #2563eb !important;
}

body.dark-theme .address-btn-primary:active,
body.dark-theme .address-btn-primary:focus {
    background-color: #1d4ed8 !important;
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.4) !important;
}

body.dark-theme .address-btn-secondary {
    background-color: rgba(75, 85, 99, 0.3) !important;
    color: var(--main-color, #e5eef7) !important;
    border-color: rgba(156, 163, 175, 0.3) !important;
}

body.dark-theme .address-btn-secondary:hover {
    background-color: rgba(75, 85, 99, 0.5) !important;
}

body.dark-theme .address-btn-secondary:active,
body.dark-theme .address-btn-secondary:focus {
    background-color: rgba(75, 85, 99, 0.7) !important;
    box-shadow: 0 0 0 2px rgba(156, 163, 175, 0.3) !important;
}

/* 加载状态 */
.address-loading {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
}

.address-loading p {
    margin-top: 12px;
    font-size: 14px;
}

.address-loading-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 2px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: address-spin 0.8s linear infinite;
    margin: 0 auto;
}

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

/* 错误提示 */
.address-error {
    text-align: center;
    padding: 20px;
    color: #ef4444;
}

/* 无数据提示 */
.address-no-data {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
    font-size: 14px;
    line-height: 1.5;
}

.address-no-data::before {
    content: '📍';
    display: block;
    font-size: 32px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* 错误状态样式 */
.address-display.error,
.address-detail-input.error {
    border-color: #ef4444 !important;
    background-color: #fef2f2;
}

.address-display.error::placeholder,
.address-detail-input.error::placeholder {
    color: #ef4444;
}

/* 响应式设计 */
@media (max-width: 640px) {
    .address-list {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    
    /* 移动端触摸优化 */
    .address-item {
        padding: 12px 8px;
        font-size: 15px;
    }
    
    .address-tab {
        padding: 12px 16px;
        font-size: 15px;
    }
    
    .address-btn {
        padding: 12px 20px;
        font-size: 15px;
    }
    
    /* 确保小屏幕也有足够的底部间距 */
    .address-modal-footer {
        padding-bottom: 8px !important;
        padding-bottom: calc(8px + env(safe-area-inset-bottom)) !important;
    }
    
    /* 防止iOS橡皮筋效果和滚动问题 */
    .address-modal-backdrop {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        touch-action: pan-y; /* 只允许垂直滚动 */
    }
    
    /* 移动端优化地址列表滚动 */
    .address-list {
        -webkit-transform: translateZ(0); /* 启用硬件加速 */
        transform: translateZ(0);
        will-change: scroll-position; /* 优化滚动性能 */
    }
    
    /* 移动端拖动条 */
    .address-modal-header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background-color: #d1d5db;
        border-radius: 2px;
    }
}