/* ==========================================================================
   SHAREABLES WORKSPACE - Modern Fluent 2.0 Design System & Global Styles
   ========================================================================== */

:root {
  /* Color Palette - Fluent Core */
  --primary: #0078d4;
  --primary-hover: #106ebe;
  --primary-active: #005a9e;
  --primary-light: #eff6fc;
  --primary-alpha: rgba(0, 120, 212, 0.12);
  
  --onenote-purple: #7719aa;
  --onenote-purple-light: #f3e5f5;
  --sharepoint-teal: #00758f;
  --sharepoint-teal-light: #e0f2f1;

  /* Theme: Light Defaults */
  --bg-app: #f5f6f8;
  --bg-surface: #ffffff;
  --bg-surface-secondary: #fbfbfc;
  --bg-surface-tertiary: #f0f2f5;
  --bg-elevated: #ffffff;
  --bg-acrylic: rgba(255, 255, 255, 0.82);
  --bg-hover: rgba(0, 0, 0, 0.04);
  --bg-active: rgba(0, 0, 0, 0.08);

  --text-primary: #242424;
  --text-secondary: #616161;
  --text-tertiary: #8a8a8a;
  --text-disabled: #bebebe;
  --text-on-accent: #ffffff;

  --border-subtle: #edebe9;
  --border-default: #e0e0e0;
  --border-strong: #8a8886;
  --divider: #f0f0f0;

  /* Status Colors */
  --status-success: #107c41;
  --status-success-bg: #dff6dd;
  --status-warning: #797775;
  --status-warning-alt: #d83b01;
  --status-warning-bg: #fff4ce;
  --status-danger: #d13438;
  --status-danger-bg: #fde7e9;
  --status-info: #0078d4;
  --status-info-bg: #eff6fc;

  /* Demo Badge Colors */
  --demo-badge-bg: rgba(119, 25, 170, 0.12);
  --demo-badge-text: #7719aa;
  --demo-badge-border: rgba(119, 25, 170, 0.25);

  /* Shadows & Elevation */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04), 0 0 1px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 0 1px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12), 0 0 2px rgba(0, 0, 0, 0.14);
  --shadow-flyout: 0 16px 36px rgba(0, 0, 0, 0.16), 0 0 2px rgba(0, 0, 0, 0.2);

  /* Typography */
  --font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', sans-serif;
  --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;

  /* Layout Dimensions */
  --topbar-height: 48px;
  --primary-rail-width: 58px;
  --secondary-sidebar-width: 290px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
  --transition-fast: 0.15s cubic-bezier(0.33, 1, 0.68, 1);
  --transition-normal: 0.25s cubic-bezier(0.33, 1, 0.68, 1);
}

/* Dark Theme Overrides */
[data-theme="dark"] {
  --bg-app: #121214;
  --bg-surface: #1e1e20;
  --bg-surface-secondary: #252528;
  --bg-surface-tertiary: #2d2d31;
  --bg-elevated: #28282c;
  --bg-acrylic: rgba(30, 30, 32, 0.85);
  --bg-hover: rgba(255, 255, 255, 0.07);
  --bg-active: rgba(255, 255, 255, 0.12);

  --text-primary: #f3f3f3;
  --text-secondary: #c4c4c8;
  --text-tertiary: #8f8f94;
  --text-disabled: #555555;
  --text-on-accent: #ffffff;

  --border-subtle: #2d2d30;
  --border-default: #3e3e44;
  --border-strong: #606068;
  --divider: #26262a;

  --status-success-bg: rgba(16, 124, 65, 0.25);
  --status-warning-bg: rgba(216, 59, 1, 0.25);
  --status-danger-bg: rgba(209, 52, 56, 0.25);
  --status-info-bg: rgba(0, 120, 212, 0.25);

  --demo-badge-bg: rgba(168, 85, 247, 0.2);
  --demo-badge-text: #c084fc;
  --demo-badge-border: rgba(168, 85, 247, 0.4);

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.65);
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-app);
  -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: transparent;
  outline: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

/* ==========================================================================
   APP SHELL LAYOUT
   ========================================================================== */

#app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* TOP NAVIGATION BAR */
.top-header {
  height: var(--topbar-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  z-index: 100;
  backdrop-filter: blur(12px);
  user-select: none;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.waffle-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 18px;
}
.waffle-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
}

.brand-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: linear-gradient(135deg, #0078d4 0%, #7719aa 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  box-shadow: 0 2px 6px rgba(0, 120, 212, 0.35);
  overflow: hidden;
}

.brand-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-title {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-pill {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--primary-alpha);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

/* Space Switcher */
.space-switcher-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-secondary);
}
.space-switcher-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-default);
}

/* Center Global Search Bar */
.header-center {
  flex: 1;
  max-width: 520px;
  margin: 0 20px;
}

.global-search-trigger {
  width: 100%;
  height: 32px;
  background-color: var(--bg-surface-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  transition: all var(--transition-fast);
}
.global-search-trigger:hover {
  background-color: var(--bg-surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary-alpha);
  color: var(--text-primary);
}
.search-shortcut {
  margin-left: auto;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background-color: var(--border-subtle);
  color: var(--text-tertiary);
  font-weight: 600;
}

/* Header Right Actions */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quick-new-btn {
  background: var(--primary);
  color: #fff;
  padding: 0 14px;
  height: 30px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 13px;
  gap: 6px;
}
.quick-new-btn:hover {
  background: var(--primary-hover);
  box-shadow: 0 2px 6px rgba(0, 120, 212, 0.3);
}

.presence-cluster {
  display: flex;
  align-items: center;
  margin: 0 4px;
}

.presence-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--bg-surface);
  margin-left: -6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  position: relative;
  transition: transform 0.2s;
  cursor: pointer;
}
.presence-avatar:hover {
  transform: translateY(-2px) scale(1.1);
  z-index: 10;
}

.header-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 16px;
}
.header-icon-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.user-profile-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0078d4, #107c41);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  margin-left: 4px;
}

/* ==========================================================================
   WORKSPACE BODY (Primary Rail + Secondary Sidebar + Main Stage)
   ========================================================================== */

.workspace-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* Primary Left Navigation Rail */
.primary-rail {
  width: var(--primary-rail-width);
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
  gap: 4px;
  z-index: 20;
}

.rail-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-secondary);
  font-size: 18px;
  position: relative;
  transition: all var(--transition-fast);
}

.rail-btn .rail-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: -0.1px;
}

.rail-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.rail-btn.active {
  background-color: var(--primary-alpha);
  color: var(--primary);
  font-weight: 600;
}

.rail-btn.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background-color: var(--primary);
  border-radius: 0 4px 4px 0;
}

.rail-divider {
  width: 32px;
  height: 1px;
  background-color: var(--border-subtle);
  margin: 6px 0;
}

.rail-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

/* Secondary Navigation Sidebar */
.secondary-sidebar {
  width: var(--secondary-sidebar-width);
  background-color: var(--bg-surface-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition-normal);
  user-select: none;
  z-index: 15;
}

.sidebar-header {
  height: 48px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}

.sidebar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sidebar-icon-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
}
.sidebar-icon-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-search-box {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-search-input {
  width: 100%;
  height: 28px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0 8px 0 26px;
  font-size: 12px;
  outline: none;
}
.sidebar-search-input:focus {
  border-color: var(--primary);
}

.sidebar-search-wrapper {
  position: relative;
}
.sidebar-search-wrapper .search-icon {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

/* Main Workspace Viewport / Stage */
.main-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-app);
  position: relative;
}

/* Stage Header Bar */
.stage-header {
  height: 48px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 10;
}

.stage-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.stage-breadcrumbs .crumb-link {
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
}
.stage-breadcrumbs .crumb-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

.stage-breadcrumbs .crumb-active {
  color: var(--text-primary);
  font-weight: 600;
}

.stage-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stage-btn {
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  gap: 6px;
}
.stage-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-default);
}
.stage-btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.stage-btn.primary:hover {
  background: var(--primary-hover);
}

/* Stage Content Viewport */
.stage-body {
  flex: 1;
  overflow-y: auto;
  position: relative;
}

/* Helper Utilities */
.hidden {
  display: none !important;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
}

.badge-blue { background: #e0f2fe; color: #0284c7; }
.badge-purple { background: #f3e8ff; color: #9333ea; }
.badge-green { background: #dcfce7; color: #16a34a; }
.badge-amber { background: #fef3c7; color: #d97706; }
.badge-red { background: #fee2e2; color: #dc2626; }

.badge-demo {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background-color: var(--demo-badge-bg);
  color: var(--demo-badge-text);
  border: 1px solid var(--demo-badge-border);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
