/* Desktop Shell — active only when html[data-layout-mode="desktop"] */

html[data-layout-mode="desktop"] body {
  overflow-x: hidden;
}

html[data-layout-mode="desktop"] .bottom-nav,
html[data-layout-mode="desktop"] .bottom-nav-spacer,
html[data-layout-mode="desktop"] .top-bar,
html[data-layout-mode="desktop"] .mobile-desktop-toggle {
  display: none !important;
}

html[data-layout-mode="desktop"] .layout-container {
  display: contents;
}

html[data-layout-mode="desktop"] .layout-main {
  display: block;
  max-width: none;
  padding: 0;
}

/* Override mobile #app constraint — the desktop-shell grid handles layout */
html[data-layout-mode="desktop"] #app {
  max-width: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* Multi-column grids for content lists inside desktop-main */
html[data-layout-mode="desktop"] .desktop-main .content-list,
html[data-layout-mode="desktop"] .desktop-main .history-grid,
html[data-layout-mode="desktop"] .desktop-main .stories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

/* Dashboard 2-column: main content + side rail */
html[data-layout-mode="desktop"] .desktop-main .dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 1280px) {
  html[data-layout-mode="desktop"] .desktop-main .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* Forms inside desktop stay readable (don't stretch full width) */
html[data-layout-mode="desktop"] .desktop-main .form-card,
html[data-layout-mode="desktop"] .desktop-main .auth-card {
  max-width: 720px;
}

/* Cards inside desktop-main look like panels */
html[data-layout-mode="desktop"] .desktop-main .glass-card {
  border-radius: 14px;
}

/* Profile apps grid — horizontal on desktop */
html[data-layout-mode="desktop"] .profile-apps-grid {
  flex-direction: row !important;
}

/* Rhythm options — horizontal on desktop */
html[data-layout-mode="desktop"] .rhythm-options-wrap {
  flex-direction: row !important;
}
html[data-layout-mode="desktop"] .rhythm-options-wrap .rhythm-radio-label {
  flex: 1;
  min-width: 0;
}

.desktop-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
  background: transparent;
  position: relative;
  z-index: 1;
}

/* Sidebar */
.desktop-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  background: rgba(12, 12, 24, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.desktop-sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 20px;
  text-decoration: none;
  color: #fff;
}

.desktop-sidebar-logo-mark {
  font-weight: 800;
  font-size: 18px;
  background: linear-gradient(135deg, #7c5cff, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: 0.5px;
}

.desktop-sidebar-logo-text {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
}

.desktop-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

.desktop-sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.desktop-sidebar-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.desktop-sidebar-item.active {
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.18), rgba(34, 211, 238, 0.12));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(124, 92, 255, 0.35);
}

.desktop-sidebar-item svg {
  flex-shrink: 0;
}

.desktop-sidebar-item.sidebar-admin-item {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  color: rgba(244, 63, 94, 0.8);
}
.desktop-sidebar-item.sidebar-admin-item:hover {
  color: #f43f5e;
  background: rgba(244, 63, 94, 0.08);
}
.desktop-sidebar-item.sidebar-admin-item.active {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.15), rgba(225, 29, 72, 0.1));
  color: #f43f5e;
  box-shadow: inset 0 0 0 1px rgba(244, 63, 94, 0.3);
}

.desktop-sidebar-footer {
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.desktop-sidebar-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.75);
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}

.desktop-sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

/* Main wrap */
.desktop-main-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Topbar */
.desktop-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 32px;
  background: rgba(12, 12, 24, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.desktop-topbar-title {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.desktop-topbar-search {
  flex: 1;
  max-width: 460px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.5);
}

.desktop-topbar-search:focus-within {
  border-color: rgba(124, 92, 255, 0.45);
  background: rgba(255, 255, 255, 0.06);
}

.desktop-topbar-search input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: #fff;
  font-size: 14px;
}

.desktop-topbar-search input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.desktop-topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.desktop-topbar-credits {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fde68a;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.desktop-topbar-credits.low { color: #fbbf24; border-color: rgba(251, 191, 36, 0.35); }
.desktop-topbar-credits.zero { color: #f87171; border-color: rgba(248, 113, 113, 0.35); }

.desktop-topbar-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c5cff, #22d3ee);
  color: #fff;
  text-decoration: none;
}

/* Main content */
.desktop-main {
  flex: 1;
  padding: 24px 28px 40px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

/* ============ Dashboard desktop layout ============ */
html[data-layout-mode="desktop"] .desktop-main .dashboard-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 1180px) {
  html[data-layout-mode="desktop"] .desktop-main .dashboard-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
html[data-layout-mode="desktop"] .desktop-main .kpi-card {
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
html[data-layout-mode="desktop"] .desktop-main .kpi-card .kpi-label {
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(240, 240, 255, 0.45);
  font-weight: 600;
  margin-bottom: 8px;
}
html[data-layout-mode="desktop"] .desktop-main .kpi-card .kpi-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(135deg, #7c5cff, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
html[data-layout-mode="desktop"] .desktop-main .kpi-card .kpi-trend {
  font-size: 0.6875rem;
  margin-top: 6px;
  color: rgba(240, 240, 255, 0.5);
  font-weight: 600;
}
html[data-layout-mode="desktop"] .desktop-main .dashboard-week-mini {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}
html[data-layout-mode="desktop"] .desktop-main .dashboard-week-mini .day-cell {
  padding: 12px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  text-align: center;
  transition: all 0.18s;
  cursor: pointer;
}
html[data-layout-mode="desktop"] .desktop-main .dashboard-week-mini .day-cell:hover {
  border-color: rgba(124, 92, 255, 0.35);
  background: rgba(124, 92, 255, 0.06);
}
html[data-layout-mode="desktop"] .desktop-main .dashboard-week-mini .day-cell.today {
  border-color: rgba(124, 92, 255, 0.55);
  background: rgba(124, 92, 255, 0.1);
}
html[data-layout-mode="desktop"] .desktop-main .dashboard-week-mini .day-name {
  font-size: 0.625rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(240, 240, 255, 0.4);
  font-weight: 700;
}
html[data-layout-mode="desktop"] .desktop-main .dashboard-week-mini .day-num {
  font-size: 1.25rem;
  font-weight: 800;
  color: #f0f0ff;
  margin: 6px 0 4px;
}
html[data-layout-mode="desktop"] .desktop-main .dashboard-week-mini .day-count {
  font-size: 0.6875rem;
  color: rgba(240, 240, 255, 0.5);
}
html[data-layout-mode="desktop"] .desktop-main .dashboard-side-rail {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
html[data-layout-mode="desktop"] .desktop-main .dashboard-side-rail .glass-card {
  padding: 18px;
}
html[data-layout-mode="desktop"] .desktop-main .side-card-title {
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(240, 240, 255, 0.45);
  font-weight: 700;
  margin: 0 0 12px;
}
html[data-layout-mode="desktop"] .desktop-main .quick-action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
  color: #f0f0ff;
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.18s;
  margin-bottom: 8px;
}
html[data-layout-mode="desktop"] .desktop-main .quick-action-btn:hover {
  border-color: rgba(124, 92, 255, 0.45);
  background: rgba(124, 92, 255, 0.08);
  transform: translateX(2px);
}
html[data-layout-mode="desktop"] .desktop-main .quick-action-btn:last-child { margin-bottom: 0; }
html[data-layout-mode="desktop"] .desktop-main .activity-feed-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: opacity 0.15s;
}
html[data-layout-mode="desktop"] .desktop-main .activity-feed-item:last-child { border-bottom: none; }
html[data-layout-mode="desktop"] .desktop-main .activity-feed-item:hover { opacity: 0.82; }
html[data-layout-mode="desktop"] .desktop-main .activity-feed-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
html[data-layout-mode="desktop"] .desktop-main .activity-feed-text {
  flex: 1; min-width: 0;
  font-size: 0.8125rem; color: #f0f0ff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
html[data-layout-mode="desktop"] .desktop-main .activity-feed-meta {
  font-size: 0.6875rem; color: rgba(240, 240, 255, 0.4); flex-shrink: 0;
}

/* Responsive fallback for narrower desktops */
@media (max-width: 1180px) {
  .desktop-shell {
    grid-template-columns: 72px 1fr;
  }
  .desktop-sidebar-logo-text,
  .desktop-sidebar-item span,
  .desktop-sidebar-toggle span {
    display: none;
  }
  .desktop-sidebar-item {
    justify-content: center;
  }
}
