/* ============================================
   BASE STYLES & RESET
   Finanzberatung CRM
   ============================================ */

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  letter-spacing: -0.01em;
}

/* Headings use display font for premium feel */
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }

/* Links */
a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-dark);
}

/* Focus states for accessibility */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-color: var(--primary);
}

/* ============ AUTH LOADING STATES ============ */
/* Hide app content until authentication completes */
body:not(.auth-ready) .header,
body:not(.auth-ready) .tabs,
body:not(.auth-ready) .content {
  visibility: hidden;
}

/* Role-restricted elements - hidden by default, shown only for owners */
.owner-only {
  display: none !important;
}

body.role-owner .owner-only,
body.is-unified.role-berater .owner-only {
  display: initial !important;
}

/* Specific element type overrides for owner-only */
body.role-owner button.owner-only,
body.is-unified.role-berater button.owner-only {
  display: inline-flex !important;
}

body.role-owner .tab.owner-only,
body.is-unified.role-berater .tab.owner-only {
  display: inline-block !important;
}

/* Lead creation - visible to owners AND enterprise members (berater/cmo in enterprise context) */
.can-create-lead {
  display: none !important;
}

body.role-owner .can-create-lead,
body.is-organization.role-berater .can-create-lead,
body.is-unified.role-berater .can-create-lead {
  display: initial !important;
}

body.role-owner button.can-create-lead,
body.is-organization.role-berater button.can-create-lead,
body.is-unified.role-berater button.can-create-lead {
  display: inline-flex !important;
}

/* Concepts access - visible to owners AND beraters (not assistants) */
.concepts-access {
  display: none !important;
}

body.role-owner .concepts-access,
body.role-ceo .concepts-access,
body.role-berater .concepts-access {
  display: initial !important;
}

body.role-owner button.concepts-access,
body.role-ceo button.concepts-access,
body.role-berater button.concepts-access {
  display: inline-flex !important;
}

body.role-owner .tab.concepts-access,
body.role-ceo .tab.concepts-access,
body.role-berater .tab.concepts-access,
body.role-assistant .tab.concepts-access {
  display: inline-block !important;
}

/* Settings button - visible to owners, beraters, and ceo_partners */
.settings-visible {
  display: none !important;
}

body.role-owner button.settings-visible,
body.role-berater button.settings-visible,
body.role-ceo button.settings-visible {
  display: inline-flex !important;
}

body.role-owner .tab.settings-visible,
body.role-berater .tab.settings-visible,
body.role-ceo .tab.settings-visible,
body.role-assistant .tab.settings-visible {
  display: inline-block !important;
}

/* CEO/Partner role — oversight + distribution only, cannot work leads */
/* CEO sees all leads, assigns beraters, manages members, sees analytics */
/* CEO gets .owner-only visibility for settings/member management */
body.role-ceo .owner-only {
  display: initial !important;
}

body.role-ceo button.owner-only {
  display: inline-flex !important;
}

body.role-ceo .tab.owner-only {
  display: inline-block !important;
}

/* CEO CAN create leads (in their enterprise) */
body.role-ceo .can-create-lead {
  display: initial !important;
}

body.role-ceo button.can-create-lead {
  display: inline-flex !important;
}

/* CEO cannot work leads — oversight + distribution only */
.can-work-lead {
  display: none !important;
}

body.role-owner .can-work-lead,
body.role-berater .can-work-lead,
body.role-assistant .can-work-lead {
  display: initial !important;
}

body.role-owner button.can-work-lead,
body.role-berater button.can-work-lead,
body.role-assistant button.can-work-lead {
  display: inline-flex !important;
}

body.role-owner div.can-work-lead,
body.role-berater div.can-work-lead,
body.role-assistant div.can-work-lead {
  display: block !important;
}

body.role-owner span.can-work-lead,
body.role-berater span.can-work-lead,
body.role-assistant span.can-work-lead {
  display: inline !important;
}

/* CEO: force-hide .can-work-lead even when combined with other visibility classes */
body.role-ceo .can-work-lead,
body.role-ceo button.can-work-lead,
body.role-ceo div.can-work-lead,
body.role-ceo span.can-work-lead {
  display: none !important;
}

/* Assistant role restrictions - hide create lead button and concepts tab */
body.role-assistant .can-create-lead {
  display: none !important;
}


/* Auto-assign button - visible to CEO/owner in org context */
.can-auto-assign {
  display: none !important;
}

body.role-ceo button.can-auto-assign,
body.role-owner.is-organization button.can-auto-assign,
body.role-owner.is-unified button.can-auto-assign,
body.role-berater button.can-auto-assign,
body.is-unified.role-berater button.can-auto-assign {
  display: inline-flex !important;
}

body.role-ceo span.can-auto-assign,
body.role-owner.is-organization span.can-auto-assign,
body.role-owner.is-unified span.can-auto-assign,
body.role-berater span.can-auto-assign,
body.is-unified.role-berater span.can-auto-assign {
  display: inline-block !important;
}

.header-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
}

/* Enterprise-only elements - visible only when body has .is-organization */
.organization-only {
  display: none !important;
}

body.is-organization .organization-only {
  display: initial !important;
}

/* Dev-only elements - hidden unless dev mode is enabled via localStorage */
.dev-only {
  display: none !important;
}

body.dev-mode .dev-only {
  display: initial !important;
}

body.dev-mode button.dev-only {
  display: inline-flex !important;
}

body.dev-mode .tab.dev-only {
  display: inline-block !important;
}

body.is-organization button.organization-only {
  display: inline-flex !important;
}

/* Pre-blur restricted elements for assistants before JS applies overlays */
body:not(.role-owner):not(.role-ceo):not(.role-berater) #activityConceptsCard,
body:not(.role-owner):not(.role-ceo):not(.role-berater) #revenueCard,
body:not(.role-owner):not(.role-ceo):not(.role-berater) #funnelFilterSection,
body:not(.role-owner):not(.role-ceo):not(.role-berater) #salesFunnelCard,
body:not(.role-owner):not(.role-ceo):not(.role-berater) #planningPipelineRatesBar,
body:not(.role-owner):not(.role-ceo):not(.role-berater) #planningPipelineCalculatorCard,
body:not(.role-owner):not(.role-ceo):not(.role-berater) #planningFilterSection,
body:not(.role-owner):not(.role-ceo):not(.role-berater) #topClientsCard,
body:not(.role-owner):not(.role-ceo):not(.role-berater) #leadSourcesCard {
  opacity: 0.08;
  pointer-events: none;
}

/* Analytics restrictions for assistants - show element but with restricted overlay */
.assistant-restricted {
  position: relative;
  pointer-events: none;
  user-select: none;
  opacity: 1 !important;
}

.assistant-restricted > *:not(.restricted-overlay) {
  opacity: 0.08;
  filter: blur(3px);
}

.restricted-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  pointer-events: none;
}

.restricted-overlay-label {
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  letter-spacing: 0.3px;
}

/* ============ UTILITY CLASSES ============ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
