/* ============================================
   PLUS.XZGGAI.COM — OpenAI Minimalist Style
   v2: Polish + new utility classes
   ============================================ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0d0d0d;
  --bg-card: #1a1a1a;
  --bg-input: #2a2a2a;
  --bg-hover: #333;
  --border: #333;
  --border-focus: #555;
  --text: #e8e8e8;
  --text-dim: #888;
  --text-muted: #555;
  --white: #fff;
  --green: #10a37f;
  --red: #ef4444;
  --yellow: #f59e0b;
  --radius: 12px;
}

html { -webkit-font-smoothing: antialiased; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== Layout ===== */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ===== Header ===== */
.app-header {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 40px;
}

.header-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--green);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-input);
  border-radius: 10px;
  padding: 4px;
  align-self: center;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.nav-tab:hover { color: var(--text); }

.nav-tab.active {
  background: var(--bg-hover);
  color: var(--white);
}

.nav-tab svg { width: 15px; height: 15px; }

/* ===== Main ===== */
.app-main {
  flex: 1;
}

.view-container {
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Section Header ===== */
.section-header {
  margin-bottom: 24px;
}

.section-header h1 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 6px;
}

.section-header p {
  color: var(--text-dim);
  font-size: 14px;
}

/* ===== Card ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}

/* ===== Form ===== */
.form-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.field-label-row .field-label {
  flex: 1;
}

.field-link {
  color: var(--green);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: opacity 0.2s;
  white-space: nowrap;
}
.field-link:hover { opacity: 0.8; text-decoration: underline; }

.field-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

.field-count {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 12px;
}

.field-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
  outline: none;
}

.field-input::placeholder { color: var(--text-muted); }
.field-input:focus { border-color: var(--border-focus); }

textarea.field-input {
  resize: vertical;
  min-height: 100px;
  font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
}

/* ===== Buttons ===== */
.btn-group {
  display: flex;
  gap: 10px;
  padding-top: 4px;
}

.btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-primary:hover { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--bg-hover); }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.shortcut-hint {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

/* ===== Result Panel ===== */
.result-panel {
  margin-top: 20px;
  animation: fadeIn 0.3s ease;
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.result-card.success { border-left: 3px solid var(--green); }
.result-card.error { border-left: 3px solid var(--red); }

.result-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  font-weight: 600;
  font-size: 15px;
}

.result-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.result-icon.success { background: rgba(16,163,127,0.15); color: var(--green); }
.result-icon.error { background: rgba(239,68,68,0.15); color: var(--red); }

.result-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 13px;
}

.result-item .label { color: var(--text-dim); }
.result-item .value { font-weight: 500; text-align: right; max-width: 65%; word-break: break-all; }

.result-error-msg {
  color: var(--red);
  font-size: 14px;
}

/* ===== Query Results ===== */
.query-results {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.query-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-dim);
}

.btn-copy {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.btn-copy:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border-focus);
}

.query-result-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: fadeIn 0.3s ease;
}

.query-result-code {
  font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
}

.query-result-email,
.query-result-time {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-unused { background: rgba(16,163,127,0.12); color: var(--green); }
.badge-used { background: rgba(245,158,11,0.12); color: var(--yellow); }
.badge-notfound { background: rgba(239,68,68,0.12); color: var(--red); }

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 36px; margin-bottom: 12px; opacity: 0.4; }
.empty-state h3 { font-size: 15px; color: var(--text-dim); margin-bottom: 4px; }
.empty-state p { font-size: 13px; }

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  animation: slideIn 0.25s ease;
  max-width: 320px;
  cursor: pointer;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }

.toast-icon { font-size: 14px; flex-shrink: 0; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}


/* ===== Ref Links ===== */
.ref-links {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.ref-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 10px;
}

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

.ref-item {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 0;
  text-decoration: none;
  color: var(--green);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  transition: opacity 0.2s;
  white-space: nowrap;
}

.ref-item:hover {
  opacity: 0.75;
  text-decoration: underline;
}


/* ===== Footer ===== */
.app-footer {
  text-align: center;
  padding: 32px 0;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 48px;
}






/* ===== Stock Inline Badge ===== */
.stock-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 12px;
  padding: 3px 10px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--red);
  vertical-align: middle;
  white-space: nowrap;
}
.stock-inline strong {
  font-weight: 700;
}


/* ===== Responsive ===== */
@media (max-width: 480px) {
  .app-shell { padding: 0 16px; }
  .card { padding: 20px; }
  .nav-tab svg { display: none; }
  .toast-container { left: 16px; right: 16px; }
  .toast { max-width: 100%; }
}
