/* Modal editor estilo ventana de OS */
#edit-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  z-index: 3000;
  align-items: center;
  justify-content: center;
  padding: 0;
}

#edit-canvas {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 60px rgba(0, 0, 0, 0.5);
  width: 95vw;
  max-width: 1400px;
  height: 92vh;
  margin: auto;
  position: relative;
  display: flex;
  flex-direction: column;
  animation: modalIn 0.3s ease;
  overflow: hidden;
}

#edit-canvas.maximized {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
}

#edit-canvas.minimized {
  width: 60vw;
  height: 60vh;
}

@keyframes modalIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Barra de título tipo ventana macOS */
.window-header {
  background: linear-gradient(180deg, #f7f7f7 0%, #ebebeb 100%);
  border-bottom: 1px solid #d0d0d0;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  border-radius: 12px 12px 0 0;
}

#edit-canvas.maximized .window-header {
  border-radius: 0;
}

.window-title {
  display: none;
}

/* Botones de control de ventana estilo macOS (izquierda) */
.window-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.window-btn {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 0.5px solid rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.window-btn:hover {
  filter: brightness(1.05);
}

.window-btn.close {
  background: linear-gradient(135deg, #ff5f57 0%, #ff4d4d 100%);
  box-shadow: 0 1px 2px rgba(255, 95, 87, 0.3);
}

.window-btn.minimize {
  background: linear-gradient(135deg, #ffbd2e 0%, #f7b731 100%);
  box-shadow: 0 1px 2px rgba(255, 189, 46, 0.3);
}

.window-btn.maximize {
  background: linear-gradient(135deg, #28c840 0%, #27c93f 100%);
  box-shadow: 0 1px 2px rgba(40, 200, 64, 0.3);
}

/* Iconos en los botones (visible al hover del header) */
.window-header:hover .window-btn::after {
  opacity: 1;
}

.window-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 9px;
  font-weight: bold;
  color: rgba(100, 30, 20, 0.8);
  opacity: 0;
  transition: opacity 0.2s;
}

.window-btn.close::after {
  content: '×';
  font-size: 13px;
  font-weight: 600;
  color: rgba(100, 30, 20, 0.9);
}

.window-btn.minimize::after {
  content: '−';
  font-size: 11px;
  font-weight: 700;
  color: rgba(130, 80, 20, 0.9);
}

.window-btn.maximize::after {
  content: '+';
  font-size: 12px;
  font-weight: 700;
  color: rgba(20, 80, 30, 0.9);
  line-height: 10px;
}

/* Menú de acciones (derecha) */
.window-menu {
  display: flex;
  gap: 10px;
  align-items: center;
}

.menu-btn {
  padding: 7px 16px;
  background: white;
  border: 1px solid #d0d0d0;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: #333;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.menu-btn:hover {
  background: #f5f5f5;
  border-color: #b0b0b0;
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
}

.menu-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.menu-btn.save {
  background: #007aff;
  color: white;
  border-color: #007aff;
}

.menu-btn.save:hover {
  background: #0056CC;
  border-color: #0056CC;
}

.menu-btn:disabled {
  background: #e0e0e0;
  color: #999;
  cursor: not-allowed;
  border-color: #d0d0d0;
  transform: none;
  box-shadow: none;
}

/* Campo título */
#edit-title {
  font-size: 22px;
  font-weight: 600;
  padding: 18px 24px;
  border: none;
  border-bottom: 2px solid #e0e0e0;
  outline: none;
  transition: border-color 0.3s;
  font-family: 'Inter', -apple-system, sans-serif;
  background: #fafafa;
}

#edit-title:focus {
  border-bottom-color: #007aff;
  background: white;
}

/* Container del editor Quill */
.editor-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: white;
}

.editor-container.focused {
  box-shadow: inset 0 0 0 2px rgba(0, 122, 255, 0.1);
}

/* Toolbar personalizada de Quill */
.ql-toolbar {
  border: none !important;
  border-bottom: 1px solid #e0e0e0 !important;
  background: #fafafa;
  padding: 12px 20px !important;
}

.ql-toolbar .ql-picker-label {
  color: #333 !important;
}

.ql-toolbar .ql-stroke {
  stroke: #333 !important;
}

.ql-toolbar .ql-fill {
  fill: #333 !important;
}

.ql-toolbar button:hover {
  background: #007aff !important;
  border-radius: 4px;
}

.ql-toolbar button:hover .ql-stroke {
  stroke: white !important;
}

.ql-toolbar button:hover .ql-fill {
  fill: white !important;
}

/* Editor Quill */
.ql-editor {
  font-size: 17px !important;
  line-height: 1.7 !important;
  padding: 24px !important;
  font-family: 'Inter', -apple-system, sans-serif !important;
  color: #333 !important;
  overflow-y: auto !important;
}

.ql-editor:focus {
  outline: none !important;
}

.ql-editor h1 {
  font-size: 32px !important;
  font-weight: 700 !important;
  margin: 20px 0 14px 0 !important;
  color: #007aff !important;
}

.ql-editor h2 {
  font-size: 26px !important;
  font-weight: 600 !important;
  margin: 16px 0 12px 0 !important;
  color: #333 !important;
}

.ql-editor h3 {
  font-size: 22px !important;
  font-weight: 600 !important;
  margin: 14px 0 10px 0 !important;
  color: #333 !important;
}

.ql-editor p {
  margin-bottom: 14px !important;
}

.ql-editor ul, .ql-editor ol {
  margin: 14px 0 !important;
  padding-left: 28px !important;
}

.ql-editor blockquote {
  border-left: 4px solid #007aff !important;
  padding-left: 18px !important;
  margin: 18px 0 !important;
  color: #666 !important;
  font-style: italic !important;
}

/* Footer con contador */
.window-footer {
  background: #fafafa;
  border-top: 1px solid #e0e0e0;
  padding: 14px 24px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.char-counter {
  font-size: 14px;
  color: #666;
  font-weight: 500;
}

.char-counter.warning {
  color: #ff9500;
  font-weight: 600;
}

.char-counter.error {
  color: #ff3b30;
  font-weight: 700;
}

/* Responsive */
@media (max-width: 768px) {
  #edit-canvas {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }

  #edit-canvas.minimized {
    width: 100vw;
    height: 80vh;
  }

  .window-header {
    padding: 12px 16px;
    border-radius: 0;
  }

  .window-controls {
    gap: 7px;
  }

  .window-btn {
    width: 12px;
    height: 12px;
  }

  .window-menu {
    gap: 8px;
  }

  .menu-btn {
    padding: 6px 12px;
    font-size: 12px;
  }

  #edit-title {
    font-size: 20px;
    padding: 16px 20px;
  }

  .ql-editor {
    font-size: 16px !important;
    padding: 20px !important;
  }

  .ql-toolbar {
    padding: 10px 16px !important;
  }
}

@media (max-width: 480px) {
  .menu-btn span {
    display: none;
  }
  
  .ql-toolbar button {
    padding: 4px !important;
  }
  
  .ql-editor {
    font-size: 15px !important;
    padding: 16px !important;
  }
}
