/* ============================
   Relay Web Console — Common Styles
   ============================ */

:root {
  --bg: #0f1419;
  --surface: #1a1f2e;
  --surface2: #242b3d;
  --border: #2d3548;
  --text: #e2e8f0;
  --text2: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --radius: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

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

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

/* ===== App Layout ===== */
#app { display: flex; min-height: 100vh; }

/* ===== Sidebar ===== */
#sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 0 20px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.sidebar-header h2 { font-size: 16px; font-weight: 600; margin-bottom: 2px; }
.sidebar-user { font-size: 11px; color: var(--text2); }

#nav { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; flex: 1; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 6px;
  color: var(--text2); text-decoration: none;
  transition: all 0.15s; font-size: 14px;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-icon { font-size: 16px; }

/* ===== Main Content ===== */
#content { flex: 1; padding: 28px 32px; overflow-y: auto; }

.page-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.page-title { font-size: 20px; font-weight: 600; }

/* ===== Card / Table ===== */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 10px 12px; color: var(--text2); font-weight: 500; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: rgba(59,130,246,0.04); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 500;
}
.badge-enabled { background: rgba(34,197,94,0.15); color: #4ade80; }
.badge-disabled{ background: rgba(239,68,68,0.15); color: #f87171; }
.badge-warning { background: rgba(234,179,8,0.15); color: #facc15; }
.badge-info    { background: rgba(59,130,246,0.15); color: #60a5fa; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border: none; border-radius: 6px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all 0.15s; text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger  { background: var(--red); color: #fff; }
.btn-danger:hover  { background: #dc2626; }
.btn-ghost   { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon {
  background: transparent; border: none; color: var(--text2);
  cursor: pointer; padding: 4px 8px; border-radius: 4px; font-size: 13px;
}
.btn-icon:hover { background: var(--surface2); color: var(--text); }
.btn-icon.danger:hover { color: var(--red); }

/* ===== Form ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 4px; font-size: 12px; font-weight: 500; color: var(--text2); }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 8px 12px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 13px; outline: none;
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent); }
.form-group textarea { resize: vertical; min-height: 60px; font-family: inherit; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; backdrop-filter: blur(2px);
}
.modal-overlay.hidden { display: none; }
.modal-content {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 24px;
  width: 520px; max-width: 90vw; max-height: 85vh; overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }

/* ===== Toast ===== */
.toast {
  position: fixed; top: 20px; right: 20px;
  padding: 12px 20px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-size: 13px; z-index: 200;
  box-shadow: var(--shadow); animation: slideIn 0.2s ease;
}
.toast.hidden { display: none; }
.toast.error { border-color: var(--red); }

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

/* ===== Upload Zone ===== */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 40px 20px; text-align: center; cursor: pointer;
  transition: all 0.15s; background: var(--surface);
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--accent); background: rgba(59,130,246,0.05); }
.upload-zone .icon { font-size: 40px; margin-bottom: 8px; }
.upload-zone .hint { color: var(--text2); font-size: 12px; margin-top: 8px; }
.upload-zone input[type="file"] { display: none; }

/* ===== Tabs ===== */
.tab-bar { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tab-item {
  padding: 8px 16px; background: none; border: none;
  border-bottom: 2px solid transparent;
  color: var(--text2); font-size: 13px; cursor: pointer;
  transition: all 0.15s;
}
.tab-item:hover { color: var(--text); }
.tab-item.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ===== Detail Row ===== */
.detail-row { display: flex; padding: 8px 0; border-bottom: 1px solid var(--border); }
.detail-label { width: 120px; flex-shrink: 0; color: var(--text2); font-size: 13px; }
.detail-value { flex: 1; font-size: 13px; word-break: break-all; }

/* ===== Empty State ===== */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text2); }
.empty-state p { margin-bottom: 16px; }

/* ===== Utility ===== */
.code { font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; font-size: 12px; background: var(--surface2); padding: 2px 6px; border-radius: 3px; color: #e2e8f0; }
.text-secondary { color: var(--text2); }
.text-sm { font-size: 12px; }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-accent { color: var(--accent); }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  #sidebar { width: 56px; }
  #sidebar .nav-icon { font-size: 20px; }
  .sidebar-header h2 { display: none; }
  .sidebar-user { display: none; }
  .nav-item span:not(.nav-icon) { display: none; }
  #content { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
}

/* ===== Auth (Login / Register) ===== */
#auth-view { min-height: 100vh; }
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 380px; max-width: 100%;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 32px; box-shadow: var(--shadow);
}
.auth-title { font-size: 20px; font-weight: 600; text-align: center; }
.auth-sub { font-size: 12px; color: var(--text2); text-align: center; margin: 6px 0 24px; }
.btn-block { width: 100%; justify-content: center; padding: 10px; }
.auth-tip { margin-top: 16px; font-size: 12px; color: var(--text2); text-align: center; }
.auth-tip a { color: var(--accent); text-decoration: none; }
.captcha-row { display: flex; gap: 8px; align-items: center; }
.captcha-row input { flex: 1; }
.captcha-q {
  min-width: 90px; text-align: center; padding: 8px 10px;
  background: var(--surface2); border: 1px dashed var(--border);
  border-radius: 6px; color: var(--accent); font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
