/* css/sidebar.css */
/* Left Sidebar Shell */
.sidebar {
    display: flex;
    height: 100%;
    border-right: 1px solid var(--border-color);
    background-color: var(--tree-bg);
}

.tab-rail {
    width: 56px;
    background-color: var(--rail-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 16px;
    border-right: 1px solid var(--border-color);
    gap: 16px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.tab-btn:hover {
    color: var(--text-primary);
    background-color: var(--hover-bg);
}
.tab-btn.active {
    color: var(--accent);
    background-color: rgba(24, 160, 251, 0.1);
}
.tab-btn svg {
    width: 20px;
    height: 20px;
}

.sidebar-content {
    width: 240px;
    display: flex;
    flex-direction: column;
}

.sidebar-panel {
    display: none;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

.sidebar-panel.active {
    display: flex;
}

/* Tree List UI */
.tree-header {
    padding: 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.tree-list {
    list-style: none;
    padding: 8px 0;
    font-size: 13px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}
.tree-list-container {
    padding-left: 16px;
    list-style: none;
    margin: 0;
}
.tree-list > .tree-list-container {
    padding-left: 0;
}

.tree-item {
    padding: 6px 8px;
    margin: 0 8px;
    cursor: pointer;
    border-radius: 4px;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.tree-item:hover {
    background-color: var(--hover-bg);
}
.tree-item.selected {
    background-color: rgba(24, 160, 251, 0.1);
    color: var(--accent);
}
.tree-item.drag-over {
    background-color: rgba(24, 160, 251, 0.2);
    border: 1px dashed var(--accent);
}
.tree-node {
    list-style: none;
}

/* Right Sidebar (Properties) */
.element-sidebar {
    width: 240px;
    background: #ffffff;
    border-left: 1px solid #e5e5e5;
    font-size: 11px;
    display: flex;
    flex-direction: column;
}

.element-sidebar .sidebar-header {
    height: 40px;
    padding: 0 8px 0 16px;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
}

.element-section {
    border-bottom: 1px solid #e5e5e5;
    padding: 16px;
}
.element-section-title {
    font-weight: 600;
    margin-bottom: 12px;
}
.element-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.element-col {
    flex: 1;
    position: relative;
}

.element-input-wrapper {
    display: flex;
    align-items: center;
    height: 28px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: #f5f5f5;
    transition: all 0.1s;
    position: relative;
}

.element-input-wrapper:hover {
    background: #eeeeee;
}
.element-input-wrapper:focus-within {
    border-color: #18a0fb;
    background: #ffffff;
    box-shadow: 0 0 0 1px #18a0fb;
}

.element-label {
    width: 24px;
    text-align: center;
    color: #b3b3b3;
    font-weight: 500;
}
.element-input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    color: #333;
    font-family: inherit;
    font-size: 11px;
    width: 100%;
}
.element-input::-webkit-outer-spin-button,
.element-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

.element-color-square {
    width: 16px;
    height: 16px;
    border-radius: 2px;
    margin: 0 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}
.native-color-picker {
    opacity: 0;
    position: absolute;
    left: 8px;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Mobile Sidebar Behavior */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 56px;
        left: -300px;
        height: calc(100vh - 56px);
        z-index: 1000;
        transition: transform 0.3s;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
    }
    .sidebar.open {
        transform: translateX(300px);
    }

    .right-sidebar {
        position: fixed;
        top: 56px;
        right: -240px;
        height: calc(100vh - 56px);
        z-index: 1000;
        transition: transform 0.3s;
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.1);
    }
    .right-sidebar.open {
        transform: translateX(-240px);
    }
}

@media (min-width: 769px) {
    .sidebar.desktop-closed {
        display: none !important;
    }
    .right-sidebar.desktop-closed {
        display: none !important;
    }
}

/* Custom Color Picker Overlay */
.custom-color-picker {
  position: fixed; /* so it can escape containers */
  width: 240px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  font-family: inherit;
  overflow: hidden;
}

.color-picker-header {
  display: flex;
  justify-content: flex-end;
  padding: 8px;
  border-bottom: 1px solid var(--border-color);
}

.color-picker-close {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-color);
  opacity: 0.6;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.color-picker-close:hover {
  opacity: 1;
  background: var(--hover-bg);
}

.color-picker-main {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.color-picker-saturation-area {
  width: 100%;
  height: 150px;
  position: relative;
  border-radius: 4px;
  overflow: hidden;
  cursor: crosshair;
}

.color-picker-sat-white {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(to right, #fff, rgba(255,255,255,0));
}

.color-picker-sat-black {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(to top, #000, rgba(0,0,0,0));
}

.color-picker-sat-pointer {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 0 2px rgba(0,0,0,0.5);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.color-picker-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-picker-eyedropper {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-color);
}
.color-picker-eyedropper:hover {
  background: var(--hover-bg);
}

.color-picker-sliders {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.color-picker-hue-slider, .color-picker-alpha-slider {
  height: 10px;
  border-radius: 5px;
  position: relative;
  cursor: pointer;
}

.color-picker-hue-slider {
  background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
}

.color-picker-alpha-wrap {
  position: relative;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
}

.color-picker-alpha-bg {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: linear-gradient(45deg, #ccc 25%, transparent 25%), linear-gradient(-45deg, #ccc 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ccc 75%), linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
}

.color-picker-alpha-slider {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
}

.color-picker-slider-pointer {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid white;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.color-picker-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-picker-format {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-color);
  padding: 4px;
  border-radius: 4px;
  font-size: 11px;
}

.color-picker-hex-input {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid transparent;
  color: var(--text-color);
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 12px;
  width: 0; /* flex takes over */
}

.color-picker-alpha-input-wrap {
  display: flex;
  align-items: center;
  width: 48px;
  background: var(--input-bg);
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 4px 6px;
}

.color-picker-alpha-input {
  width: 24px;
  background: transparent;
  border: none;
  color: var(--text-color);
  font-size: 12px;
  text-align: right;
  outline: none;
}
.color-picker-alpha-input-wrap span {
  font-size: 11px;
  color: #b3b3b3;
  margin-left: 2px;
}

.color-picker-palette {
  border-top: 1px solid var(--border-color);
  padding: 12px;
}

.color-picker-palette-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-color);
  margin-bottom: 8px;
  font-weight: 500;
}

.color-picker-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.color-picker-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.1);
}
.color-picker-swatch:hover {
  transform: scale(1.1);
  box-shadow: 0 0 2px rgba(0,0,0,0.5);
}

