/* ========== AR Fun World - Global Styles ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #FF6B35;
  --primary-light: #FF8F65;
  --primary-dark: #E55A25;
  --bg: #F8F9FA;
  --card: #FFFFFF;
  --text: #2C3E50;
  --text-secondary: #7F8C8D;
  --text-light: #BDC3C7;
  --border: #E8EAED;
  --success: #27AE60;
  --danger: #E74C3C;
  --warning: #F39C12;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-full: 50%;
}

body {
  font-family: -apple-system, 'PingFang SC', 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  width: 100vw;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ========== Status Bar (for WebView) ========== */
.status-bar {
  height: 44px;
  background: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* ========== Header ========== */
.header {
  background: white;
  padding: 8px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.header-back {
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  color: var(--text);
}

/* ========== Search Bar ========== */
.search-bar {
  background: white;
  padding: 8px 16px 12px;
}
.search-wrapper {
  position: relative;
}
.search-input {
  width: 100%;
  height: 44px;
  background: #F0F2F5;
  border: none;
  border-radius: 22px;
  padding: 0 16px 0 44px;
  font-size: 16px;
  color: var(--text);
  outline: none;
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 18px;
}

/* ========== Category Tabs ========== */
.tabs {
  background: white;
  padding: 0 16px;
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
}
.tab {
  flex: 1;
  padding: 12px 0;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
}
.tab.active {
  color: var(--primary);
  font-weight: 600;
}
.tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
}

/* ========== Model Grid ========== */
.model-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px;
}
.model-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
.model-card:active {
  transform: scale(0.97);
}
.model-thumb {
  width: 100%;
  aspect-ratio: 1;
  background: #F0F2F5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  overflow: hidden;
}
.model-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.model-info {
  padding: 10px 12px;
}
.model-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.model-price {
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
}
.model-price.free {
  color: var(--success);
}

/* ========== Model List (Admin) ========== */
.model-list {
  padding: 12px 16px;
}
.model-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.model-row-thumb {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  background: #F0F2F5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
  overflow: hidden;
}
.model-row-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.model-row-info {
  flex: 1;
  min-width: 0;
}
.model-row-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}
.model-row-meta {
  font-size: 12px;
  color: var(--text-secondary);
}
.model-row-actions {
  display: flex;
  gap: 8px;
}
.btn-sm {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  border: none;
  cursor: pointer;
  font-weight: 500;
}
.btn-edit {
  background: #E8F4FD;
  color: #2980B9;
}
.btn-delete {
  background: #FDECEC;
  color: var(--danger);
}
.btn-status {
  background: #F0FFF4;
  color: var(--success);
}

/* ========== Bottom Navigation ========== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  display: flex;
  border-top: 1px solid var(--border);
  padding: 6px 0 env(safe-area-inset-bottom, 8px);
  z-index: 100;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 0;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 10px;
  text-decoration: none;
}
.nav-item.active {
  color: var(--primary);
}
.nav-icon {
  font-size: 22px;
  line-height: 1;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s;
  width: 100%;
}
.btn:active { opacity: 0.85; }
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}
.btn-ghost {
  background: #F0F2F5;
  color: var(--text);
}
.btn-danger {
  background: var(--danger);
  color: white;
}

/* ========== Forms ========== */
.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-size: 16px;
  color: var(--text);
  outline: none;
  background: white;
}
.form-input:focus {
  border-color: var(--primary);
}
.form-select {
  width: 100%;
  height: 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-size: 16px;
  color: var(--text);
  background: white;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237F8C8D' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

/* ========== User Card (Profile) ========== */
.user-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
.avatar {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  flex-shrink: 0;
}
.avatar img {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  object-fit: cover;
}
.user-name {
  font-size: 18px;
  font-weight: 700;
}
.user-id {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ========== Stats Grid ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
}
.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ========== Menu List ========== */
.menu-list {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.menu-item:last-child { border-bottom: none; }
.menu-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
}
.menu-icon {
  font-size: 20px;
}
.menu-arrow {
  color: var(--text-light);
  font-size: 16px;
}

/* ========== Collection Grid ========== */
.collection-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 16px;
}
.collection-item {
  aspect-ratio: 1;
  background: var(--card);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: var(--shadow);
  font-size: 36px;
  position: relative;
}
.collection-item .collected-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  background: var(--primary);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
}
.collection-item .collected-name {
  font-size: 11px;
  color: var(--text-secondary);
}
.collection-item.locked {
  opacity: 0.5;
}

/* ========== Detail Page ========== */
.detail-hero {
  width: 100%;
  aspect-ratio: 1;
  background: linear-gradient(135deg, #667eea, #764ba2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 100px;
  position: relative;
  overflow: hidden;
}
.detail-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.detail-body {
  padding: 20px;
  padding-bottom: 100px;
}
.detail-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}
.detail-category {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.detail-desc {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.detail-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}
.detail-action-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px;
  background: white;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow);
  font-size: 12px;
  color: var(--text-secondary);
}
.detail-action-btn .icon { font-size: 22px; }
.detail-action-btn.active { color: var(--primary); }

.detail-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  padding: 12px 16px env(safe-area-inset-bottom, 12px);
  display: flex;
  gap: 12px;
  border-top: 1px solid var(--border);
}
.detail-price {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.detail-price-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
}
.detail-price-label {
  font-size: 11px;
  color: var(--text-secondary);
}

/* ========== Modal ========== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-content {
  background: white;
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-height: 80vh;
  padding: 24px 16px env(safe-area-inset-bottom, 24px);
  overflow-y: auto;
}
.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  text-align: center;
}

/* ========== Toast ========== */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.75);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 999;
  pointer-events: none;
  animation: fadeInOut 2s forwards;
}
@keyframes fadeInOut {
  0% { opacity: 0; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

/* ========== Loading Spinner ========== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-light);
  font-size: 14px;
}
.loading::before {
  content: '';
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========== Empty State ========== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-light);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-text { font-size: 14px; }

/* ========== Page Container ========== */
.page {
  padding-bottom: 70px;
}
