/* ============================================
   DECEM TAIL — Cosmic Design System
   ============================================ */

:root {
  --bg: #0B1020;
  --bg-deep: #060912;
  --panel: rgba(17, 26, 51, 0.65);
  --panel-solid: #111A33;
  --line: #8B9FD8;
  --line2: #6C5CE7;
  --accent: #D9415D;
  --text: #E8ECF4;
  --muted: #6B7A99;
  --ok: #7DC8E8;
  --bad: #D9415D;
  --warn: #E8B86D;
  --gold: rgba(212, 175, 55, 0.5);
  --nebula: rgba(108, 92, 231, 0.12);
  --glass: rgba(17, 26, 51, 0.55);
  --glass-border: rgba(139, 159, 216, 0.15);
  --glow: 0 0 20px rgba(108, 92, 231, 0.2), 0 0 60px rgba(108, 92, 231, 0.08);
  --glow-accent: 0 0 20px rgba(217, 65, 93, 0.25);
  --radius: 20px;
  --radius-sm: 12px;
}

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

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Rajdhani, system-ui, sans-serif;
  letter-spacing: 0.02em;
  overflow-x: hidden;
}

/* ---- Cosmic Background ---- */
.grid-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse at 15% 20%, rgba(108, 92, 231, 0.18) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 30%, rgba(139, 159, 216, 0.10) 0%, transparent 45%),
    radial-gradient(ellipse at 50% 80%, rgba(217, 65, 93, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 30% 60%, rgba(108, 92, 231, 0.08) 0%, transparent 40%),
    radial-gradient(ellipse at 70% 70%, rgba(139, 159, 216, 0.05) 0%, transparent 35%);
  animation: nebulaPulse 18s ease-in-out infinite alternate;
}

.grid-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 40% 70%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 60% 20%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 80% 50%, rgba(255,255,255,0.35), transparent),
    radial-gradient(1px 1px at 10% 80%, rgba(255,255,255,0.25), transparent),
    radial-gradient(1px 1px at 90% 15%, rgba(255,255,255,0.45), transparent),
    radial-gradient(1px 1px at 50% 50%, rgba(255,255,255,0.2), transparent),
    radial-gradient(1.5px 1.5px at 25% 45%, rgba(139,159,216,0.6), transparent),
    radial-gradient(1.5px 1.5px at 75% 35%, rgba(108,92,231,0.5), transparent),
    radial-gradient(1px 1px at 35% 85%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 65% 10%, rgba(255,255,255,0.35), transparent),
    radial-gradient(1px 1px at 15% 55%, rgba(255,255,255,0.2), transparent);
  background-size: 300px 300px;
  animation: starTwinkle 8s ease-in-out infinite alternate;
}

.grid-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 25% 15%, rgba(108, 92, 231, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 75% 85%, rgba(217, 65, 93, 0.04) 0%, transparent 50%);
  animation: nebulaDrift 25s ease-in-out infinite alternate;
}

@keyframes nebulaPulse {
  0% { opacity: 1; }
  50% { opacity: 0.85; }
  100% { opacity: 1; }
}

@keyframes starTwinkle {
  0% { opacity: 0.7; }
  50% { opacity: 1; }
  100% { opacity: 0.75; }
}

@keyframes nebulaDrift {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(15px, -10px) scale(1.02); }
}

/* ---- Topbar ---- */
.topbar {
  height: 72px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 28px;
  background: rgba(11, 16, 32, 0.75);
  backdrop-filter: blur(20px) saturate(1.2);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: 0 4px 30px rgba(108, 92, 231, 0.08);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand h1 {
  font-family: Orbitron, sans-serif;
  font-size: 20px;
  letter-spacing: 0.14em;
  color: #fff;
  text-shadow: 0 0 20px rgba(108, 92, 231, 0.4);
}

.disc {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  box-shadow: 0 0 15px rgba(108, 92, 231, 0.3), inset 0 0 12px rgba(108, 92, 231, 0.15);
  position: relative;
}

.disc::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  box-shadow: var(--glow-accent);
}

.top-status {
  font-family: JetBrains Mono, monospace;
  font-size: 11px;
  color: var(--ok);
  border: 1px solid rgba(125, 200, 232, 0.3);
  padding: 6px 12px;
  background: rgba(125, 200, 232, 0.06);
  border-radius: 8px;
}

/* ---- User Profile (header) ---- */
.user-profile-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.user-profile-btn:hover {
  background: rgba(108, 92, 231, 0.1);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(108, 92, 231, 0.2);
  border: 1.5px solid rgba(139, 159, 216, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Orbitron, sans-serif;
  font-size: 14px;
  color: #fff;
}

.user-name {
  font-family: JetBrains Mono, monospace;
  font-size: 12px;
  color: var(--muted);
}

/* ---- Navigation ---- */
.nav {
  display: flex;
  gap: 6px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(11, 16, 32, 0.5);
  backdrop-filter: blur(12px);
  overflow-x: auto;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 13px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  transition: all 0.25s ease;
  white-space: nowrap;
}

.nav a:hover {
  color: #fff;
  background: rgba(108, 92, 231, 0.1);
  border-color: rgba(139, 159, 216, 0.2);
}

.nav a.active {
  color: #fff;
  background: rgba(108, 92, 231, 0.15);
  border-color: rgba(108, 92, 231, 0.35);
  box-shadow: 0 0 16px rgba(108, 92, 231, 0.15);
  text-shadow: 0 0 10px rgba(108, 92, 231, 0.3);
}

/* ---- Main ---- */
.main {
  padding: 24px 28px;
  max-width: 1280px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 18px;
}

/* ---- Cards ---- */
.card {
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.15);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
  position: relative;
  overflow: visible;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition: all 0.3s ease;
}

.card:hover {
  border-color: rgba(139, 159, 216, 0.25);
  box-shadow: 0 8px 32px rgba(108, 92, 231, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transform: translateY(-1px);
}

.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(139, 159, 216, 0.3), rgba(108, 92, 231, 0.2), transparent);
}

.card h2 {
  font-family: Orbitron, sans-serif;
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #fff;
  margin-bottom: 14px;
  text-shadow: 0 0 16px rgba(108, 92, 231, 0.3);
}

.card h3, .section-h {
  font-family: Orbitron, sans-serif;
  font-size: 11px;
  color: var(--line2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 12px 0 8px;
  border-bottom: 1px solid rgba(108, 92, 231, 0.2);
  padding-bottom: 6px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-block;
  border: 1px solid rgba(108, 92, 231, 0.4);
  background: linear-gradient(180deg, rgba(108, 92, 231, 0.18), rgba(60, 50, 150, 0.12));
  color: var(--text);
  padding: 10px 20px;
  cursor: pointer;
  font-family: Orbitron, sans-serif;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-radius: var(--radius-sm);
  transition: all 0.25s ease;
}

.btn:hover {
  background: linear-gradient(180deg, rgba(108, 92, 231, 0.28), rgba(60, 50, 150, 0.2));
  border-color: var(--line2);
  box-shadow: 0 0 18px rgba(108, 92, 231, 0.2);
  color: #fff;
}

.btn.danger {
  border-color: rgba(217, 65, 93, 0.4);
  background: rgba(217, 65, 93, 0.12);
}

.btn.danger:hover {
  border-color: var(--accent);
  box-shadow: var(--glow-accent);
}

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

.danger {
  border-color: rgba(217, 65, 93, 0.5) !important;
  color: #f4c2cf !important;
}

.muted { color: var(--muted) }

/* ---- Metric Grid ---- */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
}

.metric {
  border: 1px solid var(--glass-border);
  background: rgba(11, 16, 32, 0.5);
  padding: 14px;
  border-radius: var(--radius-sm);
}

.metric .label {
  font-family: JetBrains Mono, monospace;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
}

.metric .value {
  font-family: Orbitron, sans-serif;
  font-size: 20px;
  margin-top: 6px;
  color: #fff;
  text-shadow: 0 0 12px rgba(108, 92, 231, 0.3);
}

/* ---- Status Table ---- */
.status-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.status-table th {
  text-align: left;
  color: var(--line2);
  font-family: Orbitron, sans-serif;
  font-size: 11px;
  text-transform: uppercase;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(108, 92, 231, 0.25);
}

.status-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(139, 159, 216, 0.08);
}

.status-table tr:hover td {
  background: rgba(108, 92, 231, 0.04);
}

.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 8px;
}

.status-dot.ok {
  background: var(--ok);
  box-shadow: 0 0 10px rgba(125, 200, 232, 0.5);
}

.status-dot.err {
  background: var(--bad);
  box-shadow: 0 0 10px rgba(217, 65, 93, 0.5);
}

.status-dot.off { background: #3a4560 }

/* ---- Forms ---- */
textarea, input, select {
  background: rgba(6, 9, 18, 0.7);
  color: var(--text);
  border: 1px solid rgba(139, 159, 216, 0.2);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-family: JetBrains Mono, monospace;
  font-size: 13px;
  outline: none;
  transition: all 0.25s ease;
}

textarea:focus, input:focus, select:focus {
  border-color: var(--line2);
  box-shadow: 0 0 16px rgba(108, 92, 231, 0.15);
  background: rgba(6, 9, 18, 0.85);
}

textarea {
  width: 100%;
  min-height: 300px;
  resize: vertical;
  line-height: 1.6;
}

input[type=range] {
  accent-color: var(--line2);
  width: 100%;
}

.slider-val {
  color: var(--line);
  font-family: JetBrains Mono, monospace;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--glass-border);
  padding: 5px 10px;
  font-family: JetBrains Mono, monospace;
  font-size: 11px;
  color: var(--muted);
  border-radius: 8px;
}

pre {
  background: rgba(6, 9, 18, 0.7);
  border: 1px solid var(--glass-border);
  padding: 14px;
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  color: var(--muted);
  overflow: auto;
  font-size: 12px;
  line-height: 1.5;
}

.notice {
  border-left: 3px solid var(--line2);
  padding: 10px 14px;
  background: rgba(108, 92, 231, 0.08);
  color: #c4cde8;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 99;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: rgba(11, 16, 32, 0.92);
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  padding: 12px 18px;
  max-width: 400px;
  color: var(--text);
}

.toast.danger {
  border-color: rgba(217, 65, 93, 0.4);
  background: rgba(217, 65, 93, 0.12);
}

/* ---- Radio ---- */
.radio-player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-left: 1px solid var(--glass-border);
  border-right: 1px solid var(--glass-border);
  height: 48px;
  align-self: center;
  flex-shrink: 0;
}

.radio-btn {
  background: rgba(108, 92, 231, 0.12);
  border: 1px solid rgba(139, 159, 216, 0.25);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
  flex-shrink: 0;
  padding: 0;
  line-height: 1;
}

.radio-btn:hover {
  box-shadow: 0 0 14px rgba(108, 92, 231, 0.3);
  color: #fff;
  transform: scale(1.06);
  border-color: var(--line2);
}

.radio-play-btn {
  width: 38px;
  height: 38px;
  font-size: 15px;
  border-color: rgba(217, 65, 93, 0.4);
  box-shadow: 0 0 12px rgba(217, 65, 93, 0.15);
}

.radio-play-btn:hover {
  border-color: var(--accent);
  box-shadow: var(--glow-accent);
}

.radio-station-name {
  font-family: JetBrains Mono, monospace;
  font-size: 12px;
  color: var(--line);
  min-width: 130px;
  text-align: center;
}

.radio-vol {
  width: 70px;
  accent-color: var(--line2);
}

.radio-list { display: grid; gap: 12px }

.radio-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-sm);
  transition: all 0.25s ease;
}

.radio-item:hover {
  border-color: rgba(139, 159, 216, 0.25);
  box-shadow: 0 0 16px rgba(108, 92, 231, 0.1);
}

.radio-item.radio-active {
  border-color: rgba(125, 200, 232, 0.35);
  box-shadow: 0 0 18px rgba(125, 200, 232, 0.12);
  background: rgba(125, 200, 232, 0.05);
}

.radio-item-info { flex: 1 }

.radio-item-name {
  font-family: Orbitron, sans-serif;
  font-size: 13px;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.radio-item-url {
  font-family: JetBrains Mono, monospace;
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
}

.radio-item-actions { display: flex; gap: 8px }

/* ---- Voice / TTS ---- */
.voice-btn, .engine-btn {
  padding: 8px 14px;
  background: rgba(17, 26, 51, 0.6);
  color: var(--muted);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.25s ease;
}

.voice-btn:hover, .voice-btn.active,
.engine-btn:hover, .engine-btn.active {
  border-color: var(--line2);
  color: #fff;
  box-shadow: 0 0 14px rgba(108, 92, 231, 0.15);
}

/* ---- Modal ---- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 18, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  background: var(--panel-solid);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 440px;
  width: 90%;
  position: relative;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.4);
}

.modal-content.modal-large {
  max-width: 640px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 18px;
  font-size: 24px;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s;
}

.modal-close:hover { color: #fff }

.profile-form label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 12px;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.profile-form input, .profile-form textarea {
  width: 100%;
}

.avatar-section {
  text-align: center;
  margin-bottom: 16px;
}

.avatar-large {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(108, 92, 231, 0.15);
  border: 2px solid rgba(139, 159, 216, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #fff;
  margin: 0 auto 12px;
  font-family: Orbitron, sans-serif;
}

/* ---- Login Page ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(1.2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.login-card h1 {
  font-family: Orbitron, sans-serif;
  font-size: 22px;
  letter-spacing: 0.12em;
  color: #fff;
  margin-bottom: 8px;
  text-shadow: 0 0 20px rgba(108, 92, 231, 0.4);
}

.login-card .subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 28px;
}

.login-card label {
  display: block;
  text-align: left;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  margin-top: 16px;
}

.login-card input {
  width: 100%;
  padding: 12px 14px;
  font-size: 14px;
}

.login-card .btn {
  width: 100%;
  margin-top: 24px;
  padding: 12px;
  font-size: 13px;
}

.login-error {
  color: var(--bad);
  font-size: 12px;
  margin-top: 12px;
  min-height: 18px;
}

/* ---- Responsive ---- */
@media (max-width: 860px) {
  .dashboard-grid, .metric-grid {
    grid-template-columns: 1fr;
  }

  .main { padding: 16px }

  .topbar {
    height: auto;
    align-items: flex-start;
    gap: 12px;
    flex-direction: column;
    padding: 12px 16px;
  }

  .brand h1 { font-size: 16px }

  .radio-player {
    border-left: none;
    border-right: none;
    border-top: 1px solid var(--glass-border);
    border-bottom: 1px solid var(--glass-border);
    width: 100%;
    justify-content: center;
    height: 48px;
  }

  .nav { padding: 10px 16px }

  .status-table { font-size: 12px }
  .status-table th, .status-table td { padding: 8px 6px }
}

/* GPU Model Panel */
.gpu-panel-header { display:flex; align-items:center; gap:12px; margin-bottom:16px; padding:12px 16px; background:rgba(108,92,231,0.06); border:1px solid rgba(108,92,231,0.15); border-radius:6px; }
.gpu-panel-header .gpu-dot { width:10px; height:10px; border-radius:50%; display:inline-block; flex-shrink:0; }
.gpu-panel-header .gpu-role-name { font-family:'Orbitron',monospace; font-size:13px; color:var(--text); }
.gpu-panel-header .gpu-model { font-size:12px; color:var(--text-muted); margin-left:8px; }
.gpu-buttons { display:flex; gap:12px; flex-wrap:wrap; }
.gpu-btn-wrap { flex:1; min-width:180px; }
.gpu-btn-wrap .btn { width:100%; text-align:left; padding:16px 20px; font-size:14px; line-height:1.5; }
.gpu-btn-wrap .btn .gpu-btn-title { font-weight:600; font-size:15px; }
.gpu-btn-wrap .btn .gpu-btn-desc { font-size:12px; color:var(--text-muted); margin-top:2px; }
.gpu-btn-wrap .btn.active-gpu { border-color:rgba(79,195,247,0.5); background:linear-gradient(180deg,rgba(79,195,247,0.15),rgba(40,100,180,0.1)); box-shadow:0 0 12px rgba(79,195,247,0.15); }
.gpu-btn-wrap .btn.active-gpu:hover { box-shadow:0 0 20px rgba(79,195,247,0.25); }
#gpu-msg { margin-top:10px; font-size:12px; }
