/* ====================================================================
   GLOBAL STYLES
   ==================================================================== */

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-100);
  display: flex;
  min-height: 100vh;
  flex: 1;
  font-family: "Rubik", sans-serif;
  overflow: auto;
  position: relative;
  flex-direction: row;

  /* Add anti-aliasing for smoother text rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

@media (max-width: 768px) {
  html,
  body {
    height: 100dvh;
    min-height: 100dvh;
    overflow-y: auto;
    padding: 0;
    -webkit-overflow-scrolling: touch;
  }
}

/* ====================================================================
     LAYOUT COMPONENTS
     ==================================================================== */

/* Main Content Area */
main {
  background-color: var(--bg-100);
  background-image: radial-gradient(var(--white-5) 1px, transparent 0);
  background-size: 10px 10px;
  background-position: top;
  margin: 12px 12px 0 0;
  padding: 0;
  border: solid var(--border);
  border-width: 1px 1px 0 1px;
  border-radius: 12px 12px 0 0;
  overflow: auto;
  display: flex;
  flex: 1;
  flex-direction: column;
}

/* Main content row needs flex: 1 */
main > .container-row {
  flex: 1;
  overflow: hidden;
}

@media (max-width: 768px) {
  main > .container-row {
    flex: 1;
    overflow: hidden;
    min-height: 0;
  }
}

@media (max-width: 768px) {
  main {
    margin: 0;
    border-radius: 0;
    border: none;
    width: 100%;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100dvh;
  }
}

/* Content Container */
.content {
  display: flex;
  flex-direction: column;
  padding: 60px 32px;
  width: 100%;
  flex: 1;
  gap: 60px;
  align-items: center;
  overflow: hidden auto;
  min-width: 0;
  scrollbar-gutter: stable;
}

@media (max-width: 768px) {
  .content {
    padding: 32px 16px;
    gap: 32px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
  }
}

.section {
  max-width: 1120px;
  width: 100%;
}

/* ====================================================================
     COMPONENT: TOP BAR
     ==================================================================== */

.top-bar {
  background-color: var(--bg-100);
  padding: 12px 16px;
  display: flex;
  width: 100%;
  height: auto;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
}

.top-bar .container-row {
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.top-bar-center {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

/* Burger Menu Icon */
.burger-menu {
  cursor: pointer;
  color: var(--white-60);
  transition: color 0.2s ease;
  font-size: 24px;
}

.burger-menu:hover {
  color: var(--white-90);
}

@media (max-width: 768px) {
  .top-bar {
    position: relative;
    top: 0;
    z-index: 100;
    padding: 12px 16px;
    flex-shrink: 0;
    background-color: var(--bg-100);
    border-bottom: 1px solid var(--border);
  }
}

/* ====================================================================
     COMPONENT: LEFT BAR
     ==================================================================== */

.left-bar-container {
  display: flex;
  flex-direction: row;
  height: 100%;
}

.left-bar-modules {
  padding: 12px;
  min-width: 60px;
  max-width: 60px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100%;
  border-right: 1px solid var(--border);
}

.left-bar-primary {
  padding: 12px;
  min-width: 240px;
  max-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100%;
}

/* Mobile overlay for left bar */
.mobile-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Accordion menu */
.accordion-menu {
  position: relative;
}

.accordion-content {
  position: static;
  background: transparent;
  border: none;
  border-radius: 0;
  margin-top: 0;
  padding: 0;
}

.accordion-submenu {
  padding-left: 16px;
  gap: 4px;
}

.accordion-submenu::before {
  content: "";
  position: absolute;
  left: 22px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background-color: var(--border);
}

@media (max-width: 768px) {
  /* Left bar becomes overlay on mobile */
  .left-bar-container {
    position: fixed;
    top: 0;
    left: -280px; /* Hidden by default */
    width: 280px;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s ease;
    background-color: var(--bg-100);
    border-right: 1px solid var(--border);
  }

  .left-bar-container.open {
    left: 0; /* Slide in when open */
  }

  .left-bar-primary {
    min-width: 100%;
    max-width: 100%;
    padding: 12px;
    height: 100%;
    border-right: none;
  }

  .left-bar-primary nav {
    flex-direction: column;
    gap: 4px;
  }

  .left-bar-primary .btn-menu {
    padding: 6px 12px;
  }

  /* Accordion menu mobile adjustments */
  .accordion-menu {
    position: relative;
  }

  .accordion-content {
    position: static;
    background: transparent;
    border: none;
    border-radius: 0;
    margin-top: 0;
    padding: 0;
  }

  .accordion-submenu {
    padding-left: 16px;
    gap: 4px;
  }

  .accordion-submenu::before {
    content: "";
    position: absolute;
    left: 22px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background-color: var(--border);
  }
}

/* ====================================================================
     COMPONENT: RIGHT BAR
     ==================================================================== */

.right-bar {
  position: relative;
  width: 0;
  min-width: 0;
  height: 100%;
  background-color: var(--bg-100);
  color: var(--white-90);
  padding: 0;
  overflow: hidden;
  transition: width 0.3s ease-in-out, padding 0.3s ease-in-out;
  border-left: 1px solid var(--border);
  flex-shrink: 0;
}

.right-bar.open {
  width: 360px;
  overflow-y: auto;
}

.right-bar-header {
  display: flex;
  padding: 16px 20px;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--border);
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.right-bar.open .right-bar-header {
  opacity: 1;
}

.right-bar-content {
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 16px;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.right-bar.open .right-bar-content {
  opacity: 1;
}

.right-bar h6 {
  font-size: 14px;
  font-weight: 500;
  color: var(--white-60);
  margin: 0 0 4px 0;
}

.right-bar .detail-value {
  font-size: 16px;
  font-weight: 400;
  color: var(--white-90);
  margin-bottom: 16px;
}

/* Right Bar Resize Handle */
.right-bar-resize-handle {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  background: transparent;
  cursor: ew-resize;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.right-bar.open .right-bar-resize-handle {
  opacity: 1;
}

.right-bar-resize-handle:hover {
  background: rgba(255, 255, 255, 0.05);
}

.resize-grip {
  width: 2px;
  height: 32px;
  background: var(--white-30);
  border-radius: 1px;
  transition: background-color 0.2s ease;
}

.right-bar-resize-handle:hover .resize-grip {
  background: var(--white-60);
}

@media (max-width: 768px) {
  .right-bar.open {
    width: 100%;
  }

  .right-bar-resize-handle {
    display: none;
  }
}

/* ====================================================================
     UTILITIES
     ==================================================================== */

/* Remove border-radius from cards inside overflow-hidden containers */
.overflow-hidden .module-card {
  border-radius: 0;
}
