/**
 * Santé Pro-RH - ERP Layout
 * Source de vérité: docs/design_system_santeprorh.v2.json
 * 
 * Layout ERP: sidebar/topbar/content
 * Usage: @import url('assets/css/sprh.erp.css');
 */

/* ===============================
   Base layout
   =============================== */

html,
body {
  height: 100%;
}

body.sprh-app {
  margin: 0;
  font-family: var(--sprh-font-sans);
  background: var(--sprh-bg);
  color: var(--sprh-text);
  font-size: var(--sprh-font-size-base);
  line-height: var(--sprh-line-height);
  --sprh-topbar-h: 64px;
  --sprh-sticky-offset: var(--sprh-topbar-h);
  --sprh-sidebar-w: 260px;
  --sprh-content-pad: var(--sprh-space-lg);
  --sprh-under-topbar-h: calc(var(--sprh-space-xl) * 2);
  --sprh-table-min-w: 960px;
  --sprh-table-min-w-dense: 1100px;
}

/* ===============================
   Shell
   =============================== */

.sprh-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.sprh-layout {
  display: flex;
  padding-top: var(--sprh-topbar-h);
  min-height: 100vh;
}

/* Legacy structure alias */
.app-layout {
  display: flex;
  padding-top: var(--sprh-topbar-h);
  min-height: 100vh;
}

/* ===============================
   Topbar
   =============================== */

.sprh-topbar,
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--sprh-topbar-h);
  background: var(--sprh-surface-elevated);
  border-bottom: 1px solid var(--sprh-border-subtle);
  box-shadow:
    inset 0 -2px 0 rgba(var(--sprh-primary-rgb), 0.18),
    0 1px 0 rgba(0, 0, 0, 0.02);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sprh-content-pad);
  z-index: 1000;
}

.sprh-topbar-left {
  display: flex;
  align-items: center;
  gap: var(--sprh-space-md);
}

.sprh-topbar-right {
  display: flex;
  align-items: center;
  gap: var(--sprh-space-sm);
}

.sprh-brand,
.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: var(--sprh-font-weight-bold);
  letter-spacing: 0.02em;
  color: var(--sprh-text);
  text-decoration: none;
}

.sprh-brand-mark,
.app-brand-mark {
  width: 42px;
  height: 42px;
  border-radius: var(--sprh-radius-lg);
  border: 1px solid var(--sprh-border);
  background: var(--sprh-surface);
  padding: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--sprh-primary);
}

.sprh-brand-mark img,
.app-brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: var(--sprh-radius-md);
  display: block;
}

.sprh-brand-text {
  font-size: var(--sprh-font-size-lg);
}

.sprh-user,
.app-user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sprh-text);
  font-weight: var(--sprh-font-weight-semibold);
}

.sprh-user i,
.app-user i {
  color: var(--sprh-muted);
  font-size: 1.1rem;
}

/* ===============================
   Sidebar
   =============================== */

.sprh-sidebar,
.app-sidebar {
  width: var(--sprh-sidebar-w);
  background: var(--sprh-primary-darker);
  color: rgba(255, 255, 255, 0.86);
  flex-shrink: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  position: fixed;
  top: var(--sprh-topbar-h);
  bottom: 0;
  left: 0;
  overflow-y: auto;
  z-index: 1050;
  transition: transform var(--sprh-duration) var(--sprh-easing);
}

.sprh-sidebar-overlay,
.sidebar-overlay {
  display: none;
}

.sprh-sidebar-brand,
.sidebar-brand {
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
}

.sprh-sidebar-brand img,
.sidebar-brand img {
  max-width: 170px;
  max-height: 42px;
  object-fit: contain;
}

.sprh-sidebar-brand-text,
.sidebar-brand-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--sprh-radius-full);
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--sprh-surface);
}

.sprh-sidebar .sprh-nav,
.app-sidebar .nav {
  padding: 12px 10px 18px;
}

.sprh-sidebar .sprh-nav-link,
.app-sidebar .nav-link {
  color: rgba(255, 255, 255, 0.86);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--sprh-radius-lg);
  margin: 2px 0;
  text-decoration: none;
  transition: background var(--sprh-duration-fast) var(--sprh-easing);
}

.sprh-sidebar .sprh-nav-link i,
.app-sidebar .nav-link i {
  color: rgba(255, 255, 255, 0.75);
  font-size: 1.05rem;
}

.sprh-sidebar .sprh-nav-link:hover,
.app-sidebar .nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--sprh-surface);
  box-shadow: inset 3px 0 0 rgba(var(--sprh-primary-rgb), 0.35);
}

.sprh-sidebar .sprh-nav-link.active,
.app-sidebar .nav-link.active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--sprh-surface);
  box-shadow: inset 3px 0 0 rgba(var(--sprh-primary-rgb), 0.78);
}

.sprh-sidebar .sprh-submenu .sprh-nav-link,
.app-sidebar .submenu .nav-link {
  padding-left: 34px;
  font-size: var(--sprh-font-size-sm);
}

.sprh-sidebar .sprh-nav-link.disabled {
  opacity: 0.55;
  pointer-events: none;
}

.sprh-sidebar .sprh-nav-section {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 14px 12px 6px;
  margin-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sprh-sidebar-badge {
  background: rgba(255, 255, 255, 0.18);
  color: var(--sprh-surface);
  font-weight: var(--sprh-font-weight-bold);
  font-size: 0.72rem;
  border-radius: var(--sprh-radius-full);
  padding: 2px 8px;
}

/* ===============================
   Content area
   =============================== */

.sprh-content {
  width: 100%;
  min-width: 0;
}

.app-content {
  flex: 1;
  padding: var(--sprh-content-pad);
  background: var(--sprh-bg);
  margin-left: var(--sprh-sidebar-w);
  min-width: 0;
  min-height: calc(100vh - var(--sprh-topbar-h));
  position: relative;
}

/* ===============================
   Alignment (desktop sidebar visible)
   =============================== */

@media (min-width: 992px) {
  body.sprh-app .sprh-topbar,
  body.sprh-app .app-header {
    left: var(--sprh-sidebar-w);
    padding-left: var(--sprh-content-pad);
    padding-right: var(--sprh-content-pad);
  }

  body.sprh-app .sprh-sidebar,
  body.sprh-app .app-sidebar {
    top: 0;
  }
}

@media (min-width: 1200px) {
  body.sprh-app {
    --sprh-content-pad: var(--sprh-space-xl);
  }
}

/* Subtle institutional band under topbar (no gradients) */
body.sprh-app .app-content::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--sprh-under-topbar-h);
  background: rgba(var(--sprh-primary-rgb), 0.06);
  border-bottom: 1px solid rgba(var(--sprh-primary-rgb), 0.08);
  pointer-events: none;
  z-index: 0;
}

body.sprh-app .app-content > * {
  position: relative;
  z-index: 1;
}

/* ===============================
   Reader mode (LMS lesson)
   =============================== */

body.reader-mode .app-header,
body.reader-mode .app-sidebar {
  display: none !important;
}

body.reader-mode .app-layout {
  padding-top: 0;
}

body.reader-mode .app-content {
  margin-left: 0;
  padding: var(--sprh-space-lg);
  min-height: 100vh;
}

/* ===============================
   Footer
   =============================== */

.sprh-footer,
.app-footer {
  background: var(--sprh-primary-darker);
  color: rgba(255, 255, 255, 0.86);
  padding: 10px 0;
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* ===============================
   Filters / Toolbar
   =============================== */

.sprh-filters {
  background: var(--sprh-surface);
  border: 1px solid var(--sprh-border);
  border-radius: var(--sprh-radius-xl);
  padding: var(--sprh-space-md);
  margin-bottom: var(--sprh-space-md);
}

.sprh-filters .sprh-input,
.sprh-filters .sprh-select {
  min-height: 42px;
}

.sprh-actions {
  display: flex;
  align-items: center;
  gap: var(--sprh-space-sm);
  flex-wrap: wrap;
}

.sprh-actions > * {
  flex-shrink: 0;
}

/* ===============================
   Responsive
   =============================== */

@media (max-width: 991px) {
  body.sprh-app {
    --sprh-content-pad: var(--sprh-space-md);
  }

  .sprh-sidebar,
  .app-sidebar {
    transform: translateX(-100%);
  }

  .sprh-sidebar.show,
  .app-sidebar.show {
    transform: translateX(0);
  }

  .app-content {
    margin-left: 0;
    padding: var(--sprh-content-pad);
  }

  .sprh-sidebar-overlay,
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--sprh-duration) var(--sprh-easing), 
                visibility var(--sprh-duration) var(--sprh-easing);
  }

  .sprh-sidebar-overlay.show,
  .sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  body.sprh-sidebar-open,
  body.app-sidebar-open {
    overflow: hidden;
  }
}

/* ===============================
   Utility classes for ERP
   =============================== */

.sprh-row-clickable {
  cursor: pointer;
}

.sprh-text-muted {
  color: var(--sprh-muted) !important;
}

.sprh-text-success {
  color: var(--sprh-success) !important;
}

.sprh-text-warning {
  color: var(--sprh-warning) !important;
}

.sprh-text-danger {
  color: var(--sprh-danger) !important;
}

.sprh-bg-surface {
  background: var(--sprh-surface);
}

.sprh-bg-surface-alt {
  background: var(--sprh-surface-alt);
}

/* Card variants */
.sprh-card-hover:hover {
  box-shadow: var(--sprh-shadow-hover);
}

/* Icon button */
.sprh-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--sprh-radius-md);
  border: none;
  background: transparent;
  color: var(--sprh-muted);
  cursor: pointer;
  transition: all var(--sprh-duration-fast) var(--sprh-easing);
}

.sprh-icon-btn:hover {
  background: rgba(var(--sprh-muted-rgb), 0.08);
  color: var(--sprh-text);
}

/* Empty state */
.sprh-empty {
  text-align: center;
  padding: var(--sprh-space-2xl) var(--sprh-space-md);
  color: var(--sprh-muted);
}

.sprh-empty-icon {
  font-size: 3rem;
  margin-bottom: var(--sprh-space-md);
  opacity: 0.5;
}

/* Loading */
.sprh-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sprh-space-2xl);
}

.sprh-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--sprh-border);
  border-top-color: var(--sprh-primary);
  border-radius: var(--sprh-radius-full);
  animation: sprh-spin 0.8s linear infinite;
}

@keyframes sprh-spin {
  to { transform: rotate(360deg); }
}
