* { 
  box-sizing: border-box; 
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  display: flex;
  margin: 0;
  padding: 0;
  height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  overflow: hidden;
}

/* Toolbar Principal */
#toolbar {
  display: flex;
  flex-direction: column;
  padding: 15px;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(10px);
  width: 300px;
  overflow-y: auto;
  box-shadow: 4px 0 15px rgba(0,0,0,0.1);
  z-index: 100;
}

.section {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #e0e0e0;
}

.section-title {
  font-size: 12px;
  font-weight: bold;
  color: #666;
  text-transform: uppercase;
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.tool-btn {
  padding: 10px 5px;
  font-size: 16px;
  cursor: pointer;
  background: #fff;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  transition: all 0.2s;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.tool-btn:hover {
  background: #f5f5f5;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.tool-btn.active {
  background: #667eea;
  color: white;
  border-color: #667eea;
}

.tool-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-label {
  font-size: 9px;
  font-weight: 500;
  text-align: center;
}

/* Controles de Camadas */
.layers-panel {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 5px;
  background: #fafafa;
}

.layer-item {
  display: flex;
  align-items: center;
  padding: 8px;
  margin-bottom: 5px;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.layer-item:hover { 
  background: #e9ecef; 
  border-color: #667eea;
}

.layer-item.active { 
  background: #667eea; 
  color: white;
  border-color: #764ba2;
}

.layer-item.hidden { 
  opacity: 0.5; 
}

.layer-preview {
  width: 40px;
  height: 30px;
  background: white;
  border: 1px solid #ddd;
  margin-right: 10px;
  border-radius: 4px;
  flex-shrink: 0;
}

.layer-controls {
  display: flex;
  gap: 5px;
  margin-top: 10px;
}

.layer-btn {
  flex: 1;
  padding: 8px 4px;
  font-size: 11px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background: #e0e0e0;
  transition: background 0.2s;
}

.layer-btn:hover { 
  background: #d0d0d0; 
}

.save-option {
  margin: 5px 0;
  padding: 15px;
  display: block;
  width: 100%;
  font-size: 14px;
}

/* Range Sliders */
input[type="range"] {
  width: 100%;
  margin: 5px 0;
}

.control-group {
  margin-bottom: 15px;
}

.control-label {
  font-size: 12px;
  color: #555;
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
}

/* Controles de Tamanho do Canvas */
.canvas-size-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.canvas-size-controls input[type="number"] {
  width: 70px;
  padding: 6px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 12px;
}

.canvas-size-controls button {
  padding: 6px 12px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.canvas-size-controls button:hover {
  background: #5568d3;
}

/* Container do Canvas */
#canvas-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

#canvas-container {
  flex: 1;
  background: #2a2a2a;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: auto;
  padding: 40px;
}

#canvas-stack {
  position: relative;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  background: white;
  transform-origin: center center;
  transition: transform 0.2s ease;
}

canvas {
  position: absolute;
  top: 0;
  left: 0;
  cursor: crosshair;
  background: transparent;
}

#canvas-bg {
  background: white;
  position: relative;
}

/* Sidebar de Anúncios - SEM CONTAINER FIXO */
#ad-sidebar {
  width: 300px;
  min-width: 300px;
  background: rgba(255,255,255,0.05);
  padding: 20px 15px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-left: 1px solid rgba(255,255,255,0.2);
  overflow-y: auto;
}

/* Wrapper do anúncio - sem altura fixa */
.ad-wrapper {
  width: 100%;
  min-height: 100px;
  background: transparent;
  border-radius: 8px;
  overflow: hidden;
}

/* O iframe do AdSense vai ocupar o espaço naturalmente */
.ad-wrapper ins.adsbygoogle {
  display: block;
  width: 100%;
}

/* Modais */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(5px);
}

.modal-content {
  background: white;
  margin: 5% auto;
  padding: 30px;
  width: 90%;
  max-width: 600px;
  border-radius: 12px;
  max-height: 80vh;
  overflow-y: auto;
}

.close {
  float: right;
  font-size: 28px;
  cursor: pointer;
  color: #999;
}

.close:hover { 
  color: #333; 
}

/* Modal de Ajuda */
.help-modal-content {
  text-align: left;
}

.help-modal-content h3 {
  color: #667eea;
  margin-top: 20px;
  margin-bottom: 10px;
  font-size: 16px;
}

.help-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.help-list li {
  padding: 8px;
  margin-bottom: 5px;
  background: #f8f9fa;
  border-radius: 6px;
  border-left: 3px solid #667eea;
  font-size: 14px;
}

.help-list li strong {
  color: #667eea;
  display: inline-block;
  min-width: 100px;
}

/* Modal de Carrossel */
.carousel-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin: 20px 0;
}

.carousel-btn {
  width: 50px;
  height: 50px;
  font-size: 24px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
}

.carousel-btn:hover {
  background: #5568d3;
  transform: scale(1.1);
}

#carousel-image {
  max-width: 400px;
  max-height: 400px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: white;
}

.carousel-info {
  text-align: center;
  font-size: 16px;
  font-weight: bold;
  color: #667eea;
  margin-bottom: 10px;
}

.choose-btn {
  width: 100%;
  padding: 15px;
  font-size: 16px;
  margin-top: 10px;
}

/* Brush Preview */
#brush-preview {
  width: 50px;
  height: 50px;
  border: 2px solid #ddd;
  border-radius: 50%;
  margin: 10px auto;
  background: radial-gradient(circle, currentColor 0%, transparent 70%);
}

/* Cores */
.color-palette {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  margin-top: 10px;
}

.color-option {
  width: 100%;
  aspect-ratio: 1;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.2s;
}

.color-option:hover { 
  transform: scale(1.1); 
}

.brush-styles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-top: 10px;
}

.brush-style-btn {
  padding: 8px 4px;
  font-size: 11px;
  border: 2px solid #e0e0e0;
  background: white;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.brush-style-btn:hover {
  background: #f0f0f0;
}

.brush-style-btn.active {
  border-color: #667eea;
  background: #f0f0ff;
  color: #667eea;
  font-weight: bold;
}

#color-picker {
  width: 100%;
  height: 40px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

/* Tooltip */
.tool-btn[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 1000;
  margin-bottom: 5px;
  max-width: 200px;
  white-space: normal;
  text-align: center;
}

/* Responsividade */
@media (max-width: 1200px) {
  #ad-sidebar { 
    display: none; 
  }
}

@media (max-width: 768px) {
  #toolbar {
    position: fixed;
    bottom: 0;
    width: 100%;
    height: 250px;
    flex-direction: row;
    overflow-x: auto;
    z-index: 200;
  }
  
  #canvas-wrapper { 
    margin-bottom: 250px; 
  }
  
  #canvas-container {
    padding: 10px;
  }
  
  .tools-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
