/* ============================================================
   SEO Content Agent — Admin Design System
   ============================================================ */

:root {
  /* Brand */
  --accent: #5b6dfa;
  --accent-hover: #4c5ce0;
  --accent-soft: rgba(91, 109, 250, .12);
  --accent-2: #8b5cf6;

  /* Semantic */
  --green: #1fb87a;
  --green-soft: rgba(31, 184, 122, .14);
  --red: #f0455b;
  --red-soft: rgba(240, 69, 91, .14);
  --yellow: #e6a723;
  --yellow-soft: rgba(230, 167, 35, .16);
  --blue: #3b82f6;
  --blue-soft: rgba(59, 130, 246, .14);

  /* Light theme surfaces */
  --bg: #f4f5fa;
  --bg-2: #eceefa;
  --panel: #ffffff;
  --panel-2: #f7f8fc;
  --border: #e3e6f0;
  --border-strong: #d3d7e6;
  --text: #1c2033;
  --text-dim: #6b7085;
  --text-muted: #9498ab;
  --shadow-color: 222deg 30% 60%;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --sidebar-w: 252px;
  --header-h: 60px;

  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;

  --shadow-sm: 0 1px 2px hsl(var(--shadow-color) / .06), 0 1px 1px hsl(var(--shadow-color) / .04);
  --shadow-md: 0 4px 14px hsl(var(--shadow-color) / .10), 0 1px 3px hsl(var(--shadow-color) / .06);
  --shadow-lg: 0 16px 40px hsl(var(--shadow-color) / .16), 0 4px 10px hsl(var(--shadow-color) / .08);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --ease: cubic-bezier(.4,0,.2,1);
}

/* Dark theme — auto (prefers-color-scheme) and manual (data-theme) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --dark-auto: 1; }
}
:root[data-theme="dark"],
:root:not([data-theme="light"]) {
  @media (prefers-color-scheme: dark) {
    --bg: #0e1120;
    --bg-2: #10152a;
    --panel: #161b2f;
    --panel-2: #1c2238;
    --border: #2a3150;
    --border-strong: #384064;
    --text: #edf0fb;
    --text-dim: #a2a8c4;
    --text-muted: #757c9c;
    --shadow-color: 230deg 60% 3%;
    --accent-soft: rgba(91, 109, 250, .2);
    --green-soft: rgba(31, 184, 122, .18);
    --red-soft: rgba(240, 69, 91, .18);
    --yellow-soft: rgba(230, 167, 35, .2);
  }
}
:root[data-theme="dark"] {
  --bg: #0e1120;
  --bg-2: #10152a;
  --panel: #161b2f;
  --panel-2: #1c2238;
  --border: #2a3150;
  --border-strong: #384064;
  --text: #edf0fb;
  --text-dim: #a2a8c4;
  --text-muted: #757c9c;
  --shadow-color: 230deg 60% 3%;
  --accent-soft: rgba(91, 109, 250, .2);
  --green-soft: rgba(31, 184, 122, .18);
  --red-soft: rgba(240, 69, 91, .18);
  --yellow-soft: rgba(230, 167, 35, .2);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-weight: 700; letter-spacing: -.01em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
::selection { background: var(--accent-soft); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid var(--bg); }

/* ---------- Shell / Sidebar ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); background: var(--panel); border-right: 1px solid var(--border);
  padding: 14px 12px 16px; position: fixed; top: 0; left: 0; bottom: 0; overflow-y: auto; z-index: 30;
  display: flex; flex-direction: column; transition: transform .22s var(--ease);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 15px;
  padding: 8px 8px 18px; letter-spacing: -.01em;
}
.sidebar-brand .brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 15px; font-weight: 800;
  box-shadow: var(--shadow-sm);
}
.sidebar-scroll { flex: 1; }
.nav-group-title {
  font-size: 10.5px; text-transform: uppercase; color: var(--text-muted); font-weight: 700;
  padding: 16px 10px 6px; letter-spacing: .08em;
}
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 13.5px; font-weight: 500; margin-bottom: 2px; position: relative;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.nav-link svg { flex: none; opacity: .85; }
.nav-link:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.nav-link.active svg { opacity: 1; }
.sidebar-footer { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 10px; }
.nav-user { display: flex; align-items: center; gap: 10px; padding: 6px 10px 4px; }
.nav-user-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12.5px; flex: none;
}
.nav-user-meta { min-width: 0; }
.nav-user-email { font-size: 12.5px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-user-role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }

.sidebar-backdrop { display: none; }

/* ---------- Main / Header ---------- */
.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; }
.header {
  height: var(--header-h); border-bottom: 1px solid var(--border); display: flex; align-items: center;
  justify-content: space-between; padding: 0 24px; position: sticky; top: 0;
  background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: blur(8px); z-index: 20;
}
.header-left { display: flex; align-items: center; gap: 14px; }
.header-right { display: flex; align-items: center; gap: 10px; }
.menu-toggle {
  display: none; background: none; border: 1px solid var(--border); color: var(--text); font-size: 16px;
  width: 34px; height: 34px; border-radius: var(--radius-sm); align-items: center; justify-content: center;
}

.icon-btn {
  width: 34px; height: 34px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text-dim); display: inline-flex; align-items: center; justify-content: center;
  transition: all .12s var(--ease);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }

.status-pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px 5px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; border: 1px solid var(--border); background: var(--panel-2); letter-spacing: .02em;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.status-RUNNING .status-dot { background: var(--green); box-shadow: 0 0 0 0 var(--green-soft); animation: pulse-dot 1.8s infinite; }
.status-RUNNING { color: var(--green); background: var(--green-soft); border-color: transparent; }
.status-PAUSED .status-dot { background: var(--yellow); } .status-PAUSED { color: var(--yellow); background: var(--yellow-soft); border-color: transparent; }
.status-STOPPED .status-dot { background: var(--text-muted); } .status-STOPPED { color: var(--text-dim); }
.status-ERROR .status-dot { background: var(--red); } .status-ERROR { color: var(--red); background: var(--red-soft); border-color: transparent; }
@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(31,184,122,.45); }
  70% { box-shadow: 0 0 0 6px rgba(31,184,122,0); }
  100% { box-shadow: 0 0 0 0 rgba(31,184,122,0); }
}

/* ---------- Content ---------- */
.content { padding: 24px 28px 60px; max-width: 1440px; }
.page-title { font-size: 21px; font-weight: 800; margin: 0 0 4px; letter-spacing: -.02em; }
.page-sub { color: var(--text-dim); margin: 0 0 22px; font-size: 13.5px; }

/* ---------- Cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 22px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px 18px; box-shadow: var(--shadow-sm); transition: box-shadow .15s var(--ease), transform .15s var(--ease);
  position: relative; overflow: hidden;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.card-label { color: var(--text-dim); font-size: 12px; font-weight: 600; margin-bottom: 8px; text-transform: uppercase; letter-spacing: .03em; }
.card-value { font-size: 25px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.card-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 6px; }

/* ---------- Panels ---------- */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; margin-bottom: 18px; box-shadow: var(--shadow-sm); }
.panel-title { font-weight: 700; margin: 0 0 14px; font-size: 14.5px; display: flex; align-items: center; justify-content: space-between; letter-spacing: -.01em; }

/* ---------- Toolbar / Forms ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }

input, select, textarea {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm);
  padding: 9px 11px; font-size: 13.5px; font-family: inherit; transition: border-color .12s var(--ease), box-shadow .12s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled, select:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; }
textarea { resize: vertical; line-height: 1.5; }
label { font-size: 12.5px; color: var(--text-dim); font-weight: 600; display: block; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin: 0 0 18px; }
fieldset legend { font-weight: 700; font-size: 13px; padding: 0 6px; color: var(--text); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--radius-sm); padding: 8px 15px; font-size: 13.5px; font-weight: 600;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  transition: background .12s var(--ease), border-color .12s var(--ease), color .12s var(--ease), transform .08s var(--ease), box-shadow .12s var(--ease);
}
.btn:hover { border-color: var(--border-strong); background: var(--bg-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-danger.btn:not([class*="btn-danger"]):hover {} /* noop guard */
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--panel-2); }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn.is-loading { color: transparent !important; position: relative; pointer-events: none; }
.btn.is-loading::after {
  content: ''; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent; color: #fff; animation: spin .6s linear infinite;
}
.btn:not(.btn-primary):not(.btn-danger).is-loading::after { color: var(--text); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: -2px; padding: 2px; }
table { width: 100%; border-collapse: collapse; font-size: 13.2px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-muted); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; background: var(--panel-2); }
th:first-child { border-top-left-radius: var(--radius-sm); }
th:last-child { border-top-right-radius: var(--radius-sm); }
tbody tr { transition: background .1s var(--ease); }
tbody tr:hover { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: none; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .01em; text-transform: capitalize; border: 1px solid transparent;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-green { color: var(--green); background: var(--green-soft); }
.badge-red { color: var(--red); background: var(--red-soft); }
.badge-yellow { color: var(--yellow); background: var(--yellow-soft); }
.badge-gray { color: var(--text-dim); background: var(--panel-2); border-color: var(--border); }

/* ---------- Toggle switch ---------- */
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle .slider { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: .15s var(--ease); cursor: pointer; }
.toggle .slider:before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s var(--ease); box-shadow: var(--shadow-sm); }
.toggle input:checked + .slider { background: var(--accent); }
.toggle input:checked + .slider:before { transform: translateX(18px); }
.toggle input:focus-visible + .slider { box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tab { padding: 9px 16px; border-radius: var(--radius-sm) var(--radius-sm) 0 0; color: var(--text-dim); font-size: 13px; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .12s var(--ease); }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: color-mix(in srgb, #000 55%, transparent); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
  animation: fade-in .15s var(--ease);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg);
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; padding: 22px;
  box-shadow: var(--shadow-lg); animation: modal-in .18s var(--ease);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-title { font-weight: 800; margin: 0 0 16px; font-size: 16.5px; letter-spacing: -.01em; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.modal[style*="420px"] .modal-actions,
.modal-actions:only-child { border-top: none; padding-top: 0; }

/* ---------- Toasts ---------- */
.toast-stack { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: 340px; }
.toast {
  background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--text-muted);
  border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13px; font-weight: 500; min-width: 240px;
  box-shadow: var(--shadow-lg); animation: toast-in .2s var(--ease); color: var(--text);
}
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.info { border-left-color: var(--blue); }
.toast.warning { border-left-color: var(--yellow); }

/* ---------- Empty / loading / error states ---------- */
.empty-state, .loading-state, .error-state {
  padding: 48px 20px; text-align: center; color: var(--text-dim); font-size: 13.5px;
}
.error-state { color: var(--red); }
.loading-state { position: relative; }
.loading-state::before {
  content: ''; display: block; width: 22px; height: 22px; margin: 0 auto 12px; border-radius: 50%;
  border: 2.5px solid var(--border); border-top-color: var(--accent); animation: spin .7s linear infinite;
}

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 8px; align-items: center; margin-top: 14px; justify-content: flex-end; font-size: 12.5px; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background:
    radial-gradient(circle at 15% 15%, var(--accent-soft), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(139,92,246,.12), transparent 45%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 388px; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 34px 32px; box-shadow: var(--shadow-lg);
}
.login-brand {
  width: 46px; height: 46px; border-radius: 13px; margin: 0 auto 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 20px;
  box-shadow: var(--shadow-md);
}
.login-card h1 { font-size: 19px; margin: 0 0 4px; text-align: center; letter-spacing: -.01em; }
.login-card p { color: var(--text-dim); font-size: 13px; margin: 0 0 24px; text-align: center; }

/* ---------- Utilities ---------- */
.full-w { width: 100%; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mb-0 { margin-bottom: 0; }
.flex { display: flex; } .flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.dim { color: var(--text-dim); }
.mono { font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; font-size: 12.5px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .sidebar.open ~ .sidebar-backdrop,
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 25; }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .content { padding: 18px 16px 40px; }
  .header { padding: 0 16px; }
}
@media (max-width: 560px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .card-value { font-size: 20px; }
  .login-card { padding: 26px 20px; }
}
