/* ===================================================== *
 * Moliyachi Helper Dashboard — Glassmorphism             *
 * ===================================================== */

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

:root {
  --primary-300: #a5b4fc;
  --primary-400: #818cf8;
  --primary-500: #6366f1;
  --primary-600: #4f46e5;
  --primary-700: #4338ca;

  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.36);

  --text: #f8fafc;
  --text-dim: rgba(248, 250, 252, 0.7);
  --text-muted: rgba(248, 250, 252, 0.45);

  --success: #34d399;
  --success-glow: rgba(52, 211, 153, 0.35);
  --warning: #fbbf24;
  --danger: #f87171;
  --danger-glow: rgba(248, 113, 113, 0.3);
  --info: #60a5fa;

  --radius: 14px;
  --radius-lg: 20px;
  --radius-full: 999px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

html, body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  color: var(--text);
  background: #0a0e1f;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  position: relative;
}

/* ===== ANIMATED MESH BACKGROUND ===== */
.bg-mesh {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(at 20% 0%, rgba(99, 102, 241, 0.18) 0%, transparent 50%),
    radial-gradient(at 80% 100%, rgba(139, 92, 246, 0.15) 0%, transparent 50%),
    radial-gradient(at 50% 50%, rgba(67, 56, 202, 0.1) 0%, transparent 70%),
    linear-gradient(180deg, #0a0e1f 0%, #0f172a 100%);
}

.bg-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.35;
  pointer-events: none;
}
.bg-blob-1 { width: 400px; height: 400px; background: #6366f1; top: -120px; left: -80px; animation: float-1 25s ease-in-out infinite; }
.bg-blob-2 { width: 380px; height: 380px; background: #8b5cf6; bottom: -100px; right: -80px; animation: float-2 30s ease-in-out infinite; }
.bg-blob-3 { width: 300px; height: 300px; background: #ec4899; top: 40%; left: 50%; opacity: 0.12; animation: float-3 35s ease-in-out infinite; }

@keyframes float-1 { 0%, 100% { transform: translate(0,0) scale(1); } 50% { transform: translate(50px, 60px) scale(1.1); } }
@keyframes float-2 { 0%, 100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-50px, -40px) scale(1.15); } }
@keyframes float-3 { 0%, 100% { transform: translate(0,0); } 50% { transform: translate(30px, -40px); } }

.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

/* ===================================================== */
/* LOGIN PAGE                                            */
/* ===================================================== */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-wrap {
  width: 100%;
  max-width: 400px;
}

.login-card {
  padding: 36px 32px 28px;
  border-radius: var(--radius-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo .logo-icon {
  display: inline-flex;
  width: 56px;
  height: 56px;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-400), var(--primary-600));
  border-radius: 16px;
  color: white;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.5);
  margin-bottom: 16px;
}

.login-logo .logo-icon svg { width: 28px; height: 28px; }

.login-logo h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff, rgba(255, 255, 255, 0.7));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-logo h1 span {
  font-weight: 500;
  opacity: 0.8;
}

.login-logo .subtitle {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 4px;
}

.login-form { display: flex; flex-direction: column; gap: 14px; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field span {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
  margin-left: 2px;
}

.field input {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  transition: all 0.2s;
}

.field input:focus {
  outline: none;
  border-color: var(--primary-400);
  background: rgba(99, 102, 241, 0.05);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.login-error {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.25);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  text-align: center;
}

.login-footer {
  text-align: center;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.brand-link {
  font-size: 11.5px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.brand-link:hover { color: var(--primary-300); }

/* ===================================================== */
/* DASHBOARD                                              */
/* ===================================================== */

.dashboard-page { padding-bottom: 60px; }

.dashboard-header {
  position: sticky;
  top: 12px;
  z-index: 50;
  margin: 12px 16px 0;
  padding: 14px 22px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(139, 92, 246, 0.2));
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.logo { display: flex; align-items: center; gap: 14px; }

.logo-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-400), var(--primary-600));
  border-radius: 12px;
  color: white;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.5);
  flex-shrink: 0;
}

.logo-icon svg { width: 22px; height: 22px; }

.logo-text h1 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  background: linear-gradient(135deg, #fff, rgba(255, 255, 255, 0.7));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text h1 span { font-weight: 500; opacity: 0.7; }
.logo-text .subtitle { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-badge {
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}

.btn-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}
.btn-icon:hover { background: rgba(255, 255, 255, 0.1); color: var(--text); }
.btn-icon svg { width: 16px; height: 16px; }

/* === TABS === */
.tabs {
  display: flex;
  gap: 6px;
  margin: 14px 16px 0;
  padding: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  overflow-x: auto;
}

.tab {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 9px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  white-space: nowrap;
  flex-shrink: 0;
}

.tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }

.tab.active {
  color: white;
  background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.dashboard-main {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tab-panel { display: none; animation: fadeIn 0.3s var(--ease); }
.tab-panel.active { display: flex; flex-direction: column; gap: 14px; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* === KPI === */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.kpi {
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
}

.kpi-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  background: linear-gradient(135deg, #fff, rgba(255, 255, 255, 0.7));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-variant-numeric: tabular-nums;
}

.kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

.kpi-success .kpi-value { background: linear-gradient(135deg, var(--success), #6ee7b7); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.kpi-error .kpi-value { background: linear-gradient(135deg, var(--danger), #fca5a5); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

/* === CARDS === */
.card {
  padding: 20px 22px;
  border-radius: var(--radius-lg);
}

.card h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 16px;
}

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

.card-header h2 { margin: 0; }

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

.stats-row > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
}

.stat-num {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat-name {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

/* === ERROR TYPES === */
.error-types {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.error-type-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
}

.error-type-name { font-weight: 600; font-size: 13px; }
.error-type-count {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

/* === TABLES === */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.data-table th {
  text-align: left;
  padding: 12px 14px;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
.data-table tbody tr:last-child td { border-bottom: none; }

.uuid-short {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 2px 6px;
  border-radius: 4px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-running { background: rgba(99, 102, 241, 0.15); color: var(--primary-300); border: 1px solid rgba(99, 102, 241, 0.3); }
.badge-done { background: rgba(52, 211, 153, 0.15); color: var(--success); border: 1px solid rgba(52, 211, 153, 0.3); }
.badge-stopped { background: rgba(251, 191, 36, 0.15); color: var(--warning); border: 1px solid rgba(251, 191, 36, 0.3); }
.badge-crashed { background: rgba(248, 113, 113, 0.15); color: var(--danger); border: 1px solid rgba(248, 113, 113, 0.3); }

.mini-progress {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mini-bar {
  width: 80px;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.mini-bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary-500), var(--primary-400)); border-radius: var(--radius-full); }
.mini-progress-text { font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* === FEED === */
.feed-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 600px;
  overflow-y: auto;
  padding-right: 6px;
}

.feed-entry {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  align-items: center;
  animation: slide-in 0.3s var(--ease);
}

@keyframes slide-in { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: translateX(0); } }

.feed-entry.ok { border-left: 3px solid var(--success); }
.feed-entry.error { border-left: 3px solid var(--danger); }

.feed-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}
.feed-entry.ok .feed-icon { background: rgba(52, 211, 153, 0.15); color: var(--success); }
.feed-entry.error .feed-icon { background: rgba(248, 113, 113, 0.15); color: var(--danger); }

.feed-content { min-width: 0; }
.feed-main { font-size: 12.5px; font-weight: 500; }
.feed-sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.feed-time {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  font-size: 13px;
}

/* === ERRORS LIST === */
.errors-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 700px;
  overflow-y: auto;
}

.error-entry {
  padding: 12px 16px;
  background: rgba(248, 113, 113, 0.04);
  border: 1px solid rgba(248, 113, 113, 0.15);
  border-radius: var(--radius);
}

.error-entry-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}

.error-entry-msg {
  font-weight: 600;
  font-size: 13px;
  color: var(--danger);
}

.error-entry-meta {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.error-entry-stack {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10.5px;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.2);
  padding: 8px 10px;
  border-radius: 6px;
  max-height: 100px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin-top: 6px;
}

/* === BUTTON PRIMARY (login) === */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
  color: white;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: all 0.2s;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.55);
}
.btn-primary svg { width: 16px; height: 16px; }

/* === TOGGLE === */
.toggle-errors {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  color: var(--text-dim);
}
.toggle-errors input { display: none; }
.toggle-track {
  position: relative;
  width: 36px;
  height: 20px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  transition: all 0.2s;
  flex-shrink: 0;
}
.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.toggle-errors input:checked ~ .toggle-track { background: var(--danger); }
.toggle-errors input:checked ~ .toggle-track .toggle-thumb { transform: translateX(16px); }

/* === FOOTER === */
.dashboard-footer {
  margin: 20px 16px 0;
  padding: 14px;
  text-align: center;
}
.dashboard-footer .brand {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 11px;
  transition: color 0.2s;
}
.dashboard-footer .brand:hover { color: var(--primary-300); }
.dashboard-footer .brand-url { font-weight: 700; color: var(--primary-400); }

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }
