/* ── Reset & Base ── */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg-primary: #0a0a12;
  --bg-secondary: #12121f;
  --bg-tertiary: #1a1a2e;
  --border: #2a2a40;
  --text: #e0e0e8;
  --text-muted: #888;
  --primary: #6500fc;
  --primary-bright: #8b3dff;
  --success: #2ecc71;
  --warning: #f39c12;
  --danger: #e74c3c;
  --info: #3498db;
  --sidebar-width: 240px;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text);
  line-height: 1.6;
}

a { color: var(--primary-bright); text-decoration: none; }
a:hover { color: #a66dff; }

/* ── Login Page ── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at center, #1a1a3e 0%, var(--bg-primary) 70%);
}
.login-container {
  text-align: center;
  padding: 50px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
}
.login-container img { margin-bottom: 20px; border-radius: 12px; }
.login-container h1 { font-size: 1.8em; margin-bottom: 8px; }
.login-container p { color: var(--text-muted); margin-bottom: 30px; }
.steam-login-btn {
  display: inline-flex; align-items: center; gap: 10px;
  background: #1b2838; color: white; padding: 14px 30px;
  border-radius: 10px; font-size: 1.1em; font-weight: 600;
  transition: all 0.2s;
}
.steam-login-btn:hover { background: #2a475e; color: white; transform: translateY(-2px); }

/* ── Layout ── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 15px 0;
  overflow-y: auto;
  z-index: 100;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px 20px;
  font-weight: 700; font-size: 1.1em;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.sidebar-brand img { border-radius: 8px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; color: var(--text-muted);
  transition: all 0.15s; font-size: 0.95em;
}
.nav-link:hover { color: var(--text); background: var(--bg-tertiary); }
.nav-link i { width: 20px; text-align: center; }
.sidebar-spacer { flex: 1; }
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; border-top: 1px solid var(--border);
  margin-top: 10px; font-size: 0.9em;
}

.content {
  margin-left: var(--sidebar-width);
  padding: 30px;
  min-height: 100vh;
}

/* ── Page Header ── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 25px;
}
.page-header h1 { font-size: 1.5em; display: flex; align-items: center; gap: 10px; }

/* ── Cards ── */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 20px;
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-tertiary);
}
.card-header h2 { font-size: 1.1em; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 20px; }

/* ── Stats ── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 15px; margin-bottom: 20px; }
.stat-card {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 10px; padding: 20px; text-align: center;
}
.stat-value { font-size: 2em; font-weight: 700; color: var(--primary-bright); }
.stat-label { color: var(--text-muted); font-size: 0.85em; margin-top: 4px; }

/* ── Tables ── */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 10px 15px; color: var(--text-muted); font-size: 0.85em; text-transform: uppercase; border-bottom: 1px solid var(--border); }
.table td { padding: 10px 15px; border-bottom: 1px solid rgba(255,255,255,0.04); vertical-align: middle; }
.table tbody tr:hover { background: rgba(101, 0, 252, 0.05); }
.row-disabled { opacity: 0.5; }

/* ── Badges ── */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 6px;
  font-size: 0.8em; font-weight: 600;
}
.badge-replace { background: rgba(52,152,219,0.2); color: var(--info); }
.badge-find_replace { background: rgba(243,156,18,0.2); color: var(--warning); }
.badge-append { background: rgba(46,204,113,0.2); color: var(--success); }
.badge-prepend { background: rgba(155,89,182,0.2); color: #9b59b6; }
.badge-success { background: rgba(46,204,113,0.2); color: var(--success); }
.badge-error { background: rgba(231,76,60,0.2); color: var(--danger); }
.badge-skipped { background: rgba(136,136,136,0.2); color: var(--text-muted); }

/* ── Status Dot ── */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-active { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-disabled { background: var(--text-muted); }
.status-warning { background: var(--warning); box-shadow: 0 0 6px var(--warning); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; border: none;
  font-size: 0.9em; font-weight: 600; cursor: pointer;
  transition: all 0.15s; text-decoration: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-bright); color: white; }
.btn-secondary { background: var(--bg-tertiary); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--primary); }
.btn-warning { background: rgba(243,156,18,0.2); color: var(--warning); }
.btn-danger { background: rgba(231,76,60,0.2); color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 0.8em; }

/* ── Forms ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 0.9em; color: var(--text-muted); }
.form-group input[type="text"],
.form-group input[type="datetime-local"],
.form-group select,
.form-group textarea {
  width: 100%; padding: 10px 14px; background: var(--bg-tertiary);
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 0.95em; font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.code-textarea { font-family: 'Consolas', 'Monaco', monospace; font-size: 0.9em; line-height: 1.5; }
.form-group small { display: block; margin-top: 4px; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.text-muted { color: var(--text-muted); }
code { background: var(--bg-tertiary); padding: 2px 6px; border-radius: 4px; font-size: 0.9em; }

.server-select { max-height: 200px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; }
.checkbox-label input { accent-color: var(--primary); }

/* ── Empty State ── */
.empty-state { text-align: center; padding: 40px; color: var(--text-muted); }
.empty-state i { font-size: 2.5em; margin-bottom: 10px; display: block; }
.empty-state .btn { margin-top: 15px; }

/* ── Alerts ── */
.alert { padding: 12px 18px; border-radius: 8px; margin-bottom: 20px; display: flex; align-items: center; gap: 10px; }
.alert-error { background: rgba(231,76,60,0.15); border: 1px solid rgba(231,76,60,0.3); color: var(--danger); }

/* ── Breadcrumbs ── */
.breadcrumb-bar {
  background: var(--bg-tertiary); padding: 8px 15px; border-radius: 8px;
  margin-bottom: 20px; font-size: 0.9em;
}
.breadcrumb-bar a { color: var(--primary-bright); }
.breadcrumb-bar span { color: var(--text-muted); margin: 0 4px; }

/* ── Modal ── */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; padding: 20px;
}
.modal-content {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 12px; max-width: 700px; width: 100%; max-height: 85vh;
  display: flex; flex-direction: column;
}
.modal-large { max-width: 900px; }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 15px 20px; border-bottom: 1px solid var(--border);
}
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.5em; cursor: pointer; }
.modal-close:hover { color: var(--text); }
.file-preview {
  padding: 20px; overflow: auto; flex: 1;
  font-family: 'Consolas', 'Monaco', monospace; font-size: 0.85em;
  line-height: 1.5; white-space: pre-wrap; color: #ccc;
  max-height: 500px;
}

/* ── Diff / Before-After View ── */
.diff-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-top: 1px solid var(--border);
}
.diff-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.diff-pane:first-child {
  border-right: 1px solid var(--border);
}
.diff-pane-header {
  padding: 10px 15px;
  font-weight: 600;
  font-size: 0.85em;
  color: var(--danger);
  background: rgba(231, 76, 60, 0.08);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.diff-pane-header-after {
  color: var(--success);
  background: rgba(46, 204, 113, 0.08);
}
.diff-content {
  padding: 15px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.82em;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  color: #ccc;
  overflow: auto;
  max-height: 500px;
  margin: 0;
  flex: 1;
}
@media (max-width: 900px) {
  .diff-container { grid-template-columns: 1fr; }
  .diff-pane:first-child { border-right: none; border-bottom: 1px solid var(--border); }
}

/* ── Action Cards ── */
.action-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
  border-left: 3px solid var(--text-muted);
}
.action-command { border-left-color: var(--info); }
.action-power { border-left-color: var(--danger); }
.action-file_edit { border-left-color: var(--success); }
.action-delay { border-left-color: var(--warning); }

.action-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 15px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.9em;
}
.action-card-header .btn { margin-left: auto; }
.action-card-handle { color: var(--text-muted); cursor: grab; }
.action-card-handle:active { cursor: grabbing; }
.action-card.drag-over { border-color: var(--primary-bright); background: rgba(101, 0, 252, 0.08); }
.action-card-body { padding: 15px; }

/* ── Cron Presets ── */
.cron-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.cron-presets .btn { font-size: 0.75em; padding: 3px 8px; }

/* ── Week Picker ── */
.week-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.week-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.week-row:has(.week-check:checked) {
  border-color: var(--primary);
  background: rgba(101, 0, 252, 0.08);
}
.week-checkbox {
  margin: 0;
  padding: 0;
}
.week-day, .week-time {
  padding: 6px 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9em;
}
.week-day { min-width: 130px; }
.week-time { min-width: 100px; }
.form-label { display: block; font-weight: 600; font-size: 0.9em; color: var(--text-muted); }

/* ── Command Rows (wipe pre-commands) ── */
.cmd-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.cmd-row input, .cmd-row select {
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9em;
}

/* ── Map List ── */
.map-list { display: flex; flex-direction: column; gap: 6px; }
.map-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.map-url {
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.85em;
  color: var(--info);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  margin-right: 10px;
}

/* ── Action type badges ── */
.badge-command { background: rgba(52,152,219,0.2); color: var(--info); }
.badge-power { background: rgba(231,76,60,0.2); color: var(--danger); }
.badge-file_edit { background: rgba(46,204,113,0.2); color: var(--success); }
.badge-delay { background: rgba(243,156,18,0.2); color: var(--warning); }
.badge-delete_files { background: rgba(231,76,60,0.2); color: var(--danger); }
.badge-set_startup_var { background: rgba(155,89,182,0.2); color: #9b59b6; }
.badge-random_map { background: rgba(26,188,156,0.2); color: #1abc9c; }
.action-delete_files { border-left-color: var(--danger); }
.action-set_startup_var { border-left-color: #9b59b6; }
.action-random_map { border-left-color: #1abc9c; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .sidebar { width: 60px; }
  .sidebar-brand span, .nav-link span, .sidebar-user span { display: none; }
  .content { margin-left: 60px; }
  .form-grid { grid-template-columns: 1fr; }
}
