/* =============================================
   API Relay — Minimalist & Premium Design
   ============================================= */

:root {
  --bg: #f5f5f7;
  --bg-card: #ffffff;
  --text: #1d1d1f;
  --text-secondary: #86868b;
  --text-tertiary: #aeaeb2;
  --border: #d2d2d7;
  --border-light: #e8e8ed;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: rgba(37,99,235,0.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 980px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
  --transition: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: #2563eb; color: #fff; }

/* -------- Layout -------- */
.container { max-width: 1100px; margin: 0 auto; padding: 0 32px; }

/* -------- Navigation -------- */
.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 32px; border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  position: sticky; top: 0; z-index: 100;
}
.nav-brand {
  font-size: 18px; font-weight: 600; color: var(--text);
  text-decoration: none; letter-spacing: -0.02em;
  transition: opacity var(--transition);
}
.nav-brand:hover { opacity: 0.7; }
.nav-links { display: flex; gap: 28px; align-items: center; }
.nav-links a {
  color: var(--text-secondary); text-decoration: none; font-size: 14px;
  font-weight: 400; transition: color var(--transition);
  position: relative;
}
.nav-links a::after {
  content: ''; position: absolute; bottom: -3px; left: 50%; width: 0;
  height: 2px; background: var(--accent); border-radius: 1px;
  transition: all var(--transition); transform: translateX(-50%);
}
.nav-links a:hover::after { width: 100%; }
.nav-links a:hover { color: var(--text); }
.nav-links .btn {
  padding: 8px 20px; background: var(--accent); color: #fff;
  border-radius: var(--radius-pill); font-size: 14px; font-weight: 500;
  transition: all var(--transition);
}
.nav-links .btn::after { display: none; }
.nav-links .btn:hover { background: var(--accent-hover); transform: scale(1.02); }

/* -------- Hero -------- */
.hero {
  padding: 110px 0 80px; text-align: center;
  position: relative; overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; top: -40%; left: -20%; width: 140%; height: 140%;
  background: radial-gradient(ellipse at 50% 40%, rgba(0,0,0,0.02) 0%, transparent 70%);
  pointer-events: none;
}
.hero h1 {
  font-size: 56px; font-weight: 700; letter-spacing: -0.04em;
  line-height: 1.07; margin-bottom: 20px; position: relative;
}
.hero p {
  font-size: 20px; color: var(--text-secondary); max-width: 580px;
  margin: 0 auto 40px; line-height: 1.5; position: relative;
}
.hero .btn-primary {
  display: inline-block; padding: 16px 36px; background: var(--accent);
  color: #fff; border-radius: var(--radius-pill); text-decoration: none;
  font-size: 17px; font-weight: 500;
  transition: all var(--transition); position: relative;
}
.hero .btn-primary:hover {
  background: var(--accent-hover); transform: scale(1.03);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
.hero .btn-primary:active { transform: scale(0.98); }

/* -------- Sections -------- */
.section { padding: 80px 0; }
.section-title {
  font-size: 32px; font-weight: 700; letter-spacing: -0.03em;
  margin-bottom: 44px; text-align: center;
}

/* -------- Products Grid -------- */
.products-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.product-card {
  background: var(--bg-card); border-radius: var(--radius-lg);
  padding: 28px; border: 1px solid var(--border);
  transition: all var(--transition); cursor: default;
}
.product-card:hover {
  box-shadow: var(--shadow-lg); border-color: transparent;
  transform: translateY(-2px);
}
.product-card h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.product-card .provider {
  font-size: 12px; color: var(--text-secondary); margin-bottom: 12px;
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500;
}
.product-card .desc { font-size: 14px; color: #515154; line-height: 1.6; margin-bottom: 16px; }
.product-card .price { font-size: 14px; color: var(--text); font-weight: 500; }
.product-card .status {
  display: inline-block; padding: 4px 10px; border-radius: 6px;
  font-size: 12px; font-weight: 500; margin-top: 12px;
}
.status-on { background: #e8f5e9; color: #2e7d32; }
.status-off { background: #f5f5f5; color: var(--text-secondary); }

/* -------- Docs Sections -------- */
.docs-section {
  background: var(--bg-card); border-radius: var(--radius-md);
  padding: 28px; margin-bottom: 20px; border: 1px solid var(--border);
}
.docs-section h3 { font-size: 18px; font-weight: 600; margin-bottom: 16px; }
.code-block {
  background: #f5f5f7; border-radius: var(--radius-sm); padding: 16px 20px;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace; font-size: 13px;
  overflow-x: auto; line-height: 1.7; color: var(--text); margin: 12px 0;
  border: 1px solid var(--border-light);
}
.code-block .comment { color: var(--text-secondary); }
.code-block .string { color: #007a3d; }
.code-block .key { color: #c41a16; }

/* -------- Forms -------- */
.form-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.form-box {
  background: var(--bg-card); border-radius: var(--radius-xl);
  padding: 48px; width: 100%; max-width: 420px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}
.form-box h2 { font-size: 24px; font-weight: 700; letter-spacing: -0.03em; margin-bottom: 8px; }
.form-box .subtitle { font-size: 14px; color: var(--text-secondary); margin-bottom: 32px; }
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--text); margin-bottom: 8px;
}
.form-group input, .form-group select {
  width: 100%; padding: 12px 16px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 15px; background: var(--bg-card);
  color: var(--text); transition: all var(--transition); outline: none;
}
.form-group input:focus, .form-group select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(29,29,31,0.1);
}
.form-group input::placeholder { color: var(--text-tertiary); }
.btn-submit {
  width: 100%; padding: 14px; background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius-pill); font-size: 16px;
  font-weight: 500; cursor: pointer; margin-top: 8px;
  transition: all var(--transition);
}
.btn-submit:hover { background: var(--accent-hover); transform: scale(1.01); }
.btn-submit:active { transform: scale(0.98); }
.form-footer { text-align: center; margin-top: 24px; font-size: 14px; color: var(--text-secondary); }
.form-footer a { color: var(--text); text-decoration: none; font-weight: 500; }
.form-footer a:hover { text-decoration: underline; }
.error-msg { color: #c41a16; font-size: 13px; margin-top: 8px; display: none; }
.success-msg { color: #2e7d32; font-size: 13px; margin-top: 8px; display: none; }

/* -------- Dashboard Layout -------- */
.dashboard { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: var(--bg-card); border-right: 1px solid var(--border);
  padding: 28px 0; position: fixed; top: 0; left: 0; height: 100vh; z-index: 50;
}
.sidebar-brand {
  padding: 0 24px 24px; font-size: 16px; font-weight: 600;
  border-bottom: 1px solid var(--border); margin-bottom: 16px;
  letter-spacing: -0.02em;
}
.sidebar-nav {
  display: flex; flex-direction: column; gap: 2px; padding: 0 12px;
  height: calc(100vh - 100px); /* fill remaining height */
}
.sidebar-nav-bottom { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.sidebar-nav a {
  display: block; padding: 10px 16px; border-radius: var(--radius-sm);
  text-decoration: none; color: var(--text-secondary); font-size: 14px;
  transition: all var(--transition);
}
.sidebar-nav a:hover { background: var(--bg); color: var(--text); }
.sidebar-nav a.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.main-content {
  flex: 1; margin-left: 240px; padding: 40px 40px 64px;
  display: flex; flex-direction: column; align-items: center;
}
.main-content > div { width: 100%; max-width: 1100px; }
.page-title { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; margin-bottom: 28px; }

/* -------- Stats Cards -------- */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 32px;
}
.stat-card {
  background: var(--bg-card); border-radius: var(--radius-md);
  padding: 24px; border: 1px solid var(--border);
  transition: all var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card .label { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.stat-card .value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }

/* -------- Token Display (Dashboard Hero Card) -------- */
.token-display {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  color: #fff; border-radius: var(--radius-lg); padding: 36px;
  margin-bottom: 36px; position: relative; overflow: hidden;
}
.token-display::after {
  content: ''; position: absolute; top: -50%; right: -20%;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(255,255,255,0.04) 0%, transparent 70%);
  pointer-events: none;
}
.token-display h3 { font-size: 14px; font-weight: 400; color: #a1a1a6; margin-bottom: 8px; }
.token-display .amount { font-size: 52px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.token-display .unit { font-size: 18px; font-weight: 400; color: #a1a1a6; margin-left: 8px; }
.token-actions { display: flex; gap: 12px; margin-top: 28px; }
.token-actions .btn {
  padding: 10px 24px; border-radius: var(--radius-pill); font-size: 14px;
  font-weight: 500; cursor: pointer; border: none;
  transition: all var(--transition);
}
.token-actions .btn:active { transform: scale(0.96); }
.btn-dark { background: #fff; color: var(--text); }
.btn-dark:hover { background: #f0f0f0; }
.btn-outline { background: transparent; color: #fff; border: 1px solid #636366; }
.btn-outline:hover { background: rgba(255,255,255,0.1); border-color: #8e8e93; }

/* -------- Tables -------- */
.table-box {
  background: var(--bg-card); border-radius: var(--radius-md);
  border: 1px solid var(--border); overflow: hidden;
  transition: box-shadow var(--transition);
}
.table-box:hover { box-shadow: var(--shadow-sm); }
.table-box table { width: 100%; border-collapse: collapse; }
.table-box th {
  text-align: left; padding: 12px 20px; font-size: 12px; font-weight: 600;
  color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border); background: #fafafa;
}
.table-box td { padding: 14px 20px; font-size: 14px; border-bottom: 1px solid var(--border-light); }
.table-box tr:last-child td { border-bottom: none; }
.table-box tr:hover { background: #f8f8fa; }

/* -------- Modals -------- */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; z-index: 200;
  animation: fadeIn 0.2s ease;
}
.modal-overlay.show { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-card); border-radius: var(--radius-lg);
  padding: 32px; width: 100%; max-width: 460px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  animation: slideUp 0.25s cubic-bezier(0.16,1,0.3,1);
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.modal h3 { font-size: 20px; font-weight: 600; margin-bottom: 24px; }
.modal .btn-cancel {
  padding: 10px 24px; border-radius: var(--radius-pill); font-size: 14px;
  background: var(--bg); border: 1px solid var(--border); cursor: pointer;
  color: var(--text); transition: all var(--transition);
}
.modal .btn-cancel:hover { background: #eee; }
.modal .btn-confirm {
  padding: 10px 24px; border-radius: var(--radius-pill); font-size: 14px;
  background: var(--accent); border: none; cursor: pointer; color: #fff;
  transition: all var(--transition);
}
.modal .btn-confirm:hover { background: var(--accent-hover); }

/* -------- Admin -------- */
.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 6px; font-size: 12px; font-weight: 500; }
.badge-active { background: #e8f5e9; color: #2e7d32; }
.badge-inactive { background: #f5f5f7; color: var(--text-secondary); }
.badge-admin { background: #e3f2fd; color: #1565c0; }

/* -------- Footer -------- */
.site-footer {
  text-align: center; padding: 40px 0; color: var(--text-secondary);
  font-size: 13px; border-top: 1px solid var(--border);
  margin-top: 80px; background: #f1f1f3;
}

/* -------- Code-only selectors (for docs page) -------- */
.api-method {
  display: inline-block; padding: 2px 10px; border-radius: 4px;
  font-size: 12px; font-weight: 600; margin-right: 8px;
}
.api-method.get { background: #e3f2fd; color: #1565c0; }
.api-method.post { background: #e8f5e9; color: #2e7d32; }
.api-endpoint {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 13px; color: var(--text); padding: 2px 0;
}

/* -------- Responsive -------- */

/* Mobile menu button (hamburger) */
.mobile-menu-btn {
  display: none; position: fixed; top: 14px; left: 14px; z-index: 110;
  width: 36px; height: 36px; border: none; border-radius: var(--radius-sm);
  background: var(--bg-card); cursor: pointer; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  transition: all var(--transition);
}
.mobile-menu-btn:active { transform: scale(0.92); }
.mobile-menu-btn .icon {
  display: block; width: 18px; height: 2px; background: var(--text);
  position: relative; transition: all 0.3s;
  border-radius: 1px;
}
.mobile-menu-btn .icon::before,
.mobile-menu-btn .icon::after {
  content: ''; position: absolute; left: 0; width: 100%; height: 2px;
  background: var(--text); transition: all 0.3s; border-radius: 1px;
}
.mobile-menu-btn .icon::before { top: -6px; }
.mobile-menu-btn .icon::after { top: 6px; }
.mobile-menu-btn.open .icon { background: transparent; }
.mobile-menu-btn.open .icon::before { top: 0; transform: rotate(45deg); }
.mobile-menu-btn.open .icon::after { top: 0; transform: rotate(-45deg); }

/* Sidebar overlay */
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 45; opacity: 0; transition: opacity 0.3s;
}
.sidebar-overlay.show { display: block; opacity: 1; }

/* Docs sidebar: sticky on desktop */
@media (min-width: 769px) {
  .docs-toc-content { position: sticky; top: 80px; height: fit-content; }
}
.docs-toc-content a.active { color: var(--accent) !important; font-weight: 600; }

/* Docs sidebar on mobile: slide from left */
@keyframes slideDown {
  from { opacity: 0; max-height: 0; }
  to { opacity: 1; max-height: 500px; }
}

@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .mobile-menu-btn { display: flex; }
  .sidebar {
    display: block;
    transform: translateX(-100%); transition: transform 0.3s cubic-bezier(0.16,1,0.3,1);
    z-index: 55;
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 24px 20px 24px 60px; }
  .hero { padding: 70px 0 50px; }
  .hero h1 { font-size: 36px; }
  .hero p { font-size: 17px; }
  .section { padding: 50px 0; }
  .products-grid { grid-template-columns: 1fr; }
  .nav { padding: 12px 20px; }
  .container { padding: 0 20px; }
  .token-display .amount { font-size: 36px; }

  /* Docs responsive */
  .docs-layout { grid-template-columns: 1fr !important; }
  .docs-toc-content {
    position: fixed; top: 0; left: 0; width: 240px; height: 100vh;
    background: var(--bg-card); border-right: 1px solid var(--border);
    padding: 28px 20px; z-index: 55;
    transform: translateX(-100%); transition: transform 0.3s cubic-bezier(0.16,1,0.3,1);
    overflow-y: auto;
  }
  .docs-toc-content.open { transform: translateX(0); }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .token-actions { flex-direction: column; }
}
