/**
 * Modern Mood Email Editor - Modular CSS
 * Design System: Modern Mood
 */

/* ========================================
   DESIGN TOKENS
   ======================================== */
:root {
  /* Modern Mood Colors */
  --mm-black: #141414;
  --mm-creme: #F8F3EB;
  --mm-lima: #E0F431;
  --mm-orange: #EC7014;
  --mm-pink: #F1B3C2;
  --mm-white: #FFFFFF;
  
  /* Editor UI Colors */
  --editor-bg: #f8fafc;
  --editor-sidebar: #ffffff;
  --editor-border: #e2e8f0;
  --editor-text: #1e293b;
  --editor-text-muted: #64748b;
  --editor-primary: var(--mm-orange);
  --editor-success: #22c55e;
  --editor-warning: #f59e0b;
  --editor-danger: #ef4444;
  
  /* Spacing */
  --editor-gap: 16px;
  --editor-radius: 12px;
}

/* ========================================
   EDITOR LAYOUT
   ======================================== */
.email-editor-container {
  display: grid;
  grid-template-columns: 300px 1fr 320px;
  height: calc(100vh - 200px);
  min-height: 600px;
  gap: var(--editor-gap);
  background: var(--editor-bg);
  border-radius: var(--editor-radius);
  overflow: hidden;
  border: 1px solid var(--editor-border);
}

/* Sidebar - Blocos */
.editor-blocks-sidebar {
  background: var(--editor-sidebar);
  border-right: 1px solid var(--editor-border);
  padding: var(--editor-gap);
  overflow-y: auto;
}

.editor-blocks-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--editor-text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.editor-blocks-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.editor-block-item {
  background: var(--mm-creme);
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 14px 10px;
  text-align: center;
  cursor: grab;
  transition: all 0.2s ease;
  user-select: none;
}

.editor-block-item:hover {
  border-color: var(--mm-orange);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(236, 112, 20, 0.15);
}

.editor-block-item:active {
  cursor: grabbing;
  transform: scale(0.95);
}

.editor-block-item.dragging {
  opacity: 0.5;
}

.editor-block-icon {
  font-size: 24px;
  margin-bottom: 6px;
}

.editor-block-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--editor-text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Canvas Central */
.editor-canvas {
  background: #e2e8f0;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.editor-email-frame {
  background: var(--mm-white);
  width: 100%;
  max-width: 600px;
  min-height: 500px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.editor-email-content {
  min-height: 400px;
  padding: 0;
}

/* Drop Zone Styles */
.editor-drop-zone {
  min-height: 80px;
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--editor-text-muted);
  font-size: 13px;
  margin: 10px 20px;
  transition: all 0.2s ease;
}

.editor-drop-zone.drag-over {
  border-color: var(--mm-orange);
  background: rgba(236, 112, 20, 0.05);
  color: var(--mm-orange);
}

.editor-drop-zone.empty-state {
  min-height: 200px;
  flex-direction: column;
  gap: 10px;
}

.editor-drop-zone .drop-icon {
  font-size: 32px;
  opacity: 0.5;
}

/* Blocos no Canvas */
.email-block {
  position: relative;
  margin: 0;
  transition: all 0.2s ease;
  cursor: pointer;
}

.email-block:hover {
  outline: 2px solid var(--mm-orange);
  outline-offset: -2px;
}

.email-block.selected {
  outline: 3px solid var(--mm-orange);
  outline-offset: -3px;
}

.email-block-actions {
  position: absolute;
  top: -12px;
  right: 10px;
  display: none;
  gap: 4px;
  z-index: 10;
}

.email-block:hover .email-block-actions,
.email-block.selected .email-block-actions {
  display: flex;
}

.block-action-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.15s ease;
}

.block-action-btn.move {
  background: var(--mm-black);
  color: var(--mm-white);
  cursor: grab;
}

.block-action-btn.duplicate {
  background: var(--mm-lima);
  color: var(--mm-black);
}

.block-action-btn.delete {
  background: var(--editor-danger);
  color: white;
}

.block-action-btn:hover {
  transform: scale(1.1);
}

/* Sidebar Direita - Propriedades */
.editor-properties-sidebar {
  background: var(--editor-sidebar);
  border-left: 1px solid var(--editor-border);
  padding: var(--editor-gap);
  overflow-y: auto;
}

.properties-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--editor-border);
}

.properties-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--editor-text);
}

.properties-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--editor-text-muted);
}

/* Property Groups */
.property-group {
  margin-bottom: 20px;
}

.property-group-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--editor-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.property-row {
  margin-bottom: 12px;
}

.property-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--editor-text);
  margin-bottom: 6px;
}

.property-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--editor-border);
  border-radius: 8px;
  font-size: 13px;
  transition: all 0.2s ease;
  font-family: inherit;
}

.property-input:focus {
  outline: none;
  border-color: var(--mm-orange);
  box-shadow: 0 0 0 3px rgba(236, 112, 20, 0.1);
}

.property-input.textarea {
  min-height: 80px;
  resize: vertical;
}

/* Color Picker Row */
.color-picker-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.color-swatch:hover {
  transform: scale(1.1);
}

.color-swatch.selected {
  border-color: var(--mm-black);
  box-shadow: 0 0 0 2px var(--mm-white), 0 0 0 4px var(--mm-black);
}

.color-swatch.custom {
  position: relative;
  overflow: hidden;
}

.color-swatch.custom input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* Font Size Slider */
.font-size-control {
  display: flex;
  align-items: center;
  gap: 10px;
}

.font-size-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--editor-border);
}

.font-size-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--mm-orange);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.font-size-value {
  min-width: 45px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--editor-text);
  background: var(--mm-creme);
  padding: 4px 8px;
  border-radius: 6px;
}

/* Toggle Switch */
.toggle-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toggle-switch label {
  font-size: 13px;
  color: var(--editor-text);
}

.toggle-checkbox {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--editor-border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.toggle-checkbox.active {
  background: var(--mm-orange);
}

.toggle-checkbox::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-checkbox.active::after {
  left: 22px;
}

/* Button Row */
.button-style-row {
  display: flex;
  gap: 6px;
}

.style-btn {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--editor-border);
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s ease;
}

.style-btn:hover {
  border-color: var(--mm-orange);
}

.style-btn.selected {
  background: var(--mm-orange);
  border-color: var(--mm-orange);
  color: white;
}

/* Alignment Buttons */
.alignment-row {
  display: flex;
  gap: 4px;
}

.align-btn {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--editor-border);
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.15s ease;
}

.align-btn:hover {
  background: var(--mm-creme);
}

.align-btn.selected {
  background: var(--mm-black);
  border-color: var(--mm-black);
  color: var(--mm-lima);
}

/* ========================================
   TOOLBAR
   ======================================== */
.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--mm-black);
  border-radius: var(--editor-radius) var(--editor-radius) 0 0;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.toolbar-btn.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--mm-white);
}

.toolbar-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.2);
}

.toolbar-btn.primary {
  background: var(--mm-lima);
  color: var(--mm-black);
}

.toolbar-btn.primary:hover {
  background: #d4e02b;
}

.toolbar-btn.danger {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.toolbar-btn.danger:hover {
  background: var(--editor-danger);
  color: white;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.2);
  margin: 0 8px;
}

/* Device Preview Toggle */
.device-toggle {
  display: flex;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 4px;
}

.device-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s ease;
}

.device-btn.active {
  background: var(--mm-white);
  color: var(--mm-black);
}

/* ========================================
   RESPONSIVE / MOBILE PREVIEW
   ======================================== */
.editor-canvas.mobile-preview .editor-email-frame {
  max-width: 375px;
}

/* ========================================
   EMPTY STATE
   ======================================== */
.editor-empty-state {
  text-align: center;
  padding: 60px 30px;
  color: var(--editor-text-muted);
}

.editor-empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.editor-empty-state h3 {
  font-size: 16px;
  color: var(--editor-text);
  margin-bottom: 8px;
}

.editor-empty-state p {
  font-size: 13px;
  line-height: 1.5;
}

/* ========================================
   BLOCK SPECIFIC STYLES
   ======================================== */

/* Header Block */
.block-header {
  background: var(--mm-creme);
  padding: 24px;
  text-align: center;
  border-bottom: 2px solid var(--mm-black);
}

.block-header img {
  max-width: 180px;
  height: auto;
}

/* Text Block */
.block-text {
  padding: 20px 30px;
}

.block-text p {
  margin: 0;
  line-height: 1.7;
}

/* Headline Block */
.block-headline {
  padding: 24px 30px 16px;
  text-align: center;
}

.block-headline h1,
.block-headline h2 {
  margin: 0;
  font-weight: 700;
  line-height: 1.2;
}

/* Button Block */
.block-button {
  padding: 16px 30px;
  text-align: center;
}

.block-button a {
  display: inline-block;
  padding: 14px 32px;
  border-radius: 30px;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Image Block */
.block-image {
  padding: 0;
}

.block-image img {
  width: 100%;
  display: block;
}

.block-image .image-placeholder {
  background: var(--editor-border);
  padding: 40px;
  text-align: center;
  color: var(--editor-text-muted);
}

/* Divider Block */
.block-divider {
  padding: 20px 30px;
}

.block-divider hr {
  border: none;
  height: 2px;
  background: var(--editor-border);
  margin: 0;
}

/* Spacer Block */
.block-spacer {
  height: 40px;
}

/* Coupon Block */
.block-coupon {
  padding: 20px 30px;
}

.block-coupon .coupon-box {
  background: var(--mm-lima);
  border: 3px dashed var(--mm-black);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
}

.block-coupon .coupon-code {
  font-size: 24px;
  font-weight: 900;
  color: var(--mm-black);
  letter-spacing: 2px;
  font-family: 'Courier New', monospace;
}

.block-coupon .coupon-description {
  font-size: 13px;
  color: var(--mm-black);
  margin-top: 8px;
}

/* Social Block */
.block-social {
  padding: 20px 30px;
  text-align: center;
}

.block-social .social-icons {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.block-social .social-icon {
  width: 36px;
  height: 36px;
  background: var(--mm-lima);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Benefits Block */
.block-benefits {
  padding: 20px 30px;
}

.block-benefits .benefits-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  text-align: center;
}

.block-benefits .benefit-item {
  padding: 12px 8px;
}

.block-benefits .benefit-icon {
  font-size: 24px;
  margin-bottom: 6px;
}

.block-benefits .benefit-text {
  font-size: 11px;
  font-weight: 600;
  color: var(--mm-black);
}

/* WhatsApp Block */
.block-whatsapp {
  padding: 20px 30px;
  text-align: center;
}

.block-whatsapp a {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #25D366;
  color: white;
  padding: 14px 28px;
  border-radius: 30px;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
}

/* Footer Block */
.block-footer {
  background: var(--mm-black);
  padding: 32px 30px;
  text-align: center;
  color: var(--mm-creme);
}

/* ========================================
   PREVIEW MODAL
   ======================================== */
.preview-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
}

.preview-modal {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 700px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.preview-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--mm-black);
  color: white;
}

.preview-modal-header h3 {
  margin: 0;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.preview-modal-close {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.preview-modal-close:hover {
  opacity: 1;
}

.preview-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.preview-modal-body iframe {
  width: 100%;
  height: 600px;
  border: none;
}

.preview-modal-actions {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  background: #f8fafc;
  border-top: 1px solid var(--editor-border);
}

.preview-modal-actions .toolbar-btn {
  flex: 1;
  justify-content: center;
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes blockAdded {
  0% {
    opacity: 0;
    transform: translateY(-10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.email-block.just-added {
  animation: blockAdded 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.email-block.shake {
  animation: shake 0.3s ease;
}
