:root {
  --bg: #121212;
  --card-bg: #1e1e2e;
  --text: #ffffff;
  --text-secondary: #a0a0a0;
  --primary: #a770ff;
  --accent: #ffd700;
  --border: #333;
  --danger: #ff4d4f;
  --success: #00c853;
  --header-height: 60px;
  --nav-height: 60px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
  overflow-x: hidden;
}

/* Utilities */
.hidden { display: none !important; }
.text-center { text-align: center; }
.btn-block { width: 100%; display: block; }

/* Page Structure */
#app-pages {
  width: 100%;
  min-height: 100vh;
  padding-bottom: var(--nav-height);
}

.page {
  display: block; /* Changed from none to block to rely on .hidden class */
  width: 100%;
  min-height: 100vh;
  animation: fadeIn 0.3s ease;
}

.page.hidden {
    display: none !important;
}

/* Remove .page.active requirement for display, use it only for animation if needed */
.page.active {
  /* display: block; - Removed redundancy */
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.main {
  padding: 15px;
  padding-top: calc(var(--header-height) + 50px); /* Header + Search/Filter */
}

.home-main {
    padding-top: 120px;
}

/* Header */
.header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background: var(--card-bg);
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
  padding: 10px 15px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.brand {
  font-size: 18px;
  font-weight: bold;
  color: var(--text);
}

.search-bar {
  display: flex;
  align-items: center;
  background: var(--bg);
  border-radius: 20px;
  padding: 5px 15px;
  margin-bottom: 10px;
}

.search-icon {
    color: var(--text-secondary);
    margin-right: 8px;
}

#q {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 14px;
  outline: none;
  height: 30px;
}

/* Filter Scroll */
.filter-scroll-container {
    overflow-x: auto;
    white-space: nowrap;
    margin: 0 -15px;
    padding: 0 15px 5px 15px;
    -webkit-overflow-scrolling: touch;
}

.filter-scroll-container::-webkit-scrollbar {
    display: none;
}

.filter-group {
    display: inline-flex;
    gap: 10px;
}

.filter-chip {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 12px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-chip.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.filter-btn {
    margin-left: 10px;
    padding: 5px 12px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Grid Layout */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

/* Card Styles */
.card {
  background: var(--card-bg);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0,0,0,0.2);
  transition: transform 0.2s;
}

.card:active {
    transform: scale(0.98);
}

.card-image-wrapper {
  position: relative;
  width: 100%;
  padding-top: 133%; /* 3:4 Aspect Ratio */
  background: #000;
}

.card-image-wrapper img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-overlay-location {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(0,0,0,0.6);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  backdrop-filter: blur(2px);
}

.card-like-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 30px;
    height: 30px;
    background: rgba(0,0,0,0.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
    cursor: pointer;
}

.card-body {
  padding: 10px;
}

.info-row {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-secondary);
    font-size: 12px;
    margin-bottom: 4px;
}

.info-row .icon {
    width: 14px;
    height: 14px;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.tag {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
}

.pink-tag {
    background: rgba(255, 105, 180, 0.2);
    color: #ff69b4;
}

.card-footer {
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Custom Page Styles */
.custom-container {
    padding-top: 70px;
    padding-bottom: 80px;
}

.custom-section-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
}

.section-header {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.section-header .icon {
    font-size: 18px;
    margin-right: 8px;
}

.section-header .title {
    font-weight: bold;
    font-size: 15px;
}

.range-input-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-wrapper {
    flex: 1;
    background: var(--bg);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
}

.input-wrapper:focus-within {
    border-color: var(--primary);
}

.custom-input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 14px;
    outline: none;
    text-align: center;
}

.custom-input.has-prefix {
    text-align: left;
    padding-left: 5px;
}

.unit, .prefix {
    color: var(--text-secondary);
    font-size: 12px;
}

.separator {
    color: var(--text-secondary);
    font-weight: bold;
}

.cup-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.cup-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.cup-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.checkbox-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.custom-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    background: var(--bg);
    padding: 8px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.custom-checkbox-item input {
    display: none;
}

.checkmark {
    width: 16px;
    height: 16px;
    border: 2px solid var(--text-secondary);
    border-radius: 4px;
    position: relative;
}

.custom-checkbox-item input:checked + .checkmark {
    background: var(--primary);
    border-color: var(--primary);
}

.custom-checkbox-item input:checked + .checkmark::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.label-text {
    font-size: 12px;
}

.custom-checkbox-item:has(input:checked) {
    border-color: var(--primary);
    background: rgba(167, 112, 255, 0.1);
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: var(--nav-height);
  background: var(--card-bg);
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-top: 1px solid rgba(255,255,255,0.05);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 10px;
  gap: 4px;
  width: 25%;
  height: 100%;
}

.nav-item.active {
  color: var(--primary);
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--card-bg);
    width: 85%;
    max-width: 320px;
    padding: 20px;
    border-radius: 16px;
    position: relative;
    animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
}

/* Added .close for other modals (e.g. Filter) */
.close {
    font-size: 24px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
}

.form-group {
    margin-bottom: 15px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
}

/* Buttons */
.btn {
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-lg {
    padding: 12px 30px;
    font-size: 16px;
}

/* Profile Page */
.profile-header-bg {
    height: 200px;
    background: linear-gradient(135deg, #a770ff, #7058ff);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: -1;
}

.profile-container {
    padding-top: 120px;
}

.profile-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    margin-bottom: 20px;
}

.user-info-card {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.user-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid var(--card-bg);
    margin-bottom: 10px;
}

.avatar-edit-btn {
    position: absolute;
    bottom: 10px;
    right: 0;
    background: var(--primary);
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.user-name {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 5px;
}

.user-id {
    color: var(--text-secondary);
    font-size: 12px;
}

.profile-stats {
    display: flex;
    width: 100%;
    justify-content: space-around;
    margin-top: 20px;
    border-top: 1px solid var(--border);
    padding-top: 15px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-num {
    font-size: 18px;
    font-weight: bold;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.menu-list {
    margin-top: 20px;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    cursor: pointer;
}

.menu-icon {
    margin-right: 15px;
    font-size: 18px;
}

.menu-text {
    flex: 1;
}

.menu-arrow {
    color: var(--text-secondary);
}

/* WeChat Overlay */
.wx-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #120c1f 0%, #1a1a2e 100%); /* 高端神秘背景 */
    z-index: 9999;
    color: white;
    padding: 40px;
    text-align: center;
    /* Flex Center */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.wx-guide-arrow {
    position: absolute;
    top: 15px;
    right: 25px;
    animation: bounce 2s infinite;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {transform: translateY(0);}
    40% {transform: translateY(-10px);}
    60% {transform: translateY(-5px);}
}

.wx-text-hint {
    display: block;
    margin-top: 5px;
    font-size: 14px;
    color: var(--primary);
    font-weight: bold;
    text-shadow: 0 0 10px rgba(167, 112, 255, 0.5);
}

.wx-content {
    margin-top: -50px; /* 略微上移 */
    background: rgba(255, 255, 255, 0.05);
    padding: 30px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    max-width: 80%;
}

.wx-icon-wrapper {
    margin-bottom: 20px;
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary), #7058ff);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px auto;
    box-shadow: 0 5px 15px rgba(167, 112, 255, 0.4);
}

.wx-icon {
    font-size: 40px;
}

.wx-content h2 {
    font-size: 24px;
    margin-bottom: 15px;
    background: linear-gradient(to right, #fff, #a770ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.wx-content p {
    font-size: 16px;
    line-height: 1.8;
    color: #ddd;
}

.wx-content strong {
    color: var(--accent);
    padding: 0 4px;
}

/* Chat Styles */
.message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.message.user {
    align-items: flex-end;
}

.message.service, .message.system {
    align-items: flex-start;
}

.message.system .bubble {
    background: var(--card-bg);
    font-size: 12px;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.bubble {
    max-width: 80%;
    width: fit-content;
    padding: 10px 15px;
    border-radius: 12px;
    background: var(--card-bg);
    font-size: 14px;
    line-height: 1.4;
    word-break: break-word;
}

.message.user .bubble {
    background: var(--primary);
    color: white;
}

.chat-messages {
    padding: 15px;
    overflow-y: auto;
}

.chat-input-area {
    display: flex;
    gap: 10px;
}

.chat-input-area input {
    flex: 1;
    padding: 10px;
    border-radius: 20px;
    border: none;
    background: var(--card-bg);
    color: white;
    outline: none;
}

.chat-input-area button {
    padding: 8px 20px;
    border-radius: 20px;
    border: none;
    background: var(--primary);
    color: white;
}

/* Detail Modal */
.detail {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    z-index: 500;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.detail-navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 50px;
    display: flex;
    align-items: center;
    padding: 0 15px;
    background: rgba(0,0,0,0.5);
    z-index: 10;
    backdrop-filter: blur(5px);
}

.btn-back {
    background: none;
    border: none;
    color: white;
    display: flex;
    align-items: center;
    gap: 5px;
}

.detail-header-image {
    height: 400px;
    position: relative;
    overflow: hidden;
}

.carousel-track {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    height: 100%;
}

.carousel-track img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    flex-shrink: 0;
    scroll-snap-align: center;
}

.detail-image-overlay {
    position: absolute;
    bottom: 15px;
    right: 15px;
    background: rgba(0,0,0,0.5);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
}

.detail-section {
    padding: 20px;
    background: var(--card-bg);
    margin-bottom: 10px;
}

.detail-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.detail-id {
    font-size: 24px;
    font-weight: bold;
}

.verified-badge {
    background: rgba(0, 200, 83, 0.2);
    color: #00c853;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
}

.detail-info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.info-item .label {
    color: var(--text-secondary);
    font-size: 12px;
    margin-bottom: 4px;
}

.info-item .value {
    font-size: 16px;
    font-weight: 500;
}

.value.highlight {
    color: var(--accent);
}

.service-tags-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.service-tag-item {
    background: rgba(0, 200, 83, 0.1);
    color: #00c853;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.detail-footer-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 15px;
    background: var(--card-bg);
    display: flex;
    gap: 15px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
    padding-bottom: max(15px, env(safe-area-inset-bottom));
}

.action-btn {
    flex: 1;
    padding: 12px;
    border-radius: 25px;
    border: none;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.action-btn.primary {
    background: linear-gradient(135deg, #a770ff, #7058ff);
    color: white;
}

.action-btn.secondary {
    background: var(--bg);
    color: var(--text);
}

/* Filter Modal Styles */
.region-group {
    margin-bottom: 15px;
}

.region-group-title {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    padding-left: 5px;
}

.region-group-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.filter-footer {
    position: sticky;
    bottom: 0;
    display: flex;
    gap: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

/* Service Page Fixed Layout */
#page-service.page {
    position: fixed; /* 强制固定定位，防止整体滚动 */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%; /* Fallback */
    height: 100dvh; /* 适配移动端动态视口 */
    min-height: 0; /* 覆盖 .page 的 min-height */
    overflow: hidden; /* 禁止溢出滚动 */
    display: flex;
    flex-direction: column;
    z-index: 50; /* 确保在底层，但不遮挡 nav */
    background-color: var(--bg);
    padding-bottom: 0 !important; /* 覆盖 #app-pages 的 padding */
}

#page-service .service-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 !important;
    margin-top: 60px; /* Header height */
    margin-bottom: 60px; /* Nav height */
    height: auto; /* 让 flex 容器自动填充 */
    overflow: hidden;
    position: relative;
    width: 100%;
}

#page-service .chat-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* 开启 iOS 平滑滚动 */
    padding: 15px;
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#page-service .chat-input-area {
    flex-shrink: 0;
    padding: 10px;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    z-index: 20;
    position: relative; /* 确保层级正确 */
}

#page-service .chat-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 30;
    backdrop-filter: blur(2px);
}

#page-service .overlay-content {
    text-align: center;
    background: var(--card-bg);
    padding: 20px 40px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

#page-service .overlay-content p {
    margin-bottom: 15px;
    color: var(--text);
}
