/* Future One OS — Workspace UI (Phase 2) */

:root {
  --bg: #F7F8FA;
  --line: #E7E9ED;
  --radius: 10px;
  --sidebar-accent: var(--accent, #0A66C2);
}

.sidebar-nav .nav-item {
  border-radius: 8px;
  border-left: 2px solid transparent;
  padding-left: 10px;
}
.sidebar-nav .nav-item:hover { background: #F3F4F6; }
.sidebar-nav .nav-item.active {
  background: #F4F6F8;
  color: var(--text);
  font-weight: 600;
  box-shadow: none;
  border-left-color: var(--sidebar-accent);
}
.sidebar-nav .nav-item.active .nav-icon-wrap { color: var(--sidebar-accent); }
.nav-icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: #64748b;
}
.sidebar-footer .user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-footer .user-org {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-settings-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin-top: 8px;
  border-radius: 8px;
  font-size: 13px;
  color: #4b5563;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  font-family: inherit;
  text-align: left;
  transition: background .12s;
}
.sidebar-settings-link:hover { background: #F3F4F6; color: var(--text); }
.sidebar-settings-link.active {
  background: #F4F6F8;
  border-left: 2px solid var(--sidebar-accent);
  font-weight: 600;
}

.page-header-bar {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 32px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}
.page-header-text { flex: 1; min-width: 0; }
.page-header-title {
  font-size: 26px;
  font-weight: 650;
  color: var(--navy);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.page-header-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.5;
  max-width: 640px;
}
.page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.header-search { position: relative; min-width: 220px; max-width: 320px; }
.header-search input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #FAFBFC;
  font: inherit;
  font-size: 13px;
  outline: none;
}
.header-search input:focus {
  border-color: #C5D4E8;
  box-shadow: 0 0 0 3px rgba(10, 102, 194, 0.08);
  background: #fff;
}
.header-search .header-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
}
.header-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #475569;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  position: relative;
}
.header-icon-btn:hover { background: #FAFBFC; border-color: #D1D5DB; }
.header-icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.header-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}
.header-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border: none;
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.header-btn-primary:hover { opacity: .9; }
.header-dropdown { position: relative; }
.header-dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  padding: 4px;
  z-index: 30;
}
.header-dropdown.open .header-dropdown-menu { display: block; }
.header-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: none;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}
.header-dropdown-item:hover { background: #F4F6F8; }

.topbar { display: none !important; }
.page .legacy-page-header { display: none !important; }

#page-workspace { padding: 24px 32px 32px; max-width: 1200px; }
.ws-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.ws-metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.ws-metric-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.ws-metric-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #F4F6F8;
  color: #64748b;
}
.ws-metric-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.ws-metric-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
}
.ws-metric-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }
.ws-row-2 {
  display: grid;
  grid-template-columns: 1.85fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.ws-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.ws-panel.card { padding: 0; overflow: hidden; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
}
.section-header-title { font-size: 15px; font-weight: 650; color: var(--navy); }
.section-header-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}
.section-body { padding: 4px 18px 16px; }

.inbox-filters { display: flex; gap: 4px; padding: 12px 18px 0; flex-wrap: wrap; }
.inbox-filter-btn {
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}
.inbox-filter-btn.active {
  color: var(--text);
  background: #F4F6F8;
  border-color: var(--line);
  font-weight: 600;
}
.priority-inbox-list { list-style: none; }
.priority-inbox-item {
  display: flex;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  align-items: flex-start;
}
.priority-inbox-item:last-child { border-bottom: none; }
.priority-inbox-item:hover { background: #FAFBFC; }
.priority-inbox-item.is-unread .priority-inbox-title { font-weight: 650; }
.priority-inbox-item.is-read .priority-inbox-title { color: #64748b; }
.priority-inbox-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #F4F6F8;
  color: #64748b;
  flex-shrink: 0;
}
.priority-inbox-body { flex: 1; min-width: 0; }
.priority-inbox-title { font-size: 13px; color: var(--text); line-height: 1.4; }
.priority-inbox-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.priority-inbox-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 11px;
  color: #94a3b8;
  flex-wrap: wrap;
}
.priority-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; margin-top: 8px; }
.priority-dot.high { background: var(--danger); }
.priority-dot.medium { background: var(--warning); }
.priority-dot.normal { background: transparent; }

.quick-action-list { list-style: none; padding: 8px 12px 12px; }
.quick-action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.quick-action-btn:hover { background: #FAFBFC; border-color: #D1D5DB; }
.quick-action-btn .qa-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #F4F6F8;
  color: #64748b;
}

.ws-activity-item {
  display: flex;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.ws-activity-item:last-child { border-bottom: none; }
.ws-activity-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #F4F6F8;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  flex-shrink: 0;
}
.ws-activity-title { font-size: 13px; color: var(--text); line-height: 1.4; }
.ws-activity-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }

.ws-app-list { list-style: none; }
.ws-app-card-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.ws-app-card-item:last-child { border-bottom: none; }
.ws-app-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #F4F6F8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #475569;
  flex-shrink: 0;
}
.ws-app-card-name { font-size: 13px; font-weight: 650; color: var(--navy); }
.ws-app-card-desc { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.45; }
.ws-app-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}
.ws-app-status { font-size: 11px; color: var(--success); font-weight: 600; }
.ws-app-open {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.ws-skeleton {
  background: linear-gradient(90deg, #F0F1F3 25%, #E8EAED 50%, #F0F1F3 75%);
  background-size: 200% 100%;
  animation: ws-shimmer 1.2s infinite;
  border-radius: 6px;
  height: 80px;
}
@keyframes ws-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.ws-empty { padding: 32px 18px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.6; }
.ws-empty-title { font-weight: 600; color: var(--text); margin-bottom: 4px; }
.ws-error { padding: 16px 18px; color: var(--danger); font-size: 13px; }
.ws-ai-brief { margin-top: 16px; display: none; }
.ws-ai-brief.visible { display: block; }

/* Role gates — hide write/owner controls until session role is applied */
body:not(.portal-role-write) [data-write-only],
body:not(.portal-role-owner) [data-owner-only] {
  display: none !important;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 49;
}
.sidebar-backdrop.visible { display: block; }
body.sidebar-open { overflow: hidden; }

/* Installed Apps hub (Phase 3) */
#page-marketplace { padding: 20px 32px 32px; }
.apps-page-summary {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 16px 20px;
  margin-bottom: 20px;
}
.apps-summary-stat { font-size: 13px; color: var(--muted); }
.apps-summary-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy, #0f172a);
  margin-right: 6px;
}
.apps-summary-divider {
  width: 1px;
  height: 28px;
  background: var(--line);
}
.apps-summary-note {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  max-width: 320px;
  line-height: 1.5;
}
.apps-page-section { margin-bottom: 28px; }
.apps-section-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.apps-section-title {
  font-size: 15px;
  font-weight: 650;
  color: var(--text);
  margin: 0;
}
.apps-section-hint { font-size: 12px; color: var(--muted); }
.apps-search-bar { padding: 12px 14px; margin-bottom: 12px; }
.app-status-pill {
  font-size: 10px;
  font-weight: 650;
  padding: 2px 8px;
  border-radius: 10px;
}
.app-status-pill.installed { background: #EAF3DE; color: #3B6D11; }
.app-status-pill.available { background: #F3F4F6; color: #64748b; }
.app-owner-note { font-size: 10px; color: var(--muted); }
.app-remove-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}
.app-remove-btn:hover { border-color: #fca5a5; color: #b91c1c; }
.app-action { gap: 8px; flex-wrap: wrap; }

@media (max-width: 960px) {
  .ws-metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .ws-row-2, .ws-row-3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .page-header-bar { padding: 14px; flex-wrap: wrap; }
  .page-header-title { font-size: 22px; }
  .header-search { min-width: 100%; order: 3; }
  #page-workspace { padding: 16px 14px 24px; }
  .mobile-menu { display: flex !important; }
}
.mobile-menu {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  flex-shrink: 0;
}
