/* ============================
   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;
}

/* ===== Login Page ===== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 380px;
  max-width: 100%;
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: 20px;
  margin-bottom: 4px;
  text-align: center;
}

.login-card .subtitle {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 28px;
  text-align: center;
}

.login-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  color: #f87171;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.login-error.show { display: block; }

.login-btn {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.login-btn:hover { background: var(--accent-hover); }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.login-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 12px;
  color: var(--text2);
}

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

#app.hidden { display: none; }

/* ===== Sidebar ===== */
#sidebar {
  width: 240px;
  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; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.logout-btn {
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text2);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.logout-btn:hover { background: var(--surface2); color: var(--red); border-color: rgba(239,68,68,0.3); }

/* ===== 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;
}

/* ===== Table ===== */
.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-forward { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-static  { background: rgba(34,197,94,0.15); color: #4ade80; }
.badge-redirect{ background: rgba(234,179,8,0.15); color: #facc15; }
.badge-enabled { background: rgba(34,197,94,0.15); color: #4ade80; }
.badge-disabled{ background: rgba(239,68,68,0.15); color: #f87171; }

/* ===== Status Tags (forward-records) ===== */
.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.tag-success { background: rgba(34,197,94,0.15); color: #4ade80; }
.tag-error   { background: rgba(239,68,68,0.15); color: #f87171; }

/* ===== 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); }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text2);
}

.empty-state p { margin-bottom: 16px; }

/* ===== 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.success { border-color: var(--green); }
.toast.error   { border-color: var(--red); }
.toast.hidden  { display: none; }

@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; }

/* ===== 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;
}

/* ===== 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; }
  .sidebar-footer { display: none; }
  #content { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
}

.code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  background: var(--surface2);
  padding: 2px 6px;
  border-radius: 3px;
  color: #e2e8f0;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text2);
}

/* ===== SMS Log Table ===== */
.sms-log-table th {
  background: var(--surface2);
  position: sticky;
  top: 0;
}