@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Outfit:wght@500;600;700&display=swap');

:root {
  --bg: #0b0f1a;
  --surface: #141925;
  --surface-2: #1a2030;
  --border: rgba(255,255,255,0.06);
  --border-hover: rgba(255,255,255,0.12);
  --text: #e8e8ed;
  --text-muted: #7a7f8e;
  --text-dim: #4a4f5e;
  --accent: #8A5AAB;
  --accent-hover: #9d6bbe;
  --amber: #e6a040;
  --amber-hover: #d4902e;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #34d399;
  --warning: #f59e0b;
  --radius: 10px;
  --radius-sm: 6px;
}

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

body {
  font-family: 'DM Sans', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Page fade-in */
body { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.container {
  max-width: 620px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

/* ---- Navigation ---- */
.nav {
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
  position: relative;
}

.nav-link {
  padding: 14px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
  letter-spacing: 0.01em;
}

.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--accent); border-bottom-color: var(--accent); }

.nav-user {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-user a {
  color: var(--amber);
  text-decoration: none;
  font-weight: 500;
}

.nav-user a:hover { text-decoration: underline; }

/* ---- Typography ---- */
h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 14px;
  letter-spacing: -0.01em;
}

h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 600;
}

.subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 24px;
  line-height: 1.5;
}

/* ---- Cards / Sections ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.section { margin-bottom: 28px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
  color: white;
  background: var(--accent);
  white-space: nowrap;
}

.btn:hover { background: var(--accent-hover); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

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

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

.btn-success { background: var(--success); color: #0b0f1a; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-ghost:hover { border-color: var(--border-hover); color: var(--text); background: rgba(255,255,255,0.03); }

.btn-sm { padding: 6px 12px; font-size: 11px; }

.btn-full { width: 100%; }

.btn-icon {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

/* ---- Inputs ---- */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="time"],
select {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

input:focus, select:focus { border-color: var(--accent); }

input::placeholder { color: var(--text-dim); }

/* ---- Search bar ---- */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.search-bar input { flex: 1; }

/* ---- List items ---- */
.list-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: border-color 0.15s;
  cursor: default;
}

.list-item.clickable { cursor: pointer; }
.list-item.clickable:hover { border-color: var(--border-hover); }

.list-item-info { flex: 1; min-width: 0; }

.list-item-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.list-item-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-left: 12px;
  flex-shrink: 0;
}

/* ---- Tags / Pills ---- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-muted);
  background: var(--bg);
}

.tag:hover { border-color: var(--accent); color: var(--text); }
.tag.active { border-color: var(--accent); background: rgba(138,90,171,0.12); color: var(--text); }

.tag-delete {
  font-size: 10px;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.tag-delete:hover { opacity: 1; color: var(--danger); }

/* ---- Status badges ---- */
.status {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.status-ready { color: var(--success); background: rgba(52,211,153,0.1); }
.status-warming { color: var(--warning); background: rgba(245,158,11,0.1); }
.status-resolving { color: var(--accent); background: rgba(138,90,171,0.1); }
.status-error { color: var(--danger); background: rgba(239,68,68,0.1); }

/* ---- Inline row ---- */
.row { display: flex; gap: 8px; align-items: center; }
.row-between { justify-content: space-between; }
.row-wrap { flex-wrap: wrap; }

/* ---- Config rows ---- */
.config-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.config-row:last-child { border-bottom: none; }
.config-key { color: var(--text-muted); }
.config-val { color: var(--text); font-weight: 600; }

/* ---- Code block ---- */
.code-block {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--accent);
  word-break: break-all;
  user-select: all;
  margin: 8px 0;
}

/* ---- Empty state ---- */
.empty {
  color: var(--text-dim);
  text-align: center;
  padding: 28px 16px;
  font-size: 13px;
  font-style: italic;
}

/* ---- Modal overlay ---- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 60px 16px;
  overflow-y: auto;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
  animation: modalSlide 0.25s ease;
}

@keyframes modalSlide { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

.modal h3 { margin-bottom: 8px; }
.modal p { color: var(--text-muted); font-size: 13px; margin-bottom: 16px; line-height: 1.5; }

/* ---- Toast notifications ---- */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: white;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 3.7s forwards;
  max-width: 340px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.toast-error { background: var(--danger); }
.toast-success { background: var(--success); color: #0b0f1a; }
.toast-info { background: var(--accent); }

@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

/* ---- Misc ---- */
.hidden { display: none !important; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text-muted); }

/* ---- Responsive ---- */
@media (max-width: 480px) {
  .container { padding: 12px 10px 32px; }
  .nav-link { padding: 12px 10px; font-size: 12px; }
  h1 { font-size: 22px; }
}

/* ---- Loading spinner for buttons ---- */
.btn.loading { pointer-events: none; opacity: 0.7; }
.btn.loading::after {
  content: '';
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 6px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Timer / countdown ---- */
.timer { font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.timer-green { color: var(--success); }
.timer-orange { color: var(--warning); }
