<template>
  <aside class="side-panel" :class="{ 'is-collapsed': collapsed }">
    <header class="side-panel-header">
      <div class="side-panel-title">{{ title }}</div>
      <button class="iconbtn" type="button" @click="toggle">{{ collapsed ? "▸" : "▾" }}</button>
    </header>
    <div v-show="!collapsed" class="side-panel-body">
      <slot />
    </div>
  </aside>
</template>

<script setup>
const props = defineProps({
  title: {
    type: String,
    default: "",
  },
  collapsed: {
    type: Boolean,
    default: false,
  },
});

const emit = defineEmits(["update:collapsed"]);

function toggle() {
  emit("update:collapsed", !props.collapsed);
}
</script>

<style scoped>
.side-panel {
  position: absolute;
  left: 16px;
  top: 175px;
  width: 320px;
  bottom: 100px;
  border-radius: 18px;
  border: 1px solid rgba(83, 214, 206, 0.24);
  background:
    radial-gradient(260px 140px at 8% 0%, rgba(63, 203, 191, 0.16), transparent 62%) padding-box,
    linear-gradient(180deg, rgba(20, 31, 37, 0.92), rgba(15, 23, 29, 0.88)) padding-box;
  box-shadow:
    0 22px 60px rgba(0, 0, 0, 0.34),
    0 0 0 1px rgba(83, 214, 206, 0.12) inset;
  overflow: hidden;
  z-index: 25;
}

.side-panel.is-collapsed {
  width: 64px;
}

.side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 10px 10px 12px;
  border-bottom: 1px solid rgba(83, 214, 206, 0.16);
  background:
    radial-gradient(360px 100px at 10% 0%, rgba(83, 214, 206, 0.24), transparent 68%),
    linear-gradient(180deg, rgba(28, 134, 122, 0.84), rgba(15, 60, 74, 0.62));
}

.side-panel-title {
  font-size: 14px;
  font-weight: 900;
  color: rgba(207, 247, 242, 0.96);
  white-space: nowrap;
}

.iconbtn {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.42);
  color: rgba(11, 27, 58, 0.86);
  font-weight: 900;
  cursor: pointer;
}

.side-panel-body {
  height: calc(100% - 52px);
  overflow: auto;
  padding: 8px;
}
</style>
