/* ═══════════════════════════════════════════════════════════════════════
   DASHBOARD V2 — Premium design with sidebar, glow background, refined UI
   Inspired by Linear / Vercel / Stripe with original galaxy accent
   ═══════════════════════════════════════════════════════════════════════ */

/* Override accent: emerald green to match reference image */
:root {
  --emerald: #10b981;
  --emerald-h: #059669;
  --emerald-d: #047857;
  --emerald-glow: rgba(16, 185, 129, 0.18);
}
[data-theme="light"] {
  --emerald: #059669;
  --emerald-h: #047857;
  --emerald-d: #065f46;
  --emerald-glow: rgba(5, 150, 105, 0.12);
}

/* ─── Layout: shell ─── */
#screen-dash:not(.hidden) {
  display: grid;
  grid-template-columns: 256px 1fr;
  height: 100vh;
  width: 100%;
  position: relative;
  overflow: hidden;
  background: var(--bg0);
}

/* ─── Animated background (the "galaxy" effect) ─── */
.dash-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.dash-bg-glow {
  position: absolute;
  top: -10%;
  right: -20%;
  width: 90%;
  height: 120%;
  background:
    radial-gradient(ellipse 60% 50% at 70% 40%, rgba(16, 185, 129, 0.10), transparent 60%),
    radial-gradient(ellipse 50% 60% at 80% 60%, rgba(168, 85, 247, 0.06), transparent 65%),
    radial-gradient(ellipse 40% 70% at 60% 50%, rgba(255, 200, 100, 0.04), transparent 70%);
  filter: blur(40px);
  animation: galaxy-drift 30s ease-in-out infinite;
}
.dash-bg-stars {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,0.3) 0, transparent 50%),
    radial-gradient(1px 1px at 60% 70%, rgba(255,255,255,0.25) 0, transparent 50%),
    radial-gradient(1px 1px at 80% 20%, rgba(255,255,255,0.2) 0, transparent 50%),
    radial-gradient(1.5px 1.5px at 30% 80%, rgba(255,255,255,0.35) 0, transparent 50%),
    radial-gradient(1px 1px at 90% 50%, rgba(255,255,255,0.25) 0, transparent 50%),
    radial-gradient(1px 1px at 50% 10%, rgba(255,255,255,0.2) 0, transparent 50%),
    radial-gradient(1.5px 1.5px at 70% 90%, rgba(255,255,255,0.3) 0, transparent 50%),
    radial-gradient(1px 1px at 15% 60%, rgba(255,255,255,0.25) 0, transparent 50%);
  background-size: 100% 100%;
  opacity: 0.6;
  animation: stars-twinkle 8s ease-in-out infinite alternate;
}
[data-theme="light"] .dash-bg-glow {
  background:
    radial-gradient(ellipse 60% 50% at 70% 40%, rgba(16, 185, 129, 0.06), transparent 60%),
    radial-gradient(ellipse 50% 60% at 80% 60%, rgba(168, 85, 247, 0.04), transparent 65%);
}
[data-theme="light"] .dash-bg-stars {
  display: none;
}
@keyframes galaxy-drift {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(-3%, 2%) rotate(2deg); }
  66% { transform: translate(2%, -2%) rotate(-1deg); }
}
@keyframes stars-twinkle {
  0% { opacity: 0.4; }
  100% { opacity: 0.7; }
}

/* ─── Sidebar ─── */
.dash-sidebar {
  position: relative;
  z-index: 10;
  background: rgba(7, 9, 12, 0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--bd1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
[data-theme="light"] .dash-sidebar {
  background: rgba(255, 255, 255, 0.85);
}
.dash-sidebar-inner {
  flex: 1;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.dash-sidebar-inner::-webkit-scrollbar { width: 4px; }
.dash-sidebar-inner::-webkit-scrollbar-thumb { background: var(--bd2); border-radius: 2px; }

/* Logo */
.dash-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  margin-bottom: 24px;
}
.dash-logo-mark {
  color: var(--emerald);
  font: 700 18px var(--fm);
  letter-spacing: -0.5px;
}
.dash-logo-text {
  font: 800 13px var(--f);
  color: var(--t6);
  letter-spacing: 0.8px;
}
.dash-logo-badge {
  font: 700 9px var(--fm);
  color: var(--emerald);
  background: var(--emerald-glow);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 1px;
}

/* Section labels */
.dash-nav-section-label {
  font: 700 10px var(--fm);
  color: var(--t2);
  letter-spacing: 1.5px;
  padding: 16px 10px 8px;
  text-transform: uppercase;
}

/* Nav items */
.dash-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.dash-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--t3);
  text-decoration: none;
  font: 500 13px var(--f);
  transition: all 150ms ease;
  cursor: pointer;
}
.dash-nav-item svg {
  flex-shrink: 0;
  color: var(--t2);
  transition: color 150ms ease;
}
.dash-nav-item:hover {
  background: var(--bg2);
  color: var(--t5);
}
.dash-nav-item:hover svg { color: var(--t4); }
.dash-nav-item.active {
  background: var(--emerald-glow);
  color: var(--emerald);
}
.dash-nav-item.active svg {
  color: var(--emerald);
}
[data-theme="light"] .dash-nav-item.active {
  background: rgba(16, 185, 129, 0.10);
  color: var(--emerald-d);
}
[data-theme="light"] .dash-nav-item.active svg {
  color: var(--emerald-d);
}

/* Plan card */
.dash-plan-card {
  margin-top: auto;
  margin-left: 6px;
  margin-right: 6px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(7, 9, 12, 0.4));
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
[data-theme="light"] .dash-plan-card {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.06), rgba(255, 255, 255, 0.6));
  border-color: rgba(16, 185, 129, 0.25);
}
.dash-plan-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.dash-plan-icon { font-size: 14px; }
.dash-plan-name {
  font: 600 13px var(--f);
  color: var(--t6);
}
.dash-plan-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.dash-plan-label {
  font: 500 11px var(--f);
  color: var(--t3);
}
.dash-plan-value {
  font: 600 11px var(--f);
  color: var(--t5);
}
.dash-plan-bar {
  width: 100%;
  height: 5px;
  background: var(--bg2);
  border-radius: 3px;
  overflow: hidden;
}
.dash-plan-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--emerald), #34d399);
  border-radius: 3px;
  transition: width 400ms ease;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}
.dash-plan-button {
  width: 100%;
  background: transparent;
  border: 1px solid var(--bd2);
  color: var(--t5);
  font: 500 12px var(--f);
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 150ms ease;
}
.dash-plan-button:hover {
  background: var(--bg2);
  border-color: var(--bd3);
  color: var(--t6);
}

/* ─── Main area ─── */
.dash-main {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  min-width: 0;
}

/* Topbar */
.dash-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 28px;
  background: rgba(7, 9, 12, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}
[data-theme="light"] .dash-topbar {
  background: rgba(255, 255, 255, 0.7);
  border-bottom-color: var(--bd1);
}

.dash-topbar-search {
  flex: 0 1 360px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg1);
  border: 1px solid var(--bd1);
  border-radius: 8px;
  padding: 8px 12px;
  transition: border-color 150ms ease, background 150ms ease;
}
.dash-topbar-search:focus-within {
  border-color: var(--emerald);
  background: var(--bg2);
}
.dash-topbar-search svg { color: var(--t2); flex-shrink: 0; }
.dash-topbar-search input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--t6);
  font: 400 13px var(--f);
}
.dash-topbar-search input::placeholder { color: var(--t2); }
.dash-kbd {
  font: 600 10px var(--fm);
  color: var(--t2);
  background: var(--bg2);
  border: 1px solid var(--bd1);
  border-radius: 4px;
  padding: 2px 5px;
  letter-spacing: 0.5px;
}

.dash-topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.dash-welcome {
  font: 500 13px var(--f);
  color: var(--t4);
  margin-right: 4px;
  white-space: nowrap;
}

/* Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--emerald), #14b88d);
  color: white;
  font: 600 13px var(--f);
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 150ms ease;
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.3), 0 0 0 1px rgba(16, 185, 129, 0.4) inset;
  white-space: nowrap;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #14b88d, var(--emerald-h));
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4), 0 0 0 1px rgba(16, 185, 129, 0.5) inset;
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg2);
  border: 1px solid var(--bd2);
  color: var(--t5);
  font: 500 13px var(--f);
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 150ms ease;
  white-space: nowrap;
}
.btn-secondary:hover {
  background: var(--bg3);
  border-color: var(--bd3);
  color: var(--t6);
}

.dash-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--bd1);
  color: var(--t3);
  border-radius: 8px;
  cursor: pointer;
  transition: all 150ms ease;
}
.dash-icon-btn:hover {
  background: var(--bg2);
  border-color: var(--bd2);
  color: var(--t5);
}
.dash-icon-btn.theme-toggle { padding: 0; gap: 0; position: relative; }
.dash-icon-btn.theme-toggle .theme-icon {
  width: 16px;
  height: 16px;
  position: absolute;
  transition: opacity 200ms ease, transform 200ms ease;
}
.dash-icon-btn.theme-toggle .theme-icon-sun { opacity: 0; transform: rotate(-90deg); }
.dash-icon-btn.theme-toggle .theme-icon-moon { opacity: 1; transform: rotate(0); }
[data-theme="light"] .dash-icon-btn.theme-toggle .theme-icon-sun { opacity: 1; transform: rotate(0); }
[data-theme="light"] .dash-icon-btn.theme-toggle .theme-icon-moon { opacity: 0; transform: rotate(90deg); }

.dash-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  color: white;
  font: 600 13px var(--f);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px transparent;
}
.dash-avatar:hover {
  transform: scale(1.05);
  box-shadow: 0 0 0 2px var(--emerald-glow);
}

/* ─── Content ─── */
.dash-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px 80px;
  position: relative;
}

.dash-content-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}
.dash-title {
  font: 700 32px/1.2 var(--f);
  color: var(--t6);
  letter-spacing: -0.6px;
  margin-bottom: 6px;
}
.dash-subtitle {
  font: 400 14px var(--f);
  color: var(--t3);
}
.dash-content-search {
  flex: 0 1 320px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg1);
  border: 1px solid var(--bd1);
  border-radius: 8px;
  padding: 9px 14px;
  transition: border-color 150ms ease;
}
.dash-content-search:focus-within { border-color: var(--emerald); }
.dash-content-search svg { color: var(--t2); flex-shrink: 0; }
.dash-content-search input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--t6);
  font: 400 13px var(--f);
  width: 100%;
}
.dash-content-search input::placeholder { color: var(--t2); }

/* Projects grid */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.proj-card {
  position: relative;
  background: rgba(17, 24, 39, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--bd1);
  border-radius: 12px;
  padding: 18px;
  cursor: pointer;
  transition: all 200ms ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 120px;
}
[data-theme="light"] .proj-card {
  background: rgba(255, 255, 255, 0.7);
}
.proj-card:hover {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(17, 24, 39, 0.7);
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(16, 185, 129, 0.1);
}
[data-theme="light"] .proj-card:hover {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(16, 185, 129, 0.15);
}
.proj-name {
  font: 600 15px var(--f);
  color: var(--t6);
  letter-spacing: -0.2px;
  word-break: break-word;
  padding-right: 24px;
}
.proj-meta {
  font: 400 12px var(--f);
  color: var(--t3);
  display: flex;
  align-items: center;
  gap: 6px;
}
.proj-files {
  margin-top: auto;
  font: 500 11px var(--fm);
  color: var(--t2);
  letter-spacing: 0.3px;
}
.proj-del {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 24px;
  height: 24px;
  background: transparent;
  border: none;
  color: var(--t2);
  font-size: 18px;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: all 150ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.proj-card:hover .proj-del { opacity: 1; }
.proj-del:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* Empty state */
.dash-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 0;
}
.dash-empty.hidden { display: none; }
.dash-empty-card {
  text-align: center;
  background: rgba(17, 24, 39, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 56px 40px;
  max-width: 540px;
  width: 100%;
  position: relative;
  overflow: hidden;
}
[data-theme="light"] .dash-empty-card {
  background: rgba(255, 255, 255, 0.6);
  border-color: var(--bd1);
}
.dash-empty-card::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse 30% 40% at 50% 30%, rgba(16, 185, 129, 0.06), transparent 70%);
  pointer-events: none;
}
.dash-empty-icon {
  position: relative;
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--t3);
}
[data-theme="light"] .dash-empty-icon {
  background: rgba(0, 0, 0, 0.04);
  border-color: var(--bd1);
}
.dash-empty-icon-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 22px;
  height: 22px;
  background: var(--emerald);
  color: white;
  font: 700 13px var(--f);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg0);
}
[data-theme="light"] .dash-empty-icon-badge {
  border-color: white;
}
.dash-empty-title {
  font: 600 18px var(--f);
  color: var(--t6);
  letter-spacing: -0.3px;
  margin-bottom: 6px;
}
.dash-empty-text {
  font: 400 14px var(--f);
  color: var(--t3);
  margin-bottom: 24px;
  line-height: 1.5;
}
.dash-empty-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Footer */
.dash-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 40px;
  font: 400 12px var(--f);
  color: var(--t2);
  background: linear-gradient(180deg, transparent, rgba(7, 9, 12, 0.6));
  pointer-events: none;
  z-index: 2;
}
[data-theme="light"] .dash-footer {
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.6));
}
.dash-footer-left { pointer-events: auto; }
.dash-footer-links {
  display: flex;
  gap: 20px;
  pointer-events: auto;
}
.dash-footer-links a {
  color: var(--t2);
  text-decoration: none;
  transition: color 150ms ease;
}
.dash-footer-links a:hover { color: var(--t5); }

/* Help FAB */
.dash-help-fab {
  position: fixed;
  bottom: 16px;
  right: 24px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg2);
  color: var(--t4);
  border: 1px solid var(--bd2);
  border-radius: 100px;
  padding: 8px 14px;
  font: 500 12px var(--f);
  cursor: pointer;
  transition: all 150ms ease;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.dash-help-fab:hover {
  background: var(--bg3);
  color: var(--t6);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* Mobile menu toggle (hidden on desktop) */
.dash-mobile-toggle {
  display: none;
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 30;
  width: 38px;
  height: 38px;
  background: var(--bg2);
  border: 1px solid var(--bd2);
  color: var(--t5);
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* ─── Responsive ─── */
@media (max-width: 1024px) {
  .dash-content { padding: 28px 24px 80px; }
  .dash-topbar { padding: 12px 20px; gap: 16px; }
  .dash-welcome { display: none; }
  .dash-topbar-search { flex: 0 1 240px; }
}

@media (max-width: 768px) {
  #screen-dash { grid-template-columns: 1fr; }
  
  .dash-mobile-toggle { display: flex; }
  
  .dash-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 250ms ease;
    z-index: 40;
    box-shadow: 0 0 60px rgba(0,0,0,0.5);
  }
  .dash-sidebar.open { transform: translateX(0); }
  
  .dash-sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 35;
    opacity: 0;
    pointer-events: none;
    transition: opacity 250ms ease;
  }
  .dash-sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
  
  .dash-topbar {
    padding-left: 64px;
    flex-wrap: wrap;
    row-gap: 8px;
  }
  .dash-topbar-search { flex: 1 1 100%; order: 3; }
  .dash-content { padding: 24px 16px 80px; }
  .dash-title { font-size: 26px; }
  .dash-content-head { flex-direction: column; }
  .dash-content-search { flex: 1 1 100%; }
  .dash-empty-card { padding: 40px 24px; }
  .dash-footer { flex-direction: column; gap: 8px; padding: 14px 16px; text-align: center; }
  .btn-secondary span:not(svg+span), .btn-primary span:not(svg+span) { display: inline; }
  /* Hide non-essential icon buttons in compact view */
  .dash-icon-btn { width: 34px; height: 34px; }
}

@media (max-width: 480px) {
  .dash-topbar-actions { gap: 6px; }
  .btn-primary, .btn-secondary { padding: 8px 12px; font-size: 12px; }
  /* Hide secondary button text on tiny screens, keep just icon */
  .btn-secondary { padding: 8px; }
  .btn-secondary > svg + * { display: none; }
}

/* ─── Hide legacy elements ─── */
.dash-header, .dash-header-r, .dash-body, .dash-top-row { display: none !important; }
