/* ==========================================================================
   COMPONENTS.CSS - DISCREET AZEO SÀRL CREDIT & SIDEBAR COMPONENTS
   ========================================================================== */

.app-layout {
  display: flex;
  min-height: 100vh;
  background-color: var(--bg-primary);
}

.sidebar {
  width: 250px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.25rem 0.75rem;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s ease;
}

.sidebar.collapsed, .sidebar.locked-closed {
  width: 68px;
  padding: 1.25rem 0.5rem;
}

.sidebar.collapsed .sidebar-text,
.sidebar.collapsed .brand-title,
.sidebar.collapsed .sidebar-section-title,
.sidebar.collapsed .user-info,
.sidebar.collapsed .credit-azeo,
.sidebar.locked-closed .sidebar-text,
.sidebar.locked-closed .brand-title,
.sidebar.locked-closed .sidebar-section-title,
.sidebar.locked-closed .user-info,
.sidebar.locked-closed .credit-azeo {
  display: none !important;
}

.sidebar.collapsed .sidebar-header,
.sidebar.locked-closed .sidebar-header { justify-content: center; }

.sidebar.collapsed .sidebar-link,
.sidebar.locked-closed .sidebar-link { justify-content: center; padding: 0.75rem; }

/* DISCREET FINE & SMALL AZEO SÀRL CREDIT */
.credit-azeo {
  font-size: 0.575rem;
  font-weight: 400;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  opacity: 0.45;
  text-align: center;
  padding-top: 0.25rem;
  transition: opacity 0.15s ease;
}

.credit-azeo:hover {
  opacity: 0.8;
}

/* Pastille 4h */
.sidebar-link-wrapper { position: relative; }

.nav-pastille {
  position: absolute;
  left: 48px;
  top: 24px;
  background-color: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color-strong);
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.725rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transform: translate(-4px, -4px) scale(0.92);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 100;
}

.sidebar.collapsed .sidebar-link-wrapper:hover .nav-pastille,
.sidebar.locked-closed .sidebar-link-wrapper:hover .nav-pastille {
  opacity: 1;
  transform: translate(0, 0) scale(1);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.5rem 1.25rem 0.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1rem;
}

.brand-title { font-size: 1.125rem; font-weight: 700; color: var(--text-primary); }

.sidebar-section-title {
  font-size: 0.675rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.08em; padding: 0.625rem 0.5rem 0.25rem 0.5rem;
}

.sidebar-menu { list-style: none; display: flex; flex-direction: column; gap: 0.25rem; }

.sidebar-link {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.625rem 0.75rem; border-radius: var(--radius-md); color: var(--text-secondary); font-weight: 500; font-size: 0.875rem; transition: all var(--transition-fast, 0.15s ease);
}

.sidebar-link:hover { background-color: var(--bg-card); color: var(--text-primary); }
.sidebar-link.active { background-color: var(--accent-muted); color: var(--accent-primary); border-left: 3px solid var(--accent-primary); font-weight: 600; }

.sidebar-footer { border-top: 1px solid var(--border-color); padding-top: 0.875rem; display: flex; flex-direction: column; gap: 0.5rem; position: relative; }

.sidebar-user-btn {
  display: flex; align-items: center; gap: 0.625rem; padding: 0.5rem 0.625rem; border-radius: var(--radius-md); background-color: var(--bg-card); border: 1px solid var(--border-color); cursor: pointer; width: 100%; transition: all var(--transition-fast, 0.15s ease);
}

.sidebar-user-btn:hover { border-color: var(--accent-primary); }

.sidebar-user-dropdown {
  position: absolute; left: 0; bottom: 115%; width: 240px; background-color: var(--bg-surface); border: 1px solid var(--border-color-strong); border-radius: var(--radius-lg); padding: 0.875rem; box-shadow: var(--shadow-lg); display: none; flex-direction: column; gap: 0.75rem; z-index: 120;
}

.sidebar-user-dropdown.active { display: flex; }

.user-avatar {
  width: 32px; height: 32px; border-radius: var(--radius-full); background-color: var(--accent-muted); border: 1px solid var(--accent-border); color: var(--accent-primary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8125rem; flex-shrink: 0;
}

.sidebar-bottom-toggle {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem; width: 100%; padding: 0.45rem 0.625rem; border-radius: var(--radius-md); background: transparent; border: 1px solid var(--border-color); color: var(--text-secondary); font-size: 0.75rem; font-weight: 600; cursor: pointer;
}

.mobile-bottom-nav { display: none; }

@media (max-width: 768px) {
  .sidebar { display: none !important; }
  .mobile-bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: 58px; background-color: var(--bg-surface); border-top: 1px solid var(--border-color); z-index: 70; justify-content: space-around; align-items: center; padding: 0 0.5rem; }
  .mobile-nav-item { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; color: var(--text-muted); font-size: 0.65rem; font-weight: 600; }
  .mobile-nav-item.active { color: var(--accent-primary); }
  .page-container { padding-bottom: 5rem !important; }
}

.main-wrapper { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.top-header { height: 3.75rem; background-color: var(--bg-surface); border-bottom: 1px solid var(--border-color); display: flex; align-items: center; justify-content: space-between; padding: 0 1.25rem; }
.theme-options-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.375rem; background-color: var(--bg-card); padding: 0.25rem; border-radius: var(--radius-md); border: 1px solid var(--border-color); }
.theme-opt-btn { padding: 0.375rem; font-size: 0.725rem; font-weight: 600; border: none; background: transparent; color: var(--text-secondary); border-radius: var(--radius-sm); cursor: pointer; }
.theme-opt-btn.active { background-color: var(--accent-primary); color: var(--text-on-accent); }
.page-container { padding: 1.5rem; flex: 1; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.55rem 1.125rem; border-radius: var(--radius-md); font-weight: 600; font-size: 0.875rem; cursor: pointer; border: 1px solid transparent; }
.btn-primary { background-color: var(--accent-primary); color: var(--text-on-accent); }
.btn-secondary { background-color: var(--bg-card); color: var(--text-primary); border-color: var(--border-color); }
.btn-outline { background: transparent; color: var(--text-primary); border-color: var(--border-color-strong); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.775rem; }
.card { background-color: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 1.25rem 1.5rem; }
.stat-card { background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 1rem 1.125rem; }
.stat-header { font-size: 0.8125rem; color: var(--text-secondary); }
.stat-value { font-size: 1.625rem; font-weight: 700; color: var(--text-primary); }
.stat-change { font-size: 0.75rem; font-weight: 600; color: var(--accent-primary); }
.table-container { width: 100%; overflow-x: auto; border: 1px solid var(--border-color); border-radius: var(--radius-md); background: var(--bg-surface); }
.data-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 0.875rem; }
.data-table th { background-color: var(--bg-card); color: var(--text-secondary); padding: 0.75rem 1rem; font-weight: 600; border-bottom: 1px solid var(--border-color); }
.data-table td { padding: 0.75rem 1rem; color: var(--text-primary); border-bottom: 1px solid var(--border-color); }
.form-input { width: 100%; padding: 0.5rem 0.875rem; background-color: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-md); color: var(--text-primary); outline: none; }
.form-select { width: 100%; padding: 0.5rem 0.875rem; background-color: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-md); color: var(--text-primary); outline: none; cursor: pointer; }
.form-label { font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.25rem; display: block; }
.form-group, .form-field { display: flex; flex-direction: column; gap: 0.25rem; }
.form-row { display: flex !important; align-items: flex-end !important; gap: 1rem !important; flex-wrap: wrap !important; margin-bottom: 0.5rem; }


/* Panel & Tabs component styling */
.panel { display: none !important; }
.panel.active { display: block !important; }

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.tab-btn:hover {
  background: var(--accent-muted);
  color: var(--accent-primary);
  border-color: var(--border-color-strong);
}
.tab-btn.active {
  background: var(--accent-primary) !important;
  color: var(--text-on-accent) !important;
  border-color: var(--accent-primary) !important;
  box-shadow: 0 4px 14px var(--accent-glow, rgba(16, 185, 129, 0.3));
}

/* Data Table Component Enhancements */
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background-color: var(--row-hover, rgba(255, 255, 255, 0.02)); }
select.mini { background-color: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 0.25rem 0.5rem; font-size: 0.8rem; }

/* ==========================================================================
   TITAN EXTENSIONS (3x3 MATRIX, CHART WRAPPERS & KPI TILES)
   ========================================================================== */
.grid-3x3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
}

@media (max-width: 1024px) {
  .grid-3x3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .grid-3x3 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
}

.chart-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chart-wrapper {
  position: relative;
  width: 100%;
  min-height: 240px;
  max-height: 380px;
}

.matrix-tile {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 130px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.matrix-tile:hover {
  border-color: var(--accent-border);
  transform: translateY(-2px);
}


/* ==========================================================================
   v1.1.0 - ADDITIVE ACCESSIBILITY & ROBUSTNESS LAYER (non-breaking)
   ========================================================================== */

:where(a, button, [role="button"], [tabindex]):focus-visible {
  outline: 2px solid var(--focus-ring, var(--accent-primary));
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.form-input:focus-visible,
.form-select:focus-visible,
select.mini:focus-visible {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.sidebar.collapsed .sidebar-link-wrapper:focus-within .nav-pastille,
.sidebar.locked-closed .sidebar-link-wrapper:focus-within .nav-pastille {
  opacity: 1;
  transform: translate(0, 0) scale(1);
}

@media (max-width: 768px) {
  .top-header > .top-header-search {
    width: auto !important;
    flex: 1 1 auto;
    min-width: 0;
    margin-right: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .sidebar-link, .sidebar-user-btn, .nav-pastille, .credit-azeo,
  .tab-btn, .matrix-tile, .theme-opt-btn, html, body {
    transition: none !important;
  }
  .matrix-tile:hover { transform: none; }
}


/* ==========================================================================
   v1.2.0 - INCLUDE CLASSES (replace former inline styles, identical rendering)
   ========================================================================== */

.sidebar-brand-link { display: flex; align-items: center; gap: 0.75rem; text-decoration: none; }
.sidebar-logo { border-radius: 6px; flex-shrink: 0; object-fit: contain; }
.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.sidebar-brand-name { font-size: 1.15rem; font-weight: 800; letter-spacing: 0.05em; color: var(--text-primary); }
.sidebar-brand-subtitle { font-size: 0.68rem; font-weight: 600; color: var(--text-muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.04em; }
.user-info-name { font-size: 0.8125rem; font-weight: 600; color: var(--text-primary); }
.user-info-sub { font-size: 0.7rem; color: var(--text-muted); }
.dropdown-user-name { font-weight: 700; font-size: 0.875rem; color: var(--text-primary); }
.dropdown-user-email { font-size: 0.75rem; color: var(--text-muted); }
.dropdown-section { border-top: 1px solid var(--border-color); padding-top: 0.5rem; }
.dropdown-section-title { font-size: 0.725rem; font-weight: 700; color: var(--text-muted); margin-bottom: 0.375rem; }
.dropdown-links { display: flex; flex-direction: column; gap: 0.375rem; }
.dropdown-link, .dropdown-link:hover { font-size: 0.8125rem; color: var(--text-primary); }
.dropdown-link-danger, .dropdown-link-danger:hover { color: var(--accent-subtle-red, #ef4444); }

.top-header-search { width: 320px; }
.top-header-left { min-width: 0; }
.top-header-title { font-size: 0.8125rem; color: var(--text-muted); }
.top-header-title strong { color: var(--text-primary); font-weight: 600; }
.top-header-actions { gap: 0.75rem; }


/* ==========================================================================
   v2.0.0 - VISUAL REFINEMENTS
   ========================================================================== */

.credit-azeo { font-size: 0.65rem; opacity: 0.7; }
.theme-opt-btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.3rem; }
.dropdown-link { display: inline-flex; align-items: center; gap: 0.45rem; }
.ui-icon { width: 14px; height: 14px; flex-shrink: 0; }
