/* LinkForge — refined ops dashboard */
/* Fonts loaded via base.html <link> tag */

:root {
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

  --bg: #f6f5f1;
  --bg-card: #ffffff;
  --bg-elevated: #fafaf8;
  --bg-hover: #f0efeb;
  --bg-input: #f6f5f1;

  --text-primary: #1a1a1a;
  --text-secondary: #6b6b6b;
  --text-tertiary: #9a9a9a;
  --text-inverse: #f0f0f0;

  --border: #e8e6e1;
  --border-light: #f0efeb;

  --accent: #3730a3;
  --accent-light: #e0e7ff;
  --accent-hover: #4338ca;

  --success: #0d7c42;
  --success-bg: #ecfdf3;
  --success-border: #86efac;

  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --danger-border: #fca5a5;

  --warning: #92400e;
  --warning-bg: #fffbeb;
  --warning-border: #fcd34d;

  --nav-bg: #161618;
  --nav-text: #a1a1a6;
  --nav-text-hover: #ffffff;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.08);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  color-scheme: light;
}

/* === Reset & Base === */

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === Top Bar === */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 28px;
  height: 56px;
  background: var(--nav-bg);
  color: var(--text-inverse);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.topbar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #818cf8, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.topbar nav {
  display: flex;
  gap: 4px;
}

.topbar nav a {
  color: var(--nav-text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  letter-spacing: -0.01em;
}

.topbar nav a:hover {
  color: var(--nav-text-hover);
  background: rgba(255,255,255,0.08);
}

/* === Layout === */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 28px;
}

/* === Cards === */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card h2 {
  margin: 0 0 16px 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

/* === Buttons === */

button {
  border: none;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  letter-spacing: -0.01em;
  background: var(--accent);
  color: #fff;
}

button:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

button:active {
  transform: translateY(0);
}

.btn-success {
  background: var(--success);
}

.btn-success:hover {
  background: #059651;
}

.btn-danger {
  background: var(--danger);
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-primary {
  background: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-small {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 4px;
}

/* === Actions Bar === */

.actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
  align-items: center;
}

/* === Form Elements === */

textarea,
input[type="text"],
input[type="number"],
input[type="password"],
input[type="file"] {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-primary);
  margin-top: 4px;
  margin-bottom: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
}

textarea:focus,
input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  background: #fff;
}

input[type="checkbox"] {
  width: auto;
  accent-color: var(--accent);
  margin: 0;
}

select {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.inline-select {
  min-width: 100px;
  padding: 4px 8px;
  font-size: 12px;
}

label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

/* === Tables === */

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  margin-top: 8px;
}

th {
  background: var(--bg-elevated);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  padding: 10px 12px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 56px;
  z-index: 10;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  vertical-align: top;
}

tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background 0.1s ease;
}

tbody tr:hover {
  background: var(--bg-hover);
}

/* === Status Row Colors === */

.row-whitelist {
  background: var(--success-bg);
}

.row-whitelist td:first-child {
  border-left: 3px solid var(--success);
}

.row-whitelist:hover {
  background: #d9fbe8;
}

.row-blacklist {
  background: var(--danger-bg);
}

.row-blacklist td:first-child {
  border-left: 3px solid var(--danger);
}

.row-blacklist:hover {
  background: #fee2e2;
}

.row-neutral {
  background: var(--warning-bg);
}

.row-neutral td:first-child {
  border-left: 3px solid var(--warning);
}

.row-neutral:hover {
  background: #fef3c7;
}

/* === Stats Grid (dashboard) === */

#stats-box {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

#stats-box p {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.3;
  position: relative;
}

/* === Upload Summary === */

#upload-summary {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 12px;
  border: 1px solid var(--border-light);
}

#upload-summary p {
  margin: 4px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

/* === Import Summary Line === */

#import-summary {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 10px 0;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* === Task Message === */

#task-message {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  margin-top: 12px;
}

/* === Config Form Layout === */

#config-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 20px;
  align-items: start;
}

#config-form label:nth-last-child(2) {
  grid-column: 1 / -1;
}

#config-form button[type="submit"] {
  grid-column: 1 / -1;
  justify-self: start;
  margin-top: 8px;
}

#config-message {
  grid-column: 1 / -1;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--success);
}

/* === Monospace Data === */

td:nth-child(3),
td:nth-child(4) {
  font-family: var(--font-mono);
  font-size: 12px;
}

/* === Scrollbar === */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* === Responsive === */

@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    height: auto;
    padding: 12px 16px;
    gap: 8px;
  }

  .topbar nav {
    flex-wrap: wrap;
    justify-content: center;
  }

  .container {
    padding: 16px;
  }

  .card {
    padding: 16px;
  }

  #config-form {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  table {
    font-size: 12px;
  }

  th, td {
    padding: 6px 8px;
  }
}

/* === Placeholder text === */

::placeholder {
  color: var(--text-tertiary);
  font-style: italic;
}

/* === Pagination === */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s ease;
}

.pagination a {
  color: var(--text-secondary);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.pagination a:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-light);
}

.pagination .current {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
}

.pagination .disabled {
  color: var(--text-tertiary);
  border: 1px solid var(--border-light);
  cursor: default;
  pointer-events: none;
}

.pagination .info {
  color: var(--text-tertiary);
  font-size: 12px;
  margin: 0 8px;
  border: none;
}

/* === Empty state === */

tbody:empty::after {
  content: '暂无数据';
  display: block;
  padding: 32px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
}
