/* ============================================================================= */
/* SIDEBARS - Structural left split-view panels (user + layers) */
/* ============================================================================= */
/* 
   Purpose: Left split-view panels for layer management and user info.
   Panels live inside .left-sidebar-panel (structural, not floating).
   Toggle buttons live in .left-sidebar-strip (see layout.css).
*/

/* ========================================================================= */
/* SIDEBAR TOGGLE BUTTONS - static inside .left-sidebar-strip */
/* ========================================================================= */

/* Buttons are laid out by the flex strip; no fixed positioning needed */
.toggle-btn,
.toggle-user-btn,
#toggleBtn,
#toggleUserBtn {
    position: static;
    transition: opacity var(--transition-fast);
}

/* ========================================================================= */
/* SIDEBAR BASE STYLING - Layer Panel */
/* ========================================================================= */

.sidebar,
#sidebar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    padding: var(--space-3);
    overflow-y: auto;
    border: none;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
}

.sidebar.closed,
#sidebar.closed {
    display: none;
}


.sidebar {
  position: absolute;
  left: 64px;
  top: 16px;
  bottom: 16px;
  width: 360px;
  height: 80%;;
  max-width: 90vw;
  background: rgba(18, 18, 20, 0.9);
  backdrop-filter: blur(8px);
  border-radius: 1rem;
  padding: 1rem;
  z-index: 6;
  transition: transform 0.3s ease;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  overflow-y: scroll;
}

.sidebar.closed {
  transform: translateX(calc(-100% - 64px));
}

.toggle-btn {
  position: absolute;
  left: 16px;
  top: 56px;
  z-index: 7;
}

.sidebar .card {
  background: rgba(255, 255, 255, 0.05);
  border: none;
  max-height: 60vh;
  overflow-y: scroll;
}

.sidebar .form-control,
.sidebar .form-select {
  background-color: #0c0f14;
  color: #eee;
  border: none;
}



.layer-list .layer-item {
  padding: .55rem 0rem;
  border-bottom: 1px dashed rgba(255, 255, 255, .08);
}

.layer-list .layer-item,
.layer-list .layer-item * {
  user-select: text;
}

.layer-list .layer-item:last-child {
  border-bottom: none;
}

.layer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}

.layer-title {
  font-weight: 600;
  font-size: .95rem;
  color: #e8eaed;
}

.layer-actions {
  display: flex;
  align-items: center;
  gap: .35rem;
}

.layer-actions .layer-eye span {
  font-size: 12px
}

.layer-details {
  margin-top: .4rem;
  padding: .5rem .6rem;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: .6rem;
}

.layer-detail.detail-description {
  color: #e8eaed
}

.layer-details code {
  background: rgba(255, 255, 255, .08);
  padding: 0 .25rem;
  border-radius: .25rem;
}

.layer-toggle {
  cursor: pointer;
  color: #9aa0a6;
  text-decoration: underline;
}

.spinner-border {
  vertical-align: -2px;
  color: whitesmoke;
}

.layer-drag-handle {
  flex: 0 0 18px;
  margin-right: .35rem;
  cursor: grab;
  user-select: none;
  color: #9aa0a6;
  display: flex;
  align-items: center;
  justify-content: center;
}

.layer-item[draggable="true"]:active .layer-row .layer-drag-handle {
  cursor: grabbing;
}

.layer-item.dragging {
  opacity: .6;
}

.layer-item.drop-above::before,
.layer-item.drop-below::after {
  content: "";
  display: block;
  height: 0;
  border-top: 2px dashed rgba(255, 255, 255, .25);
  margin: 2px 0;
}

.layer-item.drop-below::after {
  margin-top: 6px;
}

#addVectorWrap,
#addRasterWrap {
  color: #e8eaed;
}

/* =========================================================================
   LAYER GROUPS
========================================================================= */

.layer-group {
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  margin-bottom: .15rem;
}

.layer-group:last-child {
  border-bottom: none;
}

.layer-group-header {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .45rem .1rem;
  cursor: pointer;
  user-select: none;
  color: #232628;
  font-size: .85rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.layer-group-header:hover {
  color: #e8eaed;
}

.layer-group-toggle-icon {
  font-size: .75rem;
  line-height: 1;
  flex: 0 0 auto;
  transition: transform .15s ease;
}

.layer-group-name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-group-count {
  font-size: .8rem;
  flex: 0 0 auto;
}

.layer-group-body {
  padding-left: .75rem;
  border-left: 2px solid rgba(255, 255, 255, .08);
  margin-left: .35rem;
  margin-bottom: .35rem;
}



/* ===== Metadata expandable tree ===== */

.layer-meta-wrap {
  margin-top: .4rem;
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: .5rem;
  overflow: hidden;
}

.layer-meta-header {
  display: flex;
  align-items: center;
  gap: .4rem;
  /* padding: .3rem .6rem; */
  background: rgba(255, 255, 255, .04);
  cursor: pointer;
  user-select: none;
  font-size: .82rem;
  color: #9aa0a6;
  transition: background 0.15s;
}

.layer-meta-header:hover {
  background: rgba(255, 255, 255, .08);
}

.layer-meta-toggle-icon {
  font-size: .65rem;
  width: 10px;
  flex-shrink: 0;
  color: #9aa0a6;
}

.layer-meta-body {
  /* padding: .3rem .4rem; */
}

.layer-meta-key-row {
  margin-bottom: .2rem;
}

.layer-meta-key-label {
  display: flex;
  align-items: baseline;
  gap: .35rem;
  padding: .15rem .2rem;
  border-radius: .3rem;
  font-size: .8rem;
  color: #9aa0a6;
  cursor: default;
  user-select: none;
}

.layer-meta-key-label:has(.layer-meta-key-icon:not(.layer-meta-key-icon--leaf)) {
  cursor: pointer;
}

.layer-meta-key-label:hover:has(.layer-meta-key-icon:not(.layer-meta-key-icon--leaf)) {
  background: rgba(255, 255, 255, .06);
}

.layer-meta-key-icon {
  font-size: .6rem;
  width: 10px;
  min-width: 10px;
  flex-shrink: 0;
  color: #9aa0a6;
}

.layer-meta-key-icon--leaf {
  visibility: hidden;
}

.layer-meta-inline-val {
  margin-left: .3rem;
  color: var(--color-text-primary);
  font-size: .78rem;
  font-family: monospace;
  opacity: .85;
  word-break: break-all;
}

.layer-meta-key-val {
  padding-left: 1.25rem;
}

.layer-meta-key-val pre {
  margin: 0;
  padding: .3rem .5rem;
  background: rgba(255, 255, 255, .04);
  border-radius: .35rem;
  font-size: .75rem;
  color: var(--color-text-primary);
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.5;
}

.layer-meta-key-val pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}


/* ===== Layer Style Legend ===== */

.layer-legend-wrap {
  margin-top: .4rem;
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: .5rem;
  overflow: hidden;
}

.layer-legend-header {
  display: flex;
  align-items: center;
  gap: .4rem;
  /* padding: .25rem .55rem; */
  background: rgba(255, 255, 255, .04);
  cursor: pointer;
  user-select: none;
  font-size: .82rem;
  color: #9aa0a6;
  transition: background 0.15s;
}

.layer-legend-header:hover {
  background: rgba(255, 255, 255, .08);
}

.layer-legend-toggle-icon {
  font-size: .65rem;
  width: 10px;
  flex-shrink: 0;
  color: #9aa0a6;
}

.layer-legend-body {
  padding: .4rem .55rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  max-height: 200px;
  overflow-y: scroll;
}

/* Single color */
.layer-legend-single {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .8rem;
  color: #95989c;
}
.layer-legend-swatch {
  width: 22px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,.12);
  flex-shrink: 0;
}

/* Graduated */
.layer-legend-graduated {
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.layer-legend-field {
  font-size: .75rem;
  color: #95989c;
  font-family: monospace;
  opacity: .85;
}
.layer-legend-ramp {
  width: 100%;
  height: 12px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,.1);
}
.layer-legend-ramp-labels {
  display: flex;
  justify-content: space-between;
  font-size: .72rem;
  color: #95989c;
  font-family: monospace;
  line-height: 1.2;
}

/* Categorized */
.layer-legend-cat-grid {
  display: flex;
  flex-direction: column;
  gap: .18rem;
}
.layer-legend-cat-row {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .78rem;
  color: #95989c;
}
.layer-legend-cat-swatch {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  border: 1px solid rgba(255,255,255,.12);
  flex-shrink: 0;
}
.layer-legend-cat-more {
  font-size: .75rem;
  color: #6b7280;
  font-style: italic;
}


/* ========================================================================= */
/* SIDEBAR BASE STYLING - User Panel */
/* ========================================================================= */

.user-sidebar,
#userSidebar,
.artifact-sidebar,
#artifactSidebar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    padding: var(--space-3);
    overflow-y: auto;
    border: none;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
}

.user-sidebar.closed,
#userSidebar.closed,
.artifact-sidebar.closed,
#artifactSidebar.closed {
    display: none;
}

/* ========================================================================= */
/* SIDEBAR FORM CONTROLS */
/* ========================================================================= */

.sidebar .card,
.user-sidebar .card,
.artifact-sidebar .card,
#sidebar .card,
#userSidebar .card,
#artifactSidebar .card {
    background: var(--color-card-bg);
    border: none;
    max-height: 60vh;
    overflow-y: auto;
    border-radius: var(--radius-xl);
}

.sidebar .form-control,
.sidebar .form-select,
.user-sidebar .form-control,
.user-sidebar .form-select,
.artifact-sidebar .form-control,
.artifact-sidebar .form-select,
#sidebar .form-control,
#sidebar .form-select,
#userSidebar .form-control,
#userSidebar .form-select,
#artifactSidebar .form-control,
#artifactSidebar .form-select {
    background-color: var(--color-input-bg);
    color: var(--color-text-primary);
    border: var(--color-input-border);
    border-radius: var(--radius-md);
}

/* ========================================================================= */
/* LAYER PANEL - Layers list and management */
/* ========================================================================= */

.layer-list,
#projectLayersList {
    display: flex;
    flex-direction: column;
    gap: 0;
    role: list;
}

.layer-item {
    padding: 0.55rem 0;
    border-bottom: 1px dashed var(--color-border-dashed);
    user-select: text;
    transition: background-color var(--transition-fast);
}

.layer-item:hover {
    background-color: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
    /* padding: 0.55rem var(--space-sm); */
}

.layer-item:last-child {
    border-bottom: none;
}

.layer-item * {
    user-select: text;
}

/* ========================================================================= */
/* LAYER ITEM CONTENT */
/* ========================================================================= */

.layer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-1);
}

.layer-title {
    font-weight: var(--font-weight-semibold);
    font-size: 0.95rem;
    color: var(--color-text-primary);
    flex: 1;
}

/* Layer actions (eye, download, etc.) */
.layer-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.layer-actions .layer-eye span,
.layer-eye .material-symbols-outlined {
    font-size: 12px;
    cursor: pointer;
    color: var(--color-text-secondary);
    transition: color var(--transition-fast);
}

.layer-actions .layer-eye span:hover,
.layer-eye .material-symbols-outlined:hover {
    color: var(--color-text-primary);
}

/* Layer drag handle */
.layer-drag-handle {
    flex: 0 0 18px;
    margin-right: 0.35rem;
    cursor: grab;
    user-select: none;
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast);
}

.layer-item[draggable="true"]:active .layer-row .layer-drag-handle {
    cursor: grabbing;
}

.layer-drag-handle:hover {
    color: var(--color-text-primary);
}

/* ========================================================================= */
/* LAYER DETAILS - Metadata section */
/* ========================================================================= */

.layer-details {
    margin-top: var(--space-2);
    padding: 0.5rem 0.6rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--color-border-light);
    border-radius: 0.6rem;
    font-size: 0.85rem;
}

.layer-detail.detail-description {
    color: var(--color-text-primary);
    margin-bottom: var(--space-sm);
}

.layer-details code {
    background: rgba(255, 255, 255, 0.08);
    padding: 0 0.25rem;
    border-radius: 0.25rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas;
}

.layer-toggle {
    cursor: pointer;
    color: var(--color-text-secondary);
    text-decoration: underline;
    transition: color var(--transition-fast);
}

.layer-toggle:hover {
    color: var(--color-text-primary);
}

/* ========================================================================= */
/* LAYER DRAG AND DROP INDICATORS */
/* ========================================================================= */

.layer-item.dragging {
    opacity: 0.6;
    background-color: rgba(255, 255, 255, 0.03);
}

.layer-item.drop-above::before,
.layer-item.drop-below::after {
    content: "";
    display: block;
    height: 0;
    border-top: 2px dashed var(--color-accent-green-alpha-35);
    margin: 2px 0;
}

.layer-item.drop-below::after {
    margin-top: 6px;
}

/* ========================================================================= */
/* USER PANEL - User info and projects */
/* ========================================================================= */

#infoUserId,
#infoProjectId,
#infoThreadId {
    color: var(--color-text-primary);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas;
    font-size: 0.9rem;
    word-break: break-all;
}

#infoThreadId code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 4px;
    border-radius: var(--radius-sm);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas;
}

/* Projects list container */
#userProjects {
    max-height: 45vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Individual project item */
.project-item,
#userProjects .project-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-1);
    padding: 0.35rem 0.6rem;
    border-bottom: 1px dashed var(--color-border-light);
    transition: background-color var(--transition-fast);
}

.project-item:hover,
#userProjects .project-item:hover {
    background-color: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
}

.project-item:last-child,
#userProjects .project-item:last-child {
    border-bottom: none;
}

.project-name {
    font-size: 0.92rem;
    color: var(--color-text-primary);
    flex: 1;
}

/* ========================================================================= */
/* ARTIFACT PANEL - Artifacts list and details */
/* ========================================================================= */

#projectArtifactsList {
  max-height: 60vh;
  overflow-y: auto;
}

.artifact-item {
  padding: 0.55rem 0;
  border-bottom: 1px dashed var(--color-border-dashed);
  transition: background-color var(--transition-fast);
}

.artifact-item:last-child {
  border-bottom: none;
}

.artifact-item:hover {
  background-color: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-md);
}

.artifact-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-2);
}

.artifact-main {
  min-width: 0;
  flex: 1;
}

.artifact-title {
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  word-break: break-word;
}

.artifact-kind {
  text-transform: lowercase;
  font-size: 0.72rem;
}

.artifact-toggle {
  cursor: pointer;
  color: var(--color-text-secondary);
  text-decoration: underline;
}

.artifact-details {
  margin-top: var(--space-2);
  padding: 0.5rem 0.6rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--color-border-light);
  border-radius: 0.6rem;
}

.artifact-details code {
  background: rgba(255, 255, 255, 0.08);
  padding: 0 0.25rem;
  border-radius: 0.25rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas;
}

.artifact-spec-wrap {
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--space-2);
}

.artifact-spec-header {
  display: flex;
  align-items: center;
  gap: .4rem;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  user-select: none;
  padding: .35rem .5rem;
}

.artifact-spec-header:hover {
  background: rgba(255, 255, 255, 0.08);
}

.artifact-spec-toggle-icon {
  font-size: .65rem;
  width: 10px;
  flex-shrink: 0;
  color: var(--color-text-secondary);
}

.artifact-spec-body {
  padding: .45rem .55rem;
}

.artifact-summary-markdown {
  margin-top: var(--space-1);
  max-height: 180px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  color: var(--color-text-primary);
}

.artifact-summary-markdown :first-child {
  margin-top: 0;
}

.artifact-summary-markdown :last-child {
  margin-bottom: 0;
}

.artifact-summary-markdown pre {
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  white-space: pre-wrap;
  word-break: break-word;
}

.artifact-summary-markdown code {
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 0 0.2rem;
}

.artifact-summary-open-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.artifact-summary-open-btn .material-symbols-outlined {
  font-size: 14px;
  line-height: 1;
}

.artifact-summary-modal-content {
  min-height: 70vh;
}

.artifact-summary-modal-markdown {
  max-height: none;
  min-height: 55vh;
}

.artifact-summary-modal-markdown h1,
.artifact-summary-modal-markdown h2,
.artifact-summary-modal-markdown h3,
.artifact-summary-modal-markdown h4,
.artifact-summary-modal-markdown h5,
.artifact-summary-modal-markdown h6 {
  color: var(--color-text-primary);
}

/* New project form */
#newProjForm .form-control {
    background-color: var(--color-input-bg);
    color: var(--color-text-primary);
    border: var(--color-input-border);
}

/* ========================================================================= */
/* COLLAPSIBLE SECTIONS - Vector and Raster layer sections */
/* ========================================================================= */

#addVectorWrap,
#addRasterWrap {
    color: var(--color-text-primary);
    background: transparent;
}

.collapse .form-label {
    color: var(--color-text-secondary);
    margin-bottom: var(--space-1);
    font-size: 0.9rem;
}

.collapse .form-check-label {
    color: var(--color-text-primary);
}

/* ========================================================================= */
/* RESPONSIVE ADJUSTMENTS */
/* ========================================================================= */

@media (max-width: 640px) {
    .sidebar,
    .user-sidebar,
  .artifact-sidebar,
    #sidebar,
  #userSidebar,
  #artifactSidebar {
        padding: var(--space-2);
    }
}

@media (max-width: 480px) {
    .layer-item,
    .project-item {
        font-size: 0.85rem;
    }
}
