/* contexte SaaS : padding latéral du contenu principal, polices légèrement réduites */
.saas-embed {
	font-size: 91%;
}
.saas-embed .table {
	font-size: 100%;
}

body.capwise-saas {
	margin: 0;
	display: flex;
	min-height: 100vh;
	font-family: system-ui, sans-serif;
}

.saas-sidebar {
	width: 260px;
	background: #0e2141;
	color: #f9fafb;
	padding: 16px;
	flex-shrink: 0;
	position: fixed;
	top: 0;
	left: 0;
	height: 100vh;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	z-index: 1000;
}

.saas-content {
	flex: 1;
	min-width: 0;
	padding: 22px 53px;
	margin-left: 260px;
}

.sidebar-logo {
	margin-bottom: 24px;
}
.sidebar-logo img {
	max-width: 140px;
	height: auto;
	display: block;
}

.sidebar-nav {
	flex: 1;
	overflow-y: auto;
	min-height: 0;
}

.sidebar-empty {
	color: #9ca3af;
	font-size: 0.875rem;
}

.sidebar-section-label {
	font-size: 0.7rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: #7a8696;
	padding: 0 4px;
	margin-bottom: 2px;
}

.sidebar-org-name {
	font-size: 0.875rem;
	color: #d1d5db;
	padding: 4px 4px;
}

.sidebar-super-admin-badge {
	display: inline-block;
	align-self: flex-start;
	background: #3b5578;
	color: #e5edf7;
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	padding: 3px 8px;
	border-radius: 4px;
	margin-bottom: 4px;
}

.sidebar-org-select {
	background-color: #17305a;
	color: #f9fafb;
	border: 1px solid #2a4470;
	font-size: 0.875rem;
}
.sidebar-org-select:focus {
	background-color: #17305a;
	color: #f9fafb;
	border-color: #4a7ac4;
	box-shadow: 0 0 0 0.15rem rgba(74, 122, 196, 0.25);
}
.sidebar-org-select option {
	background-color: #0e2141;
	color: #f9fafb;
}

.sidebar-link {
	display: block;
	padding: 5px 4px;
	font-size: 0.875rem;
	color: #d1d5db;
	text-decoration: none;
	border-radius: 4px;
}

.sidebar-link:hover {
	background: #374151;
	color: #f9fafb;
}

.sidebar-link-active {
	color: #f9fafb;
	font-weight: 600;
	pointer-events: none;
}

/* ── Companies ──────────────────────────────────────────────────────────── */

.sidebar-company {
	margin-bottom: 2px;
}

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

.sidebar-company-toggle {
	background: none;
	border: none;
	color: #6b7280;
	padding: 4px 2px;
	cursor: pointer;
	font-size: 0.65rem;
	line-height: 1;
	flex-shrink: 0;
}

.sidebar-company-toggle:hover {
	color: #d1d5db;
}

.sidebar-chevron {
	display: inline-block;
	transition: transform 0.45s ease;
}

.sidebar-company.is-expanded .sidebar-chevron {
	transform: rotate(90deg);
}

.sidebar-company-name {
	flex: 1;
	min-width: 0;
	font-size: 0.875rem;
	color: #d1d5db;
	text-decoration: none;
	padding: 4px 4px;
	border-radius: 4px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	display: block;
}

.sidebar-company-name:hover {
	background: #374151;
	color: #f9fafb;
}

.sidebar-company-name-active {
	color: #f9fafb;
	font-weight: 600;
}

@keyframes cw-sidebar-expand {
	from { max-height: 0; opacity: 0; }
	to   { max-height: 220px; opacity: 1; }
}

@keyframes cw-sidebar-collapse {
	from { max-height: 220px; opacity: 1; }
	to   { max-height: 0; opacity: 0; }
}

.sidebar-company-tabs {
	padding-left: 6px;
	margin-left: 5px;  /* aligne la border avec le centre du chevron ▶ */
	border-left: 1px solid rgba(157, 180, 204, 0.45);
	overflow: hidden;
	max-height: 0;
	opacity: 0;
	margin-bottom: 0;
}

.sidebar-company.is-expanded .sidebar-company-tabs {
	max-height: 220px;
	opacity: 1;
	margin-bottom: 4px;
	animation: cw-sidebar-expand 0.42s ease forwards;
}

.sidebar-company.sidebar-no-anim .sidebar-company-tabs {
	animation: none !important;
}

.sidebar-company.is-collapsing .sidebar-company-tabs {
	animation: cw-sidebar-collapse 0.32s ease forwards;
}

.sidebar-tab-link {
	display: block;
	padding: 3px 4px;
	font-size: 0.875rem;
	color: #9ca3af;
	text-decoration: none;
	border-radius: 4px;
}

.sidebar-tab-link:hover {
	background: #374151;
	color: #f9fafb;
}

.sidebar-tab-link-active {
	color: #dae1ee;  /* bleu très clair — se distingue du nom de company active (blanc) */
	font-weight: 600;
	pointer-events: none;
}

.sidebar-new-company {
	color: #d1d5db;
	font-size: 0.875rem;
	padding: 4px;
}

.sidebar-new-company:hover {
	color: #f9fafb;
}

/* Empêche Bootstrap d'injecter un padding-right de compensation scrollbar sur la sidebar sticky */
.saas-sidebar { padding-right: 16px !important; }

/* Modal large mais pas fullscreen (laisse la sidebar visible sur grand écran) */
.capwise-saas .modal-dialog.saas-modal-wide {
	max-width: min(1600px, 95vw);
}

/* ── Custom use cases : badge sidebar (phase 9) ────────────────────────── */
/* Le tab-link devient flex : label prend l'espace restant (et peut wrapper),
   badge reste collé à droite aligné en haut même si le titre passe sur 2 lignes. */
.sidebar-tab-link-custom {
	display: flex;
	align-items: flex-start;
	gap: 7px;  /* ≈ largeur de `&nbsp;` + espace utilisée par les autres items */
}
.sidebar-tab-link-custom .sidebar-custom-badge {
	margin-left: 6px;  /* un peu d'air entre le texte et le badge */
}
.sidebar-custom-icon {
	flex: 0 0 auto;
	line-height: 1.3;
}
.sidebar-custom-label {
	flex: 1 1 auto;
	min-width: 0;
	/* Si le titre wrappe, la 2ème ligne démarre ici (après l'icône), donc alignée
	   avec le texte de la 1ère ligne — pas sous l'icône. */
}
.sidebar-custom-badge {
	flex: 0 0 auto;
	margin-top: 2px;
	padding: 1px 5px;
	font-size: 0.53rem;
	font-weight: 500;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: #1a2f52;
	background: #ffd166;
	border-radius: 4px;
	box-shadow: 0 0 0 1px rgba(255, 209, 102, 0.35);
}
.sidebar-tab-link-active .sidebar-custom-badge {
	color: #1a2f52;
	background: #ffdf8a;
	box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
}

/* Chevron inerte pour les use cases custom à plat : on reprend l'apparence de
   `.sidebar-company-toggle` (déjà stylé) mais on coupe l'interactivité pour que
   le triangle serve uniquement d'ancrage visuel aligné avec les companies. */
.sidebar-toggle-inert {
	cursor: default;
	display: inline-block;
}

/* ── Custom use cases embedés (phase 9) ────────────────────────────────── */
/* Le use case share/*.php émet une navbar fixed-top (render_header) qui sinon
   recouvrirait toute la viewport y compris la sidebar. On la recadre sur la
   zone saas-content. La navbar a z-index:1030 dans render-html-ui.php → on
   reste au-dessus du contenu sans masquer la sidebar (z-index:1000 mais
   fixed à left:0). */
.saas-content:has(.saas-custom-embed) {
	padding: 0;
}
.saas-custom-embed {
	padding: 78px 53px 22px;  /* top = hauteur navbar + marge ; sinon padding saas-content standard */
	min-height: 100vh;
}
.saas-custom-embed #main-nav.fixed-top {
	left: 260px;
	right: 0;
	width: auto;
}

/* ── Dashboard — org blocks ─────────────────────────────────────────────── */

.cw-dash-org-block {
	margin-bottom: 48px;
}

.cw-dash-org-block-multi + .cw-dash-org-block-multi {
	border-top: 1px solid #e5e7eb;
	padding-top: 40px;
}

.cw-dash-page-title {
	font-size: 1.3rem;
	font-weight: 500;
	color: #111827;
	margin-bottom: 12px;
}

.cw-dash-org-title {
	font-size: 1.1rem;
	font-weight: 600;
	color: #374151;
	margin-bottom: 16px;
}

/* ── Company cards ──────────────────────────────────────────────────────── */

.cw-company-card {
	transition: box-shadow .15s ease, border-color .15s ease;
	cursor: pointer;
	color: inherit;
}

.cw-company-card:hover {
	color: inherit;
	box-shadow: 0 4px 12px rgba(0,0,0,.12);
	border-color: #adb5bd;
}

/* Header Bootstrap card-header */

.cw-cc-header {
	display: flex;
	align-items: center;
	background: #f8f9fa;
	padding: 0.7rem 1rem;
}

.cw-cc-bldg-icon {
	opacity: 0.55;
	font-size: 1.1rem;
	flex-shrink: 0;
}

.cw-cc-name {
	font-size: 1.05rem;
	font-weight: 500;
	color: #0e2141;
	text-decoration: none;
}

.cw-cc-name:hover {
	color: #1d4ed8;
	text-decoration: underline;
}

/* Corps */

.cw-cc-body {
	display: flex;
	flex-direction: column;
	padding: 1rem;
}

/* Sections internes */

.cw-cc-section {
	margin-bottom: 14px;
}

.cw-cc-section-grow {
	flex: 1;
}

.cw-cc-section-label {
	font-size: 0.72rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .07em;
	color: #9ca3af;
	margin-bottom: 6px;
}

.cw-cc-empty {
	font-size: 0.875rem;
	color: #d1d5db;
	font-style: italic;
}

/* Instruments (cap table) */

.cw-cc-instr-row {
	display: flex;
	align-items: baseline;
	gap: 6px;
	margin-bottom: 4px;
}

.cw-cc-pill {
	font-size: 0.7rem;
	font-weight: 700;
	padding: 2px 6px;
	border-radius: 4px;
	flex-shrink: 0;
	letter-spacing: .03em;
}

.cw-cc-pill-ao  { background: #dbeafe; color: #1e40af; }
.cw-cc-pill-ap  { background: #ede9fe; color: #6d28d9; }
.cw-cc-pill-opt { background: #dcfce7; color: #166534; }

.cw-cc-instr-names {
	font-size: 0.875rem;
	color: #374151;
}

/* Positions */

.cw-cc-pos-row {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 4px;
	margin-bottom: 5px;
}

.cw-cc-pos-name {
	font-size: 0.9rem;
	font-weight: 600;
	color: #1f2937;
}

.cw-cc-pos-instruments {
	font-size: 0.85rem;
	color: #6b7280;
}

.cw-cc-pos-total {
	font-size: 0.85rem;
	color: #0e2141;
	font-weight: 500;
	margin-left: auto;
	white-space: nowrap;
}

/* Pied de card */

.cw-cc-footer {
	font-size: 0.78rem;
	color: #9ca3af;
	background: transparent;
	border-top: 1px solid #eaecee;
	padding-top: 0.35rem;
}

.cw-cc-body {
	padding-bottom: 0.25rem;
}

/* Carte "Nouvelle company" */

.cw-cc-new-card {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	min-height: 120px;
	border: 2px dashed #d1d5db !important;
	box-shadow: none !important;
	color: #9ca3af;
	text-decoration: none;
	gap: 8px;
	font-size: 0.95rem;
	background: #fff;
}

.cw-cc-new-card:hover {
	border-color: #6b7280 !important;
	color: #374151;
	background: #f9fafb;
}

.cw-cc-new-icon {
	font-size: 1.5rem;
}

/* ── Badges rôle membre ─────────────────────────────────────────────────── */

.cw-role-badge {
	display: inline-block;
	font-size: 0.7rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	padding: 0.28em 0.65em;
	border-radius: 6px;
	line-height: 1;
	vertical-align: middle;
}

.cw-role-badge-admin {
	background: rgba(13, 110, 253, 0.12);
	color: #0a58ca;
}

.cw-role-badge-user {
	background: rgba(25, 135, 84, 0.12);
	color: #146c43;
}

.cw-role-badge-guest {
	background: rgba(108, 117, 125, 0.12);
	color: #495057;
}

.cw-role-badge-me {
	background: rgba(25, 135, 84, 0.12);
	color: #146c43;
}

.cw-role-badge-danger {
	background: rgba(220, 53, 69, 0.12);
	color: #b02a37;
}

/* ── Lien admin org dans la sidebar ────────────────────────────────────── */

.sidebar-admin-link {
	margin-top: 4px;
	font-size: 0.8rem;
	color: #9ca3af !important;
	padding: 3px 4px;
}

.sidebar-admin-link:hover {
	color: #f9fafb !important;
}

.sidebar-admin-link.sidebar-link-active {
	color: #f9fafb !important;
}

/* ── Titre de page avec nom d'org ───────────────────────────────────────── */

.cw-org-page-title {
	font-size: 1.3rem;
	font-weight: 500;
	color: #111827;
	margin-bottom: 0;
	display: flex;
	align-items: center;
	gap: 0;
}

.cw-org-page-title-icon {
	opacity: 0.55;
	font-size: 1.15rem;
	margin-right: 0.5rem;
	flex-shrink: 0;
}

/* ── Logo sidebar cliquable ─────────────────────────────────────────────── */
/* Logo sidebar cliquable */

.sidebar-account-link {
	display: block;
	font-size: 0.875rem;
	word-break: break-all;
	color: #9db4cc;
	text-decoration: none;
	margin-bottom: 16px;
	padding-left: 0;
	text-align: left;
}

.sidebar-account-link:hover {
	color: #fff;
}

.sidebar-logo-link {
	display: block;
	transition: opacity .15s ease;
}

.sidebar-logo-link:hover {
	opacity: .85;
}
