/* App Layout (Option B+ base) */
:root{
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e5e7eb;
  --shadow: 0 6px 18px rgba(15,23,42,.08);
  --accent: #2563eb;
  --danger: #dc2626;
  --warn: #f59e0b;
}

*{box-sizing:border-box}
html,body{height:100%}
body.app-layout{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color:var(--text);
  background:var(--bg);
  display:flex;
  min-height:100vh;
}

/* Sidebar */
.sidebar{
  width:260px;
  background:#0b1220;
  color:#e5e7eb;
  padding:18px 14px;
  position:sticky;
  top:0;
  height:100vh;
}
.sidebar-title{
  font-weight:800;
  letter-spacing:.6px;
  padding:10px 10px 16px;
  font-size:18px;
}
.sidebar-nav{display:flex; flex-direction:column; gap:6px; padding:6px}
.sidebar-nav a{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 10px;
  border-radius:12px;
  color:#e5e7eb;
  text-decoration:none;
  opacity:.9;
}
.sidebar-nav a:hover{background:rgba(255,255,255,.08); opacity:1}
.sidebar-nav a.active{background:rgba(37,99,235,.22); border:1px solid rgba(37,99,235,.35); opacity:1}

/* Main */
.main-content{
  flex:1;
  padding:22px 26px;
  overflow:auto;
}

.page-header{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:16px;
  margin-bottom:14px;
}
.page-header h1{
  margin:0;
  font-size:22px;
}
.user-info{color:var(--muted); font-size:13px}

.dashboard-section{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:16px;
  box-shadow:var(--shadow);
  padding:14px 14px 8px;
}

/* Table */
.data-table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  margin-top:8px;
  font-size:13px;
}
.data-table th, .data-table td{
  padding:10px 10px;
  border-bottom:1px solid var(--border);
  vertical-align:top;
}
.data-table thead th{
  position:sticky;
  top:0;
  background: #fbfbfc;
  z-index:1;
  text-align:left;
  font-size:12px;
  color: #334155;
  letter-spacing:.3px;
}
.data-table tbody tr:hover{
  background:#f8fafc;
}
.data-table tbody tr:last-child td{border-bottom:0}

/* Responsive */
@media (max-width: 980px){
  .sidebar{width:220px}
}
@media (max-width: 820px){
  body.app-layout{display:block}
  .sidebar{position:relative; height:auto; width:auto}
  .main-content{padding:14px}
  .data-table thead th{position:static}
}


/* Hide top header on app-layout pages (we keep it in DOM for cloning) */
body.app-layout header.topbar{ display:none !important; }
body.app-layout .breadcrumbbar{ display:none !important; }

/* Sidebar cloned menus */
.sidebar.sidebar--auto{ padding:16px 12px; }
.sb-section{ margin-top:10px; }
.sb-section-btn{
  width:100%;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 10px;
  border-radius:12px;
  border:1px solid transparent;
  background:transparent;
  color:#e5e7eb;
  cursor:pointer;
  font:inherit;
  font-weight:700;
  letter-spacing:.2px;
}
.sb-section-btn:hover{ background:rgba(255,255,255,.08); }
.sb-section.open .sb-section-btn{
  background:rgba(255,255,255,.06);
  border-color:rgba(255,255,255,.10);
}
.sb-links{
  display:none;
  margin:6px 0 0 8px;
  padding-left:6px;
  border-left:1px solid rgba(255,255,255,.10);
}
.sb-section.open .sb-links{ display:block; }
.sb-links a{
  display:block;
  padding:8px 10px;
  border-radius:10px;
  color:#e5e7eb;
  text-decoration:none;
  opacity:.88;
  font-size:13px;
}
.sb-links a:hover{ background:rgba(255,255,255,.08); opacity:1; }
.sb-links a.active{ background:rgba(37,99,235,.22); border:1px solid rgba(37,99,235,.35); opacity:1; }
.sb-footer{
  margin-top:auto;
  padding:10px 6px 6px;
}
.sb-logout{
  display:flex;
  justify-content:center;
  padding:10px 12px;
  border-radius:12px;
  text-decoration:none;
  color:#e5e7eb;
  border:1px solid rgba(255,255,255,.14);
  background:rgba(255,255,255,.06);
}
.sb-logout:hover{ background:rgba(255,255,255,.10); }

/* Buttons */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:8px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background:#fff;
  color:var(--text);
  text-decoration:none;
  font-weight:800;
  font-size:13px;
}
.btn:hover{ background:#f8fafc; }
/* ===== SIDEBAR COLLAPSE FIX FINAL ===== */

.sidebar{
  transition: width 0.25s ease;
}

.sidebar.collapsed{
  width:70px;
}

/* Cache le titre TB-S */
.sidebar.collapsed .sb-title-text{
  display:none;
}

/* Cache les textes des sections */
.sidebar.collapsed .sb-section-btn span:first-child{
  display:none;
}

/* Cache les textes des liens */
.sidebar.collapsed .sb-links span{
  display:none;
}

/* Centre les icônes */
.sidebar.collapsed .sb-section-btn{
  justify-content:center;
}

.sidebar.collapsed .sb-links a{
  justify-content:center;
}

/* Cache footer */
.sidebar.collapsed .sb-footer{
  display:none;
}

/* ===== MODULE LEVEL (Maintenance / Qualité / Production) ===== */

.sb-module-content{
  display:none;
  margin-top:8px;
}

.sb-module.open .sb-module-content{
  display:block;
}

.sb-module-btn{
  width:100%;
  padding:12px;
  border-radius:12px;
  background:rgba(255,255,255,.06);
  color:#fff;
  border:none;
  text-align:left;
  font-weight:800;
  cursor:pointer;
  margin-top:8px;
}

.sb-module-btn:hover{
  background:rgba(255,255,255,.12);
}
/* ===== MAIN MODULES (Maintenance / Qualité / Production) ===== */

.sb-main-module {
  margin-bottom: 14px;
}

.sb-main-module > .sb-module-btn {
  width: 100%;
  padding: 14px 12px;
  font-size: 15px;
  font-weight: 800;
  border-radius: 14px;
  background: linear-gradient(145deg, #1e293b, #0f172a);
  border: 1px solid rgba(255,255,255,0.08);
  letter-spacing: .4px;
  transition: all 0.2s ease;
}

.sb-main-module > .sb-module-btn:hover {
  background: linear-gradient(145deg, #2563eb, #1d4ed8);
  transform: translateY(-1px);
}

.sb-main-module.open > .sb-module-btn {
  background: linear-gradient(145deg, #2563eb, #1d4ed8);
  box-shadow: 0 6px 20px rgba(37,99,235,0.35);
}