@import url('https://fonts.googleapis.com/css2?family=Madimi+One&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;700&display=swap');

body {
  margin: 0;
  padding: 0;
  height: 100vh;
  width: 100vw;
  font-family: 'Manrope', sans-serif;
  background-image: url('../images/background/mainbackground.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  animation: moveBackground 180s linear infinite alternate;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@keyframes moveBackground {
  0% {
    background-position: 0% 50%;
  }

  100% {
    background-position: 100% 50%;
  }
}

/* Header Bar */
.top-bar {
  height: 60px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  /* Reduced side padding (was 30px, too wide on small screens) */
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  z-index: 100;
}

.studio-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: #2d3436;
  letter-spacing: -0.5px;
}

.top-actions {
  display: flex;
  gap: 15px;
}

.action-btn {
  padding: 8px 20px;
  border-radius: 8px;
  border: none;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Manrope', sans-serif;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-home {
  background: transparent;
  color: #636e72;
  border: 1px solid #b2bec3;
}

.btn-home:hover {
  background: #dfe6e9;
  color: #2d3436;
}

.btn-save {
  background: #6C63FF;
  /* Brand color */
  color: white;
  box-shadow: 0 4px 6px rgba(108, 99, 255, 0.3);
}

.btn-save:hover {
  background: #5a52d5;
  transform: translateY(-1px);
}

/* Main Workspace */
.workspace {
  flex-grow: 1;
  display: flex;
  padding: 20px;
  gap: 20px;
  height: calc(100vh - 60px);
  max-height: calc(100vh - 60px);
  box-sizing: border-box;
  overflow: hidden;
  /* Prevent panels from expanding the workspace height */
}

/* Tool Toolbar (Left) */
.toolbar-container {
  width: 70px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  border-radius: 12px;
  padding: 15px 0;
  align-items: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  overflow-y: auto;
  flex-shrink: 0;
  /* Keep fixed width */
  max-height: 100%;
}

.tool-btn {
  width: 45px;
  /* Fixed size */
  height: 45px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: #636e72;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.2rem;
  position: relative;
}

.tool-btn:hover {
  background: rgba(108, 99, 255, 0.1);
  color: #6C63FF;
}

.tool-btn.active {
  background: #6C63FF;
  color: white;
  box-shadow: 0 4px 10px rgba(108, 99, 255, 0.4);
}

/* Tooltip on hover */
.tool-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 60px;
  background: #2d3436;
  color: white;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 0.8rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 10;
}

.tool-btn:hover::after {
  opacity: 1;
}


/* Canvas Area (Center) */
.canvas-container {
  flex-grow: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(255, 255, 255, 0.5);
  /* Slight background to separate */
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  /* Scrollbars managed inside if needed */
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.05);
}

canvas {
  background: white;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  /* border: 1px solid #dfe6e9; removed border for cleaner look */
  cursor: crosshair;
}

/* Properties Sidebar (Right) */
.properties-panel {
  width: 250px;
  background: rgba(255, 255, 255, 0.8);
  /* Less transparency for controls */
  backdrop-filter: blur(12px);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 25px;
  flex-shrink: 0;
  /* Keep fixed width */
  max-height: 100%;
}

.prop-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prop-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #636e72;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Custom Range Slider */
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  border: #000000ba;
  border-radius: 10px;
  background: #43434354;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 16px;
  width: 16px;
  border-radius: 50%;
  background: #6C63FF;
  margin-top: -6px;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(108, 99, 255, 0.4);
}

input[type=range]::-webkit-slider-runnable-track {
  width: 100%;
  height: 4px;
  background: #dfe6e9;
  border-radius: 2px;
}

/* Color Picker */
.color-picker-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

#colorSelector {
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  /* Square with radius looks modern */
  cursor: pointer;
  padding: 0;
  background: none;
}

#colorPreview {
  font-weight: 600;
  color: #2d3436;
}

/* Undo/Redo Group */
.history-btns {
  display: flex;
  gap: 10px;
}

.history-btn {
  flex: 1;
  padding: 8px;
  border: 1px solid #b2bec3;
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-size: 0.9rem;
  color: #2d3436;
  transition: all 0.2s;
}

.history-btn:hover {
  background: #f1f2f6;
}

.history-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 768px) {
  .workspace {
    flex-direction: column;
    padding: 10px;
    height: auto;
    /* Allow scrolling on mobile */
  }

  .canvas-container {
    order: 1;
    min-height: 50vh;
    padding: 10px;
  }

  canvas {
    max-width: 100%;
    height: auto;
    touch-action: none;
    /* Prevent scrolling while drawing */
  }

  .toolbar-container {
    width: 100%;
    flex-direction: row;
    justify-content: center;
    height: auto;
    /* Allow auto height */
    padding: 10px;
    order: 2;
    flex-wrap: wrap;
  }

  .properties-panel {
    width: 100%;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    order: 3;
    padding-bottom: 40px;
  }

  .prop-group {
    min-width: 45%;
    /* 2 columns for props */
    align-items: center;
  }
}

/* Palette Styles */
.palette-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  width: 100%;
}

.palette-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}

.palette-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: transform 0.1s;
}

.palette-swatch:hover {
  transform: scale(1.1);
  border-color: #6C63FF;
}

.palette-btn {
  background: #dfe6e9;
  border: none;
  border-radius: 4px;
  color: #636e72;
  padding: 4px 8px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.2s;
}

.palette-btn:hover {
  background: #b2bec3;
  color: #2d3436;
}

.palette-btn.add {
  background: #6C63FF;
  color: white;
}

.palette-btn.add:hover {
  background: #5a52d5;
}