/* ============================================================
   UNDERMACHINE ADMIN — style.css v6
   Финальный: темы, обои, анимации, всё аккуратно
   ============================================================ */

:root, [data-theme="cosmos"] {
  --bg: #0a0e27;
  --card: #141832;
  --card-2: #1a1f45;
  --border: rgba(139, 92, 246, 0.25);
  --text: #e0e7ff;
  --text-dim: #94a3b8;
  --accent: #8b5cf6;
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #06b6d4 100%);
  --ok: #10b981;
  --bad: #ef4444;
  --warn: #f59e0b;
  --glow: 0 0 24px rgba(139, 92, 246, 0.35);
}

[data-theme="cyberpunk"] {
  --bg: #0a0510;
  --card: #1a0a28;
  --card-2: #251135;
  --border: rgba(255, 0, 170, 0.35);
  --text: #ffe4ff;
  --text-dim: #b48eb8;
  --accent: #ff00aa;
  --grad: linear-gradient(135deg, #ff00aa 0%, #ff6b00 50%, #00e5ff 100%);
  --ok: #00ff9d;
  --bad: #ff3366;
  --warn: #ffb800;
  --glow: 0 0 24px rgba(255, 0, 170, 0.5);
}

[data-theme="minimal"] {
  --bg: #f6f8fc;
  --card: #ffffff;
  --card-2: #f0f4fb;
  --border: rgba(0, 0, 0, 0.08);
  --text: #1a1f36;
  --text-dim: #6b7690;
  --accent: #3b82f6;
  --grad: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
  --ok: #059669;
  --bad: #dc2626;
  --warn: #d97706;
  --glow: 0 4px 20px rgba(59, 130, 246, 0.15);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overscroll-behavior-y: none;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  position: relative;
  background:
    radial-gradient(circle at 20% -10%, rgba(139, 92, 246, 0.15), transparent 50%),
    radial-gradient(circle at 100% 0%, rgba(6, 182, 212, 0.10), transparent 40%),
    var(--bg);
}

body.has-wallpaper {
  background: transparent;
}

/* ---------- Обои ---------- */
#wallpaper-layer,
#wallpaper-dim {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  margin: 0; padding: 0;
  pointer-events: none;
  z-index: -1;
}
#wallpaper-layer.hidden { display: none; }
#wallpaper-layer img,
#wallpaper-layer video {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: var(--wall-opacity, 1);
  filter: blur(var(--wall-blur, 0px));
  transition: opacity 0.4s ease;
}
#wallpaper-dim {
  background: rgba(0, 0, 0, var(--wall-dim, 0));
  z-index: 0;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: rgba(10, 14, 39, 0.72);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
[data-theme="minimal"] .topbar { background: rgba(255, 255, 255, 0.8); }

.topbar-left { display: flex; align-items: center; gap: 10px; }
.logo {
  font-size: 22px;
  background: var(--grad);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 6s ease-in-out infinite;
}
.logo-text {
  font-weight: 700;
  letter-spacing: 1.5px;
  font-size: 13px;
  background: var(--grad);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 6s ease-in-out infinite;
}
.topbar-right { display: flex; gap: 8px; }

.icon-btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px; height: 36px;
  border-radius: 10px;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s;
}
.icon-btn:active { transform: scale(0.86); }
.icon-btn:hover { box-shadow: var(--glow); }

/* ---------- View ---------- */
.view {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  z-index: 1;
}
.loading {
  text-align: center;
  color: var(--text-dim);
  padding: 60px 0;
  animation: pulse 1.4s ease-in-out infinite;
}

.view > * {
  animation: fadeSlideUp 0.4s cubic-bezier(.2,.7,.3,1.1) backwards;
}
.view > *:nth-child(1) { animation-delay: 0.02s; }
.view > *:nth-child(2) { animation-delay: 0.06s; }
.view > *:nth-child(3) { animation-delay: 0.10s; }
.view > *:nth-child(4) { animation-delay: 0.14s; }
.view > *:nth-child(5) { animation-delay: 0.18s; }
.view > *:nth-child(6) { animation-delay: 0.22s; }
.view > *:nth-child(7) { animation-delay: 0.26s; }

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  background: rgba(10, 14, 39, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
}
[data-theme="minimal"] .tabbar { background: rgba(255, 255, 255, 0.92); }

.tab {
  flex: 1;
  background: none; border: none;
  color: var(--text-dim);
  display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 5px 1px;
  font-size: 9px;
  cursor: pointer;
  border-radius: 10px;
  transition: color 0.18s, background 0.18s;
}
.tab-icon { font-size: 16px; line-height: 1; transition: transform 0.2s; }
.tab:active .tab-icon { transform: scale(1.15); }
.tab.active { color: var(--text); background: var(--card); }
.tab.active .tab-icon {
  filter: drop-shadow(0 0 6px var(--accent));
  animation: bounce 0.4s cubic-bezier(.34,1.56,.64,1);
}

/* ---------- Карточки ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.25s, transform 0.25s, border-color 0.25s;
}
.card:hover { box-shadow: var(--glow); }
.card::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: var(--grad);
  background-size: 200% 100%;
  opacity: 0.7;
  animation: gradientShift 8s ease-in-out infinite;
}
.card-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.card-value {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.card-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ---------- Grid ---------- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.grid-1 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

/* ---------- Точки ---------- */
.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.dot.ok  { background: var(--ok);  box-shadow: 0 0 8px var(--ok); animation: pulseDot 2s ease-in-out infinite; }
.dot.bad { background: var(--bad); box-shadow: 0 0 8px var(--bad); }
.dot.warn{ background: var(--warn);box-shadow: 0 0 8px var(--warn); animation: pulseDot 1.6s ease-in-out infinite; }

/* ---------- Кнопки ---------- */
.btn {
  background: var(--grad);
  background-size: 200% 200%;
  border: none;
  color: #fff;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
  box-shadow: var(--glow);
  animation: gradientShift 6s ease-in-out infinite;
}
.btn:active { transform: scale(0.94); }
.btn.ghost {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: none;
  animation: none;
}
.btn.ghost:hover { box-shadow: var(--glow); border-color: var(--accent); }
.btn.ghost:active { transform: scale(0.94); }

/* ---------- Строки ---------- */
.row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: none; }
.row-label { font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row-value { font-size: 13px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(30px) scale(0.9);
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s, transform 0.28s cubic-bezier(.34,1.56,.64,1);
  z-index: 100;
  max-width: 90vw;
  box-shadow: var(--glow);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}

/* ---------- Заголовки ---------- */
.section-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 20px 4px 10px;
}
.section-title:first-child { margin-top: 0; }

/* ---------- Тема: кнопки ---------- */
.theme-btns { display: flex; gap: 8px; }
.theme-btn {
  flex: 1;
  padding: 12px 8px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--card-2);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}
.theme-btn.active {
  border-color: var(--accent);
  box-shadow: var(--glow);
  background: var(--card);
}
.theme-btn:active { transform: scale(0.95); }

/* ---------- Обои: контролы ---------- */
.wall-preview {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 12px;
  background: var(--card-2);
  background-size: cover;
  background-position: center;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}
.file-input { display: none; }
.file-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 18px;
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  text-align: center;
}
.file-label:hover {
  border-color: var(--accent);
  background: var(--card-2);
  box-shadow: var(--glow);
}
.wall-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wall-controls .btn.ghost {
  width: 100%;
  padding: 12px 18px;
}

/* ---------- Слайдеры ---------- */
.wall-sliders {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.slider-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.slider-row .card-sub {
  margin: 0;
  font-size: 13px;
}
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--card-2);
  outline: none;
  margin: 4px 0 0 0;
  cursor: pointer;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 10px var(--accent);
  transition: transform 0.15s;
  border: none;
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
.slider::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
  box-shadow: 0 0 10px var(--accent);
}

/* ---------- Inputs ---------- */
input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card-2);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: var(--glow);
}
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card-2);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
}
textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--glow);
}

/* ---------- Animations ---------- */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}
@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.35); opacity: 0.75; }
}
@keyframes bounce {
  0%   { transform: scale(0.75); }
  60%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* ============ LOCK SCREEN ============ */
#lock-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 20% -10%, rgba(139, 92, 246, 0.25), transparent 50%),
    radial-gradient(circle at 100% 0%, rgba(6, 182, 212, 0.15), transparent 40%);
  animation: lockFadeIn 0.3s ease;
}
#lock-screen.unlocked {
  animation: lockFadeOut 0.35s ease forwards;
  pointer-events: none;
}
.lock-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px;
  width: 100%;
  max-width: 340px;
}
.lock-logo {
  font-size: 64px;
  background: var(--grad);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 4s ease-in-out infinite;
}
.lock-title {
  font-size: 18px;
  letter-spacing: 3px;
  font-weight: 700;
  background: var(--grad);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 4s ease-in-out infinite;
}
.lock-sub {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.lock-dots {
  display: flex;
  gap: 16px;
  margin: 8px 0 20px;
}
.lock-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}
.lock-dot.filled {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent);
  transform: scale(1.15);
}
.lock-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  width: 100%;
  max-width: 280px;
}
.lock-key {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 22px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s, background 0.12s, box-shadow 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}
.lock-key:active {
  transform: scale(0.9);
  background: var(--card-2);
  box-shadow: 0 0 16px var(--accent);
}
.lock-key-empty {
  background: transparent;
  border-color: transparent;
  pointer-events: none;
}
.lock-key-del {
  background: transparent;
  font-size: 20px;
}
.lock-key-del:active {
  background: var(--card-2);
}
.lock-error {
  color: var(--bad);
  font-size: 13px;
  min-height: 20px;
  margin-top: 4px;
  text-align: center;
}
.lock-shake {
  animation: lockShake 0.4s ease;
}

@keyframes lockFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes lockFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}
@keyframes lockShake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-12px); }
  40%      { transform: translateX(12px); }
  60%      { transform: translateX(-8px); }
  80%      { transform: translateX(8px); }
}

/* Скрываем основной UI пока не разблокировано */
body.locked .topbar,
body.locked .view,
body.locked .tabbar {
  display: none !important;
}
