/* ==========================================================================
   JAMES BOT 1.0 - GLOBAL BASE DESIGN SYSTEM (global-base.css)
   Aesthetic: Deep Charcoal/Slate (#0d1117 / #0f172a) & Emerald (#10b981 / #059669)
   ========================================================================== */

:root,
[data-theme="dark"] {
  /* Cores Base - Dark Mode (Deep Charcoal & Emerald Accent) */
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --card-bg: #161b22;
  --card-hover-bg: #1c2128;
  --sidebar-bg: #161b22;
  --border-color: #30363d;
  --border-color-muted: rgba(48, 54, 61, 0.6);
  --text-primary: #f0f6fc;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  
  /* Cores de Ação e Marca (Emerald & System Statuses) */
  --primary-color: #10b981;
  --primary-hover: #059669;
  --primary-alpha: rgba(16, 185, 129, 0.18);
  --accent-green: #10b981;
  --success-color: #3fb950;
  --warning-color: #f59e0b;
  --danger-color: #f85149;
  --info-color: #3b82f6;
  --purple-color: #a855f7;

  /* Sidebar Tokens - Dark */
  --nav-item-color: #8b949e;
  --nav-item-icon-color: #8b949e;
  --nav-item-hover-bg: rgba(255, 255, 255, 0.06);
  --nav-item-hover-color: #f0f6fc;
  --nav-item-active-bg: rgba(16, 185, 129, 0.18);
  --nav-item-active-color: #10b981;

  /* UI/UX Pro Max Scale: Raios de Borda e Sombras */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 24px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
  /* Cores Base - Light Mode */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --card-bg: #ffffff;
  --card-hover-bg: #f1f5f9;
  --sidebar-bg: #ffffff;
  --border-color: #e2e8f0;
  --border-color-muted: #cbd5e1;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  /* Cores de Ação no Modo Claro */
  --primary-color: #059669;
  --primary-hover: #047857;
  --primary-alpha: rgba(5, 150, 105, 0.12);
  --accent-green: #10b981;
  --success-color: #10b981;
  --warning-color: #d97706;
  --danger-color: #dc2626;
  --info-color: #2563eb;
  --purple-color: #9333ea;

  /* Sidebar Tokens - Light */
  --nav-item-color: #334155;
  --nav-item-icon-color: #64748b;
  --nav-item-hover-bg: #f1f5f9;
  --nav-item-hover-color: #0f172a;
  --nav-item-active-bg: #e6f4ea;
  --nav-item-active-color: #005c4b;

  /* Sombras Light Mode */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.08);
}

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

html, body {
  width: 100%;
  height: 100%;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Layout Principal da Aplicação */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar Navegação Principal (Harmonizada com Dark / Light Mode) */
.sidebar,
.sidebar-header,
.sidebar-nav,
.sidebar-footer,
.sidebar-legal-footer {
  background-color: var(--sidebar-bg) !important;
  border-color: var(--border-color) !important;
}

.sidebar #providerBrandName {
  color: var(--text-primary) !important;
}

.sidebar .nav-section-title {
  color: var(--text-muted) !important;
  font-weight: 700 !important;
}

.sidebar .nav-item {
  color: var(--nav-item-color) !important;
}

.sidebar .nav-item .material-icons {
  color: var(--nav-item-icon-color) !important;
}

.sidebar .nav-item:hover {
  background-color: var(--nav-item-hover-bg) !important;
  color: var(--nav-item-hover-color) !important;
}

.sidebar .nav-item:hover .material-icons {
  color: var(--nav-item-hover-color) !important;
}

.sidebar .nav-item.active {
  background-color: var(--nav-item-active-bg) !important;
  color: var(--nav-item-active-color) !important;
  font-weight: 600 !important;
}

.sidebar .nav-item.active .material-icons {
  color: var(--nav-item-active-color) !important;
}

.sidebar .user-name {
  color: var(--text-primary) !important;
  font-weight: 600 !important;
}

.sidebar .btn-toggle-sidebar {
  color: var(--text-muted) !important;
}

.sidebar {
  width: 250px;
  min-width: 250px;
  height: 100%;
  border-right: 1px solid var(--border-color) !important;
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              min-width 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.28s ease;
  flex-shrink: 0;
}

/* ─── ESTADO COLAPSADO (desktop) ─────────────────────────── */
.sidebar.collapsed {
  width: 68px !important;
  min-width: 68px !important;
}

.sidebar.collapsed #providerBrandName,
.sidebar.collapsed #sidebarLogoContainer .version,
.sidebar.collapsed .nav-item span:not(.material-icons),
.sidebar.collapsed .sidebar-legal-footer,
.sidebar.collapsed .user-name,
.sidebar.collapsed #btnThemeToggleSidebar,
.sidebar.collapsed #logoutButtonSidebar {
  display: none !important;
}

/* Divisor elegante de 1px entre categorias no modo colapsado */
.sidebar.collapsed .nav-section-title {
  height: 1px !important;
  margin: 10px 10px !important;
  padding: 0 !important;
  font-size: 0 !important;
  line-height: 0 !important;
  background-color: #e2e8f0 !important;
  overflow: hidden !important;
}

.sidebar.collapsed .sidebar-header {
  justify-content: center !important;
  padding: 14px 6px !important;
}

.sidebar.collapsed #sidebarLogoContainer {
  justify-content: center !important;
  flex: none !important;
}

.sidebar.collapsed .provider-logo-brand-img {
  max-width: 36px !important;
  max-height: 36px !important;
}

.sidebar.collapsed .sidebar-nav {
  padding: 8px 6px !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

.sidebar.collapsed .nav-item {
  justify-content: center !important;
  padding: 10px 0 !important;
  gap: 0 !important;
  width: 100% !important;
  position: relative !important;
}

.sidebar.collapsed .nav-item .material-icons {
  margin: 0 !important;
  font-size: 22px !important;
}

.sidebar.collapsed .btn-toggle-sidebar .material-icons {
  transform: rotate(180deg);
}

/* ─── TOOLTIP NO MODO COLAPSADO ──────────────────────────── */
.sidebar.collapsed .nav-item::after {
  content: attr(title);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%) translateX(-6px);
  background: #0f172a;
  color: #f8fafc;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 300;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.sidebar.collapsed .nav-item:hover::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* ─── OVERLAY MOBILE ─────────────────────────────────────── */
#sidebarOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 190;
  opacity: 0;
  transition: opacity 0.28s ease;
}

#sidebarOverlay.active {
  display: block;
  opacity: 1;
}

/* ─── BOTÃO HAMBURGER MOBILE ─────────────────────────────── */
#btnHamburgerMobile {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 300;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #334155;
  transition: all 0.15s ease;
}

#btnHamburgerMobile:hover {
  background: #f1f5f9;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

#btnHamburgerMobile .material-icons {
  font-size: 22px;
  color: #334155;
}

/* ─── RESPONSIVIDADE MOBILE (<768px) ─────────────────────── */
@media (max-width: 767px) {
  #btnHamburgerMobile {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 270px !important;
    min-width: 270px !important;
    transform: translateX(-100%);
    box-shadow: none;
  }

  /* Sidebar aberta no mobile */
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.18);
  }

  /* Ocultar botão desktop collapse no mobile */
  .btn-toggle-sidebar {
    display: none;
  }

  /* Garantir que conteúdo não fica atrás do hamburger */
  .main-content {
    padding-top: 0;
  }

  /* Estado colapsado não se aplica no mobile */
  .sidebar.collapsed {
    width: 270px !important;
    min-width: 270px !important;
  }

  .sidebar.collapsed .nav-item span:not(.material-icons),
  .sidebar.collapsed .nav-section-title,
  .sidebar.collapsed .user-name,
  .sidebar.collapsed #providerBrandName,
  .sidebar.collapsed #sidebarLogoContainer .version,
  .sidebar.collapsed .sidebar-legal-footer {
    opacity: 1;
    width: auto;
    overflow: visible;
    pointer-events: auto;
  }

  .sidebar.collapsed .nav-item {
    justify-content: flex-start;
    padding: 10px 14px;
  }

  .sidebar.collapsed .sidebar-header {
    justify-content: space-between;
    padding: 16px;
  }

  .sidebar.collapsed .sidebar-footer {
    justify-content: flex-start;
    padding: 12px 14px;
  }

  /* Desativar tooltips no mobile */
  .sidebar.collapsed .nav-item::after {
    display: none;
  }
}

/* Botão para Retrair / Expandir Sidebar */
.btn-toggle-sidebar {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-toggle-sidebar:hover {
  background-color: var(--card-bg);
  color: var(--text-primary);
}

/* Lista da Navegação Categorizada */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
}

.nav-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 14px 12px 6px 12px;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background-color: var(--card-bg);
  color: var(--text-primary);
}

.nav-item.active {
  background-color: var(--primary-alpha);
  color: var(--primary-color);
  font-weight: 600;
}

[data-theme="dark"] .nav-item.active {
  color: var(--accent-green);
}

.nav-item .material-icons {
  font-size: 20px;
}

/* Área de Conteúdo Principal */
.main-content {
  flex: 1;
  height: 100%;
  overflow: hidden;
  position: relative;
  background-color: var(--bg-primary);
}

.content-section {
  display: none !important;
  width: 100%;
  height: 100%;
}

.content-section.active {
  display: flex !important;
  flex-direction: column;
  flex: 1;
  width: 100%;
  height: 100%;
}

/* Scrollbar Customizada */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
