/* Modern Sidebar - Clean & Minimal */

/* Items panel search + category filter */

/* #items-tab inherits 16px padding from the generic .tab-content rule
   (layout.css), which would stack with the search bar's own padding and
   push it down. Zero it out here so the search bar sits flush against the
   tab divider; #item-palette below already carries its own 16px padding. */
#items-tab {
  padding: 0;
}

.items-search-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 10px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-panel);
}

.items-search-wrapper {
  flex: 1;
  min-width: 0;
  position: relative;
}

.items-search-wrapper::before {
  position: absolute;
  top: 50%;
  left: 12px;
  z-index: 1;
  width: 16px;
  height: 16px;
  pointer-events: none;
  content: '';
  background: currentcolor;
  color: var(--color-text-tertiary);
  mask:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M10.5 4a6.5 6.5 0 0 1 5.17 10.45l4.44 4.44a.86.86 0 0 1-1.22 1.22l-4.44-4.44A6.5 6.5 0 1 1 10.5 4Zm0 1.72a4.78 4.78 0 1 0 0 9.56 4.78 4.78 0 0 0 0-9.56Z'/%3E%3C/svg%3E")
    center / contain no-repeat;
  transform: translateY(-50%);
}

.items-search {
  width: 100%;
  height: 36px;
  padding: 0 36px;
  font-size: 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  transition: all var(--transition-fast);
  font-family: inherit;
  position: relative;
}

.items-search:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-light);
}

.items-search::placeholder {
  color: var(--color-text-secondary);
  opacity: 0.7;
}

.items-search::-webkit-search-cancel-button {
  appearance: none;
  height: 16px;
  width: 16px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cline x1='18' y1='6' x2='6' y2='18'/%3E%3Cline x1='6' y1='6' x2='18' y2='18'/%3E%3C/svg%3E")
    center center no-repeat;
  background-size: contain;
  cursor: pointer;
  opacity: 0.6;
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
}

.items-search::-webkit-search-cancel-button:hover {
  opacity: 1;
}

/* Filter-by-category button + dropdown */
.items-filter-dropdown {
  flex-shrink: 0;
}

.items-filter-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.items-filter-btn svg {
  width: 17px;
  height: 17px;
}

.items-filter-btn:hover {
  border-color: var(--color-border-hover);
  color: var(--color-text-primary);
}

.items-filter-btn.is-active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.items-filter-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  background: var(--color-graphite-900);
  color: white;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.items-filter-menu {
  right: 0;
  left: auto;
  width: 220px;
  padding: 8px 0;
}

.items-filter-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 14px 8px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--color-border-light);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.items-filter-clear {
  border: none;
  background: none;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--color-primary);
  cursor: pointer;
}

.items-filter-clear:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

.items-filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--color-text-primary);
  cursor: pointer;
}

.items-filter-option:hover {
  background: var(--color-bg-tertiary);
}

.items-filter-option input[type='checkbox'] {
  width: 14px;
  height: 14px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

/* New Layout Button */
.btn-new-layout {
  display: block;
  width: calc(100% - 32px);
  margin: 12px 16px;
  padding: 10px 14px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
}

.btn-new-layout:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-new-layout:active {
  transform: translateY(0);
}

.sidebar-section-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.sidebar-section-header h2 {
  margin: 0;
  color: var(--color-text-primary);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
}

.sidebar-section-header p {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}

/* Empty State */
.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--color-text-secondary);
}

.empty-state p {
  margin: 0;
  font-size: 14px;
}

.empty-state p:first-child {
  font-weight: 500;
  font-size: 15px;
  color: var(--color-text);
}

/* Floor Plan List */
#floorplan-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  padding: 16px;
}

.floorplan-template-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.floorplan-combo-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgb(var(--color-primary-rgb) / 35%);
  border-radius: var(--radius-md);
  background: rgb(var(--color-primary-rgb) / 5%);
}

.floorplan-combo-heading {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.floorplan-combo-heading > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.floorplan-combo-heading strong {
  color: var(--color-text-primary);
  font-size: 14px;
  line-height: 1.2;
}

.floorplan-combo-heading > div:first-child span {
  min-width: 44px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--color-bg-secondary);
  color: var(--color-text-tertiary);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
}

.floorplan-combo-hint {
  color: var(--color-text-secondary);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
}

.floorplan-combo-units {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.floorplan-combo-unit {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 6px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-panel);
  cursor: pointer;
  transition:
    background-color var(--transition-fast),
    border-color var(--transition-fast),
    box-shadow var(--transition-fast);
}

.floorplan-combo-unit:hover {
  border-color: rgb(180 37 24 / 20%);
  background: rgb(180 37 24 / 3%);
}

.floorplan-combo-unit.is-active {
  border-color: rgb(180 37 24 / 32%);
  background: rgb(180 37 24 / 6%);
  box-shadow: 0 1px 2px rgb(0 0 0 / 4%);
}

.floorplan-combo-index {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 7px;
  background: var(--color-primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.floorplan-combo-unit-name {
  overflow: hidden;
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.floorplan-combo-unit.is-active .floorplan-combo-unit-name {
  color: var(--color-text-primary);
  font-weight: 700;
}

.floorplan-combo-actions {
  display: flex;
  gap: 3px;
}

.floorplan-combo-actions button {
  display: grid;
  width: 24px;
  height: 24px;
  padding: 0;
  place-items: center;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--color-text-tertiary);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.floorplan-combo-actions button:hover {
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
}

.floorplan-combo-disclaimer {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: 11px;
  line-height: 1.35;
}

/* Floating "Selected units" panel, docked to the canvas's right edge.
   Content comes before the toggle in DOM order (see index.html) so the
   toggle -- the last flex child -- stays pinned flush against the edge at
   all times, and only the content's width animates open/closed.
   align-items: flex-start (NOT stretch, the default) is load-bearing here
   -- stretch was making the toggle match the content card's full height,
   which is what turned it into a huge solid bar instead of a compact tab. */
.floorplan-combo-panel {
  position: absolute;
  top: 14px;
  right: 0;
  z-index: 15;
  display: flex;
  align-items: flex-start;
  max-height: calc(100% - 32px);
}

.floorplan-combo-panel.hidden {
  display: none;
}

.floorplan-combo-panel-content {
  position: relative;
  top: 40px;
  left: 16px;
  width: 0;
  overflow: hidden;
  transition: width var(--transition-base);
}

@media (width > 768px) {
  #floorplan-combo-panel-content {
    top: 48px;
    left: 30px;
  }
}

@media (width <= 480px) {
  #floorplan-combo-panel-content {
    top: 12px;
    left: 0;
  }
}

.floorplan-combo-panel.is-open .floorplan-combo-panel-content {
  width: 228px;
}

.floorplan-combo-panel-content > .floorplan-combo-summary {
  width: 228px;
  max-height: 100%;
  padding: 10px;
  overflow-y: auto;
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  box-shadow: var(--shadow-lg);
}

/* Compact, fixed-size tab handle -- intentionally small (not stretched),
   matching the same solid-red treatment used for primary buttons (Add,
   New Layout) elsewhere in the app for visual consistency. Just the
   chevron -- no icon/badge, the panel itself already shows the count. */
.floorplan-combo-toggle {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  background: var(--color-primary);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: background var(--transition-fast);
}

.floorplan-combo-toggle:hover {
  background: var(--color-primary-hover);
}

.floorplan-combo-toggle svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  transition: transform var(--transition-base);
}

.floorplan-combo-panel.is-open .floorplan-combo-toggle svg {
  transform: rotate(180deg);
}

.floorplan-item {
  padding: 14px;
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.floorplan-item-copy {
  min-width: 0;
}

.floorplan-add {
  display: inline-flex;
  min-width: 58px;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 10px;
  border: 1px solid var(--color-primary);
  border-radius: 6px;
  background: var(--color-primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.floorplan-combo-actions button:disabled,
.floorplan-add:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.floorplan-add-plus {
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}

.floorplan-item:hover {
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.floorplan-item.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  box-shadow: 0 0 0 1px var(--color-primary);
}

.floorplan-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text);
  margin-bottom: 4px;
}

.floorplan-info {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

.floorplan-area {
  font-size: 13px;
  color: var(--color-primary);
  font-weight: 500;
}

/* Item Palette */
#item-palette {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  padding: 12px 14px 16px;
}

.item-category {
  margin-bottom: 8px;
}

.category-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
  color: var(--color-text-tertiary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.category-items {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}

.palette-item {
  min-height: 132px;
  padding: 10px 8px 9px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: center;
  transition:
    border-color var(--transition-base),
    transform var(--transition-base);
  position: relative;
  background: var(--color-bg-panel);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.palette-item:hover {
  transform: translateY(-1px);
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-sm);
}

.palette-item:active {
  transform: translateY(0);
}

/* Brand-red selected-on-canvas indicator (--color-primary, #B42518) so
   it's visually obvious this card corresponds to whatever's currently
   selected on the canvas. */
.palette-item.is-selected-on-canvas {
  border-color: var(--color-primary);
  background: rgb(var(--color-primary-rgb) / 4%);
  box-shadow: 0 0 0 1px rgb(var(--color-primary-rgb) / 18%);
}

.palette-item-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 600;
  transition: transform var(--transition-fast);
}

.palette-item-image {
  width: 100%;
  height: 64px;
  border-radius: var(--radius-md);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  transition: transform var(--transition-fast);
}

.palette-item-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform var(--transition-fast);
}

.palette-image-fallback {
  position: absolute;
  inset: 10px;
  border-radius: var(--radius-md);
  background: linear-gradient(
    180deg,
    var(--fallback-color, #94a3b8),
    color-mix(in srgb, var(--fallback-color, #94a3b8) 70%, #0f172a)
  );
  border: 1px solid rgb(148 163 184 / 45%);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 40%);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.palette-item-image--error .palette-image-fallback {
  opacity: 1;
}

.palette-item-image--error img {
  display: none;
}

.palette-item-placeholder {
  width: 100%;
  height: 64px;
  border-radius: var(--radius-md);
  border: 1px dashed rgb(148 163 184 / 70%);
  background: repeating-linear-gradient(
    135deg,
    rgb(226 232 240 / 60%) 0,
    rgb(226 232 240 / 60%) 10px,
    rgb(148 163 184 / 30%) 10px,
    rgb(148 163 184 / 30%) 20px
  );
  transition: transform var(--transition-fast);
}

.palette-item-placeholder--mezzanine {
  border-color: rgb(107 114 128 / 60%);
  background: repeating-linear-gradient(
    135deg,
    rgb(209 213 219 / 40%) 0,
    rgb(209 213 219 / 40%) 12px,
    rgb(148 163 184 / 35%) 12px,
    rgb(148 163 184 / 35%) 24px
  );
}

.palette-shape-preview {
  width: 100%;
  height: 64px;
  border-radius: var(--radius-md);
  border: 1px solid rgb(148 163 184 / 50%);
  background: linear-gradient(180deg, rgb(248 250 252 / 95%), rgb(241 245 249 / 95%));
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.palette-shape-preview::before {
  content: '';
  display: block;
  width: 46px;
  height: 46px;
  background: var(--shape-color, #475569);
  border-radius: 12px;
  transition: transform var(--transition-fast);
  box-shadow:
    inset 0 0 0 1px rgb(255 255 255 / 60%),
    0 4px 8px rgb(15 23 42 / 8%);
}

.palette-shape-preview--circle::before {
  width: 44px;
  height: 44px;
  border-radius: 999px;
}

.palette-shape-preview--rectangle::before {
  width: 56px;
  height: 30px;
  border-radius: 8px;
}

.palette-shape-preview--triangle::before {
  width: 48px;
  height: 42px;
  border-radius: 0;
  clip-path: polygon(50% 4%, 0% 100%, 100% 100%);
}

.palette-shape-preview--square::before {
  width: 44px;
  height: 44px;
}

.palette-shape-preview--oval::before {
  width: 56px;
  height: 34px;
  border-radius: 999px;
}

.palette-shape-preview--diamond::before {
  width: 44px;
  height: 44px;
  border-radius: 0;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

.palette-shape-preview--pentagon::before {
  width: 46px;
  height: 44px;
  border-radius: 0;
  clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%);
}

.palette-shape-preview--hexagon::before {
  width: 48px;
  height: 42px;
  border-radius: 0;
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}

.palette-shape-preview--octagon::before {
  width: 46px;
  height: 46px;
  border-radius: 0;
  clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
}

.palette-shape-preview--star::before {
  width: 46px;
  height: 46px;
  border-radius: 0;
  clip-path: polygon(
    50% 0%,
    61% 35%,
    98% 35%,
    68% 57%,
    79% 91%,
    50% 70%,
    21% 91%,
    32% 57%,
    2% 35%,
    39% 35%
  );
}

.palette-shape-preview--l-shape::before {
  width: 44px;
  height: 44px;
  border-radius: 0;
  clip-path: polygon(0% 0%, 50% 0%, 50% 50%, 100% 50%, 100% 100%, 0% 100%);
}

.palette-item:hover .palette-shape-preview::before {
  transform: scale(1.05);
}

.palette-item:hover .palette-item-icon,
.palette-item:hover .palette-item-image,
.palette-item:hover .palette-item-image img,
.palette-item:hover .palette-item-placeholder {
  transform: scale(1.03);
}

.palette-item .item-label {
  font-weight: 600;
  font-size: 13px;
  color: var(--color-text-primary);
  line-height: 1.22;
}

.palette-item .item-size {
  font-size: 11px;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.palette-item[data-category='mezzanine'] {
  border-style: dashed;
  background: linear-gradient(135deg, rgb(248 250 252 / 90%) 0%, rgb(241 245 249 / 90%) 100%);
}

.palette-item[data-category='mezzanine'] .item-label {
  color: #374151;
}

/* Saved Layouts */
#saved-layouts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
}

.saved-layout-item {
  padding: 14px;
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.saved-layout-item:hover {
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-sm);
}

.saved-layout-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text);
  margin-bottom: 4px;
}

.saved-layout-date {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-bottom: 10px;
}

.saved-layout-actions {
  display: flex;
  gap: 6px;
}

.btn-load-layout,
.btn-delete-layout {
  flex: 1;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-load-layout {
  background: var(--color-primary);
  color: white;
}

.btn-load-layout:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-delete-layout {
  background: var(--color-bg);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

.btn-delete-layout:hover {
  background: #fef2f2;
  color: #dc2626;
  border-color: #dc2626;
}
