/* GrSidebar CSS */

:root {
  /* User Defined Palette */
  --gr-primary: #285d2a;      /* Cor_Segundaria_6_1 */
  --gr-primary-dark: #105018; /* Cor_Segundaria_6_2 */
  --gr-body-empty: #c6c6c6;   /* Vazio_Corpo */
  --gr-panel-empty: #ebebeb;  /* Vazio_Painel */
  --gr-bg-empty: #9a9a9a;     /* Vazio_Fundo */

  /* Sidebar Specifics (Mapped to Palette) */
  --sidebar-bg: #ffffff;
  --sidebar-text: #475569;
  --sidebar-text-active: #0f172a;
  --sidebar-text-muted: #64748b;
  --sidebar-border: #f1f5f9;
  --sidebar-bg-search: #f8fafc;
  --sidebar-bg-hover: rgba(0, 0, 0, 0.03);
  --sidebar-tree-line: #e2e8f0;
  --sidebar-footer-bg: #f8fafc;
  --sidebar-user-card-bg: rgba(0, 0, 0, 0.01);
  --sidebar-toggle-bg: #ffffff;
  --sidebar-toggle-border: #e2e8f0;
  --sidebar-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
}

.dark .gr-sidebar-container {
  /* Dark Theme Variables (If needed, otherwise keep light as default or adapt) */
  --sidebar-bg: #1a1a1a;
  --sidebar-text: #ffffff;
  --sidebar-text-active: #ffffff;
  --sidebar-text-muted: #a0a0a0;
  --sidebar-border: rgba(255, 255, 255, 0.03);
  --sidebar-bg-search: #252525;
  --sidebar-bg-hover: rgba(255, 255, 255, 0.03);
  --sidebar-tree-line: #262626;
  --sidebar-footer-bg: #181818;
  --sidebar-user-card-bg: rgba(255, 255, 255, 0.02);
  --sidebar-toggle-bg: #262626;
  --sidebar-toggle-border: #333;
  --sidebar-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.gr-sidebar-container {
  width: 260px;
  height: calc(100vh - 20px);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 40;
  border-radius: 16px;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  box-shadow: var(--sidebar-shadow);
  border: 1px solid var(--sidebar-border);
}

/* Subtle Top Glow - GR Primary */
.gr-sidebar-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gr-primary), transparent);
  opacity: 0.5;
}

.gr-sidebar-container.collapsed {
  width: 80px;
}

/* Toggle Area */
.gr-toggle-container {
  padding: 1rem;
  display: flex;
  justify-content: flex-end;
  min-height: 56px;
  align-items: center;
}

.collapsed .gr-toggle-container {
  justify-content: center;
}

.gr-toggle-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--sidebar-toggle-bg);
  border: 1px solid var(--sidebar-toggle-border);
  color: var(--sidebar-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.gr-toggle-btn:hover {
  background: var(--sidebar-bg-search);
  color: var(--gr-primary);
  border-color: var(--gr-primary);
  transform: scale(1.05);
}

/* Search Box */
.gr-search-wrapper {
  padding: 0.5rem 1.25rem 1.5rem;
  transition: all 0.3s ease;
}

.collapsed .gr-search-wrapper {
  opacity: 0;
  pointer-events: none;
  height: 0;
  padding: 0;
}

.gr-search-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  background: var(--sidebar-bg-search);
  border: 1px solid var(--sidebar-border);
  border-radius: 12px;
  color: var(--sidebar-text);
  font-size: 0.85rem;
  outline: none;
  transition: all 0.2s ease;
}

.gr-search-input:focus {
  border-color: var(--gr-primary);
  background: var(--sidebar-bg);
  box-shadow: 0 0 0 3px rgba(40, 93, 42, 0.1); /* using gr-primary in rgba */
}

/* Navigation Content */
.gr-nav-content {
  flex: 1;
  padding: 0.5rem 1rem;
  overflow-y: auto;
  overflow-x: hidden;
}

.gr-nav-content::-webkit-scrollbar {
  width: 3px;
}

.gr-nav-content::-webkit-scrollbar-thumb {
  background: var(--sidebar-border);
  border-radius: 10px;
}

/* Menu Item Wrapper */
.gr-item-wrapper {
  margin-bottom: 6px;
}

/* Links & Tree Structure */
.gr-link {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  color: var(--sidebar-text-muted);
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
  gap: 14px;
}

.gr-link:hover:not(.active) {
  background: var(--sidebar-bg-hover);
  color: var(--sidebar-text);
}

.gr-link.active {
  background: var(--gr-primary) !important;
  color: #ffffff !important; /* Always white on primary bg */
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(40, 93, 42, 0.25);
}

.gr-icon {
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.gr-link:hover .gr-icon:not(.active) {
  transform: scale(1.1);
}

.gr-label {
  flex: 1;
  font-size: 0.9rem;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.collapsed .gr-label,
.collapsed .gr-chevron {
  display: none;
}

.gr-chevron {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--sidebar-text-muted);
}

.gr-chevron.expanded {
  transform: rotate(180deg);
}

/* Submenu & Tree Lines */
.gr-submenu {
  margin-left: 0.5rem;
  padding-left: 1.25rem;
  border-left: 2px solid var(--sidebar-tree-line);
  margin-top: 4px;
  margin-bottom: 8px;
}

.gr-sublink {
  display: flex;
  align-items: center;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  color: var(--sidebar-text-muted);
  font-size: 0.85rem;
  transition: all 0.2s ease;
  text-decoration: none;
  margin-bottom: 2px;
  position: relative;
  gap: 12px;
}

.gr-sublink::before {
  content: '';
  position: absolute;
  left: -1.25rem;
  top: 50%;
  width: 0.75rem;
  height: 2px;
  background: var(--sidebar-tree-line);
}

.gr-sublink:hover {
  color: var(--sidebar-text);
  background: var(--sidebar-bg-hover);
}

.gr-sublink.active {
  color: var(--gr-primary);
  font-weight: 700;
}

/* Icons in sublink */
.gr-sublink .gr-icon {
  opacity: 0.7;
}

.gr-sublink.active .gr-icon {
  opacity: 1;
  color: var(--gr-primary);
}

/* Footer Section */
.gr-footer {
  padding: 1.25rem;
  border-top: 1px solid var(--sidebar-border);
  background: var(--sidebar-footer-bg);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.collapsed .gr-footer {
  padding: 1.25rem 0.5rem;
  align-items: center;
}

/* Brand Area in Footer */
.gr-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gr-brand-logo {
  width: 36px;
  height: 36px;
  background: var(--gr-primary);
  color: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  box-shadow: 0 0 15px rgba(40, 93, 42, 0.2);
  flex-shrink: 0;
}

.gr-brand-info {
  display: flex;
  flex-direction: column;
}

.gr-brand-name {
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--sidebar-text);
}

.gr-brand-name span {
  color: var(--gr-primary);
}

.gr-app-sub {
  font-size: 0.7rem;
  color: var(--sidebar-text-muted);
  font-weight: 600;
}

/* User Card */
.gr-user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.625rem;
  background: var(--sidebar-user-card-bg);
  border-radius: 12px;
  border: 1px solid var(--sidebar-border);
}

.gr-user-data {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.gr-user-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gr-logout-link {
  font-size: 0.75rem;
  color: var(--sidebar-text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.2s;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  width: fit-content;
}

.gr-logout-link:hover {
  color: #ef4444;
}

/* Legal & Version */
.gr-legal {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 0.75rem;
  border-top: 1px solid var(--sidebar-border);
}

.gr-legal-item, .gr-version {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  color: var(--sidebar-text-muted);
}

.gr-legal-item svg, .gr-version svg {
  color: var(--gr-primary);
  opacity: 0.6;
}

/* Locks */
.gr-locked {
  opacity: 0.4;
  cursor: not-allowed !important;
}

.gr-lock-icon {
  margin-left: auto;
  color: var(--gr-primary) !important;
}
